3 Dim passCount
As Integer
4 Dim failCount
As Integer
7 Function doUnitTest() As String
8 result
= verify_testCLng()
9 If failCount
<> 0 Or passCount
= 0 Then
18 Function verify_testCLng() As String
23 result
= "Test Results" & Chr
$(10) & "============" & Chr
$(10)
25 Dim testName
As String
26 Dim nr1
, nr2
As Long 'variables for test
27 testName
= "Test CLng function"
30 On Error GoTo errorHandler
34 TestLog_ASSERT nr1
= nr2
, "the return CLng is: " & nr1
38 TestLog_ASSERT nr1
= nr2
, "the return CLng is: " & nr1
42 TestLog_ASSERT nr1
= nr2
, "the return CLng is: " & nr1
46 TestLog_ASSERT nr1
= nr2
, "the return CLng is: " & nr1
50 REM TestLog_ASSERT nr1 = nr2, "the return CLng is: " & nr1
52 REM If the fraction is less than or equal to .5, the result will round down.
53 REM If the fraction is greater than .5, the result will round up.
57 TestLog_ASSERT nr1
= nr2
, "the return CLng is: " & nr1
61 TestLog_ASSERT nr1
= nr2
, "the return CLng is: " & nr1
65 TestLog_ASSERT nr1
= nr2
, "the return CLng is: " & nr1
67 result
= result
& Chr
$(10) & "Tests passed: " & passCount
& Chr
$(10) & "Tests failed: " & failCount
& Chr
$(10)
68 verify_testCLng
= result
72 TestLog_ASSERT (False), testName
& ": hit error handler"
75 Sub TestLog_ASSERT(assertion
As Boolean, Optional testId
As String, Optional testComment
As String)
77 If assertion
= True Then
78 passCount
= passCount
+ 1
81 If Not IsMissing(testId
) Then
82 testMsg
= testMsg
+ " : " + testId
84 If Not IsMissing(testComment
) And Not (testComment
= "") Then
85 testMsg
= testMsg
+ " (" + testComment
+ ")"
88 result
= result
& Chr
$(10) & " Failed: " & testMsg
89 failCount
= failCount
+ 1