3 Dim passCount
As Integer
4 Dim failCount
As Integer
7 Function doUnitTest() As String
8 result
= verify_testChoose()
9 If failCount
<> 0 Or passCount
= 0 Then
18 Function verify_testChoose() As String
23 result
= "Test Results" & Chr
$(10) & "============" & Chr
$(10)
25 Dim testName
As String
27 testName
= "Test Choose function"
30 On Error GoTo errorHandler
33 var1
= Choose(1, "Libre", "Office", "Suite")
34 TestLog_ASSERT var1
= var2
, "the return Choose is: " & var1
37 var1
= Choose(2, "Libre", "Office", "Suite")
38 TestLog_ASSERT var1
= var2
, "the return Choose is: " & var1
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
59 TestLog_ASSERT (False), testName
& ": hit error handler"
62 Sub TestLog_ASSERT(assertion
As Boolean, Optional testId
As String, Optional testComment
As String)
64 If assertion
= True Then
65 passCount
= passCount
+ 1
68 If Not IsMissing(testId
) Then
69 testMsg
= testMsg
+ " : " + testId
71 If Not IsMissing(testComment
) And Not (testComment
= "") Then
72 testMsg
= testMsg
+ " (" + testComment
+ ")"
75 result
= result
& Chr
$(10) & " Failed: " & testMsg
76 failCount
= failCount
+ 1