Bump version to 6.4.7.2.M8
[LibreOffice.git] / basic / qa / vba_tests / choose.vb
blob3d30cfce12ade88654fce470d6d52fee278ece54
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_testChoose()
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_testChoose() As String
20 passCount = 0
21 failCount = 0
23 result = "Test Results" & Chr$(10) & "============" & Chr$(10)
25 Dim testName As String
26 Dim var1, var2
27 testName = "Test Choose function"
30 On Error GoTo errorHandler
32 var2 = "Libre"
33 var1 = Choose(1, "Libre", "Office", "Suite")
34 TestLog_ASSERT var1 = var2, "the return Choose is: " & var1
36 var2 = "Office"
37 var1 = Choose(2, "Libre", "Office", "Suite")
38 TestLog_ASSERT var1 = var2, "the return Choose is: " & var1
40 var2 = "Suite"
41 var1 = Choose(3, "Libre", "Office", "Suite")
42 TestLog_ASSERT var1 = var2, "the return Choose is: " & var1
45 var1 = Choose(4, "Libre", "Office", "Suite")
46 TestLog_ASSERT IsNull(var1), "the return Choose is: Null4 "
48 var1 = Choose(0, "Libre", "Office", "Suite")
49 TestLog_ASSERT IsNull(var1), "the return Choose is: Null0 "
51 var1 = Choose(-1, "Libre", "Office", "Suite")
52 TestLog_ASSERT IsNull(var1), "the return Choose is: Null-1"
54 result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
55 verify_testChoose = result
57 Exit Function
58 errorHandler:
59 TestLog_ASSERT (False), testName & ": hit error handler"
60 End Function
62 Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
64 If assertion = True Then
65 passCount = passCount + 1
66 Else
67 Dim testMsg As String
68 If Not IsMissing(testId) Then
69 testMsg = testMsg + " : " + testId
70 End If
71 If Not IsMissing(testComment) And Not (testComment = "") Then
72 testMsg = testMsg + " (" + testComment + ")"
73 End If
75 result = result & Chr$(10) & " Failed: " & testMsg
76 failCount = failCount + 1
77 End If
79 End Sub