Bump version to 6.4.7.2.M8
[LibreOffice.git] / basic / qa / vba_tests / iif.vb
blobfd77563e52dff99ee0baedb4f78e1876685b7c1e
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_testIIf()
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_testIIf() As String
20 passCount = 0
21 failCount = 0
23 result = "Test Results" & Chr$(10) & "============" & Chr$(10)
25 Dim testName As String
26 Dim date1, date2, testnr
27 testName = "Test IIf function"
28 On Error GoTo errorHandler
30 date2 = "it is true"
31 date1 = IIf(True, "it is true", "it is false")
32 TestLog_ASSERT date1 = date2, "the return IIf is: " & date1
34 date2 = "it is false"
35 date1 = IIf(False, "It is true", "it is false")
36 TestLog_ASSERT date1 = date2, "the return IIf is: " & date1
38 testnr = 1001
39 date2 = "Large"
40 date1 = IIf(testnr > 1000, "Large", "Small")
41 TestLog_ASSERT date1 = date2, "the return IIf is: " & date1
43 result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
44 verify_testIIf = result
46 Exit Function
47 errorHandler:
48 TestLog_ASSERT (False), testName & ": hit error handler"
49 End Function
51 Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
53 If assertion = True Then
54 passCount = passCount + 1
55 Else
56 Dim testMsg As String
57 If Not IsMissing(testId) Then
58 testMsg = testMsg + " : " + testId
59 End If
60 If Not IsMissing(testComment) And Not (testComment = "") Then
61 testMsg = testMsg + " (" + testComment + ")"
62 End If
64 result = result & Chr$(10) & " Failed: " & testMsg
65 failCount = failCount + 1
66 End If
68 End Sub