3 Dim passCount
As Integer
4 Dim failCount
As Integer
7 Function doUnitTest() As String
8 result
= verify_testYear()
9 If failCount
<> 0 or passCount
= 0 Then
18 Function verify_testYear() As String
23 result
= "Test Results" & Chr
$(10) & "============" & Chr
$(10)
25 Dim testName
As String
27 testName
= "Test Year function"
28 On Error GoTo errorHandler
31 date1
= Year("12/2/1969")
32 TestLog_ASSERT date1
= date2
, "the return Year is: " & date1
36 TestLog_ASSERT date1
= date2
, "the return Year is: " & date1
38 result
= result
& Chr
$(10) & "Tests passed: " & passCount
& Chr
$(10) & "Tests failed: " & failCount
& Chr
$(10)
39 verify_testYear
= result
43 TestLog_ASSERT (False), testName
& ": hit error handler"
46 Sub TestLog_ASSERT(assertion
As Boolean, Optional testId
As String, Optional testComment
As String)
48 If assertion
= True Then
49 passCount
= passCount
+ 1
52 If Not IsMissing(testId
) Then
53 testMsg
= testMsg
+ " : " + testId
55 If Not IsMissing(testComment
) And Not (testComment
= "") Then
56 testMsg
= testMsg
+ " (" + testComment
+ ")"
59 result
= result
& Chr
$(10) & " Failed: " & testMsg
60 failCount
= failCount
+ 1