3 Dim passCount
As Integer
4 Dim failCount
As Integer
7 Function doUnitTest() As String
8 result
= verify_testVal()
9 If failCount
<> 0 or passCount
= 0 Then
18 Function verify_testVal() As String
23 result
= "Test Results" & Chr
$(10) & "============" & Chr
$(10)
25 Dim testName
As String
27 testName
= "Test Val function"
28 On Error GoTo errorHandler
31 date1
= Val("02/04/2010")
32 TestLog_ASSERT date1
= date2
, "the return Val is: " & date1
36 TestLog_ASSERT date1
= date2
, "the return Val is: " & date1
40 TestLog_ASSERT date1
= date2
, "the return Val is: " & date1
43 date1
= Val("50 Park Lane")
44 TestLog_ASSERT date1
= date2
, "the return Val is: " & date1
47 date1
= Val("1320 then some text")
48 TestLog_ASSERT date1
= date2
, "the return Val is: " & date1
52 TestLog_ASSERT date1
= date2
, "the return Val is: " & date1
55 date1
= Val("sometext")
56 TestLog_ASSERT date1
= date2
, "the return Val is: " & date1
59 REM date1 = Val("1, 2")
60 REM TestLog_ASSERT date1 = date2, "the return Val is: " & date1
65 TestLog_ASSERT date1
= date2
, "the return Val is: " & date1
66 result
= result
& Chr
$(10) & "Tests passed: " & passCount
& Chr
$(10) & "Tests failed: " & failCount
& Chr
$(10)
67 verify_testVal
= result
71 TestLog_ASSERT (False), testName
& ": hit error handler"
74 Sub TestLog_ASSERT(assertion
As Boolean, Optional testId
As String, Optional testComment
As String)
76 If assertion
= True Then
77 passCount
= passCount
+ 1
80 If Not IsMissing(testId
) Then
81 testMsg
= testMsg
+ " : " + testId
83 If Not IsMissing(testComment
) And Not (testComment
= "") Then
84 testMsg
= testMsg
+ " (" + testComment
+ ")"
87 result
= result
& Chr
$(10) & " Failed: " & testMsg
88 failCount
= failCount
+ 1