Bump version to 6.4.7.2.M8
[LibreOffice.git] / basic / qa / vba_tests / cbool.vb
blobcf3b8224d0e742e472f260c39912ea8038013bef
1 Option VBASupport 1
2 Rem Option VBASupport 1 'unREM in .vb file
3 Option Explicit
4 Dim passCount As Integer
5 Dim failCount As Integer
6 Dim result As String
8 Function doUnitTest() As String
9 result = verify_testCBool()
10 If failCount <> 0 Or passCount = 0 Then
11 doUnitTest = result
12 Else
13 doUnitTest = "OK"
14 End If
15 End Function
19 Function verify_testCBool() As String
21 passCount = 0
22 failCount = 0
24 result = "Test Results" & Chr$(10) & "============" & Chr$(10)
26 Dim testName As String
27 Dim res2, res1 As Boolean
28 Dim a1, a2 As Integer
29 testName = "Test CBool function"
30 On Error GoTo errorHandler
32 res2 = True
33 res1 = CBool(1)
34 TestLog_ASSERT res1 = res2, "the return CBool is: " & res1
36 res2 = False
37 res1 = CBool(1 = 2)
38 TestLog_ASSERT res1 = res2, "the return CBool is: " & res1
40 res2 = False
41 res1 = CBool(0)
42 TestLog_ASSERT res1 = res2, "the return CBool is: " & res1
44 res2 = True
45 res1 = CBool(21)
46 TestLog_ASSERT res1 = res2, "the return CBool is: " & res1
48 res2 = True
49 res1 = CBool("true")
50 TestLog_ASSERT res1 = res2, "the return CBool is: " & res1
52 res2 = False
53 res1 = CBool("false")
54 TestLog_ASSERT res1 = res2, "the return CBool is: " & res1
56 res2 = True
57 res1 = CBool("1")
58 TestLog_ASSERT res1 = res2, "the return CBool is: " & res1
60 res2 = True
61 res1 = CBool("-1")
62 TestLog_ASSERT res1 = res2, "the return CBool is: " & res1
64 res2 = False
65 res1 = CBool("0")
66 TestLog_ASSERT res1 = res2, "the return CBool is: " & res1
68 res2 = False
69 a1 = 1: a2 = 10
70 res1 = CBool(a1 = a2)
71 TestLog_ASSERT res1 = res2, "the return CBool is: " & res1
73 res2 = True
74 a1 = 10: a2 = 10
75 res1 = CBool(a1 = a2)
76 TestLog_ASSERT res1 = res2, "the return CBool is: " & res1
78 result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
79 verify_testCBool = result
81 Exit Function
82 errorHandler:
83 TestLog_ASSERT (False), testName & ": hit error handler"
84 End Function
86 Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
88 If assertion = True Then
89 passCount = passCount + 1
90 Else
91 Dim testMsg As String
92 If Not IsMissing(testId) Then
93 testMsg = testMsg + " : " + testId
94 End If
95 If Not IsMissing(testComment) And Not (testComment = "") Then
96 testMsg = testMsg + " (" + testComment + ")"
97 End If
99 result = result & Chr$(10) & " Failed: " & testMsg
100 failCount = failCount + 1
101 End If
103 End Sub