3 Dim passCount
As Integer
4 Dim failCount
As Integer
7 Function doUnitTest() As String
8 result
= verify_testDateValue()
9 If failCount
<> 0 And passCount
> 0 Then
18 Function verify_testDateValue() as String
23 result
= "Test Results" & Chr
$(10) & "============" & Chr
$(10)
25 Dim testName
As String
26 Dim TestDateTime
As Date
28 Dim date1
, date2
As Date
29 testName
= "Test DateValue function"
32 On Error GoTo errorHandler
34 date1
= DateValue("February 12, 1969") '2/12/1969
35 TestLog_ASSERT date1
= date2
, "the return date is: " & date1
38 date1
= DateValue("21/01/2008") '1/21/2008
39 TestLog_ASSERT date1
= date2
, "the return date is: " & date1
40 result
= result
& Chr
$(10) & "Tests passed: " & passCount
& Chr
$(10) & "Tests failed: " & failCount
& Chr
$(10)
41 verify_testDateValue
= result
45 TestLog_ASSERT (False), testName
& ": hit error handler"
48 Sub TestLog_ASSERT(assertion
As Boolean, Optional testId
As String, Optional testComment
As String)
50 If assertion
= True Then
51 passCount
= passCount
+ 1
54 If Not IsMissing(testId
) Then
55 testMsg
= testMsg
+ " : " + testId
57 If Not IsMissing(testComment
) And Not (testComment
= "") Then
58 testMsg
= testMsg
+ " (" + testComment
+ ")"
61 result
= result
& Chr
$(10) & " Failed: " & testMsg
62 failCount
= failCount
+ 1