3 Dim passCount
As Integer
4 Dim failCount
As Integer
7 Function doUnitTest() As String
8 result
= verify_testIsNumeric()
9 If failCount
<> 0 Or passCount
= 0 Then
18 Function verify_testIsNumeric() As String
23 result
= "Test Results" & Chr
$(10) & "============" & Chr
$(10)
25 Dim testName
As String
27 testName
= "Test IsNumeric function"
28 On Error GoTo errorHandler
31 date1
= IsNumeric(123)
32 TestLog_ASSERT date1
= date2
, "the return IsNumeric is: " & date1
35 date1
= IsNumeric(-123)
36 TestLog_ASSERT date1
= date2
, "the return IsNumeric is: " & date1
39 date1
= IsNumeric(123.8)
40 TestLog_ASSERT date1
= date2
, "the return IsNumeric is: " & date1
43 date1
= IsNumeric("a")
44 TestLog_ASSERT date1
= date2
, "the return IsNumeric is: " & date1
47 rem date1 = IsNumeric(True)
48 rem TestLog_ASSERT date1 = date2, "the return IsNumeric is: " & date1
51 date1
= IsNumeric("123")
52 TestLog_ASSERT date1
= date2
, "the return IsNumeric is: " & date1
54 result
= result
& Chr
$(10) & "Tests passed: " & passCount
& Chr
$(10) & "Tests failed: " & failCount
& Chr
$(10)
55 verify_testIsNumeric
= 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