Bump version to 6.4.7.2.M8
[LibreOffice.git] / basic / qa / vba_tests / ismissing.vb
blob496a57a533e73eb3b9409c01e6ae6f150e758934
1 Option VBASupport 1
2 Option Explicit
3 Dim passCount As Integer
4 Dim failCount As Integer
5 Dim result As String
7 Function doUnitTest() As String
8 result = verify_testIsMissing()
9 If failCount <> 0 Or passCount = 0 Then
10 doUnitTest = result
11 Else
12 doUnitTest = "OK"
13 End If
14 End Function
18 Function verify_testIsMissing() As String
20 passCount = 0
21 failCount = 0
23 result = "Test Results" & Chr$(10) & "============" & Chr$(10)
25 Dim testName As String
26 Dim num1, num2 As Integer
27 testName = "Test IsMissing function"
28 On Error GoTo errorHandler
30 num1 = ReturnTwice()
31 TestLog_ASSERT IsNull(num1)
33 num2 = 4
34 num1 = ReturnTwice(2)
35 TestLog_ASSERT num1 = num2, "the return IsMissing is: " & num1
37 result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
38 verify_testIsMissing = result
40 Exit Function
41 errorHandler:
42 TestLog_ASSERT (False), testName & ": hit error handler"
43 End Function
45 Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
47 If assertion = True Then
48 passCount = passCount + 1
49 Else
50 Dim testMsg As String
51 If Not IsMissing(testId) Then
52 testMsg = testMsg + " : " + testId
53 End If
54 If Not IsMissing(testComment) And Not (testComment = "") Then
55 testMsg = testMsg + " (" + testComment + ")"
56 End If
58 result = result & Chr$(10) & " Failed: " & testMsg
59 failCount = failCount + 1
60 End If
62 End Sub
63 ' Function procedure definition.
64 Function ReturnTwice(Optional A)
65 If IsMissing(A) Then
66 ' If argument is missing, return a Null.
67 ReturnTwice = Null
68 Else
69 ' If argument is present, return twice the value.
70 ReturnTwice = A * 2
71 End If
72 End Function