3 Dim passCount
As Integer
4 Dim failCount
As Integer
7 Function doUnitTest() As String
8 result
= verify_testStrReverse()
9 If failCount
<> 0 or passCount
= 0 Then
18 Function verify_testStrReverse() As String
23 result
= "Test Results" & Chr
$(10) & "============" & Chr
$(10)
25 Dim testName
As String
27 testName
= "Test StrReverse function"
28 On Error GoTo errorHandler
31 date1
= StrReverse("abcd")
32 TestLog_ASSERT date1
= date2
, "the return StrReverse is: " & date1
35 date1
= StrReverse("ABABAB")
36 TestLog_ASSERT date1
= date2
, "the return StrReverse is: " & date1
39 date1
= StrReverse("123456")
40 TestLog_ASSERT date1
= date2
, "the return StrReverse is: " & date1
44 TestLog_ASSERT date1
= date2
, "the return StrReverse is: " & date1
46 result
= result
& Chr
$(10) & "Tests passed: " & passCount
& Chr
$(10) & "Tests failed: " & failCount
& Chr
$(10)
47 verify_testStrReverse
= result
51 TestLog_ASSERT (False), testName
& ": hit error handler"
54 Sub TestLog_ASSERT(assertion
As Boolean, Optional testId
As String, Optional testComment
As String)
56 If assertion
= True Then
57 passCount
= passCount
+ 1
60 If Not IsMissing(testId
) Then
61 testMsg
= testMsg
+ " : " + testId
63 If Not IsMissing(testComment
) And Not (testComment
= "") Then
64 testMsg
= testMsg
+ " (" + testComment
+ ")"
67 result
= result
& Chr
$(10) & " Failed: " & testMsg
68 failCount
= failCount
+ 1