3 Dim passCount
As Integer
4 Dim failCount
As Integer
7 Function doUnitTest() As String
8 result
= verify_testLCase()
9 If failCount
<> 0 Or passCount
= 0 Then
18 Function verify_testLCase() As String
23 result
= "Test Results" & Chr
$(10) & "============" & Chr
$(10)
25 Dim testName
As String
26 Dim str1
, str2
As String 'variables for test
27 testName
= "Test LCase function"
28 On Error GoTo errorHandler
31 str1
= LCase("LOWERCASE")
32 TestLog_ASSERT str1
= str2
, "the return LCase is: " & str1
35 str1
= LCase("LowerCase")
36 TestLog_ASSERT str1
= str2
, "the return LCase is: " & str1
39 str1
= LCase("lowercase")
40 TestLog_ASSERT str1
= str2
, "the return LCase is: " & str1
43 str1
= LCase("LOWER CASE")
44 TestLog_ASSERT str1
= str2
, "the return LCase is: " & str1
47 result
= result
& Chr
$(10) & "Tests passed: " & passCount
& Chr
$(10) & "Tests failed: " & failCount
& Chr
$(10)
48 verify_testLCase
= result
52 TestLog_ASSERT (False), testName
& ": hit error handler"
55 Sub TestLog_ASSERT(assertion
As Boolean, Optional testId
As String, Optional testComment
As String)
57 If assertion
= True Then
58 passCount
= passCount
+ 1
61 If Not IsMissing(testId
) Then
62 testMsg
= testMsg
+ " : " + testId
64 If Not IsMissing(testComment
) And Not (testComment
= "") Then
65 testMsg
= testMsg
+ " (" + testComment
+ ")"
68 result
= result
& Chr
$(10) & " Failed: " & testMsg
69 failCount
= failCount
+ 1