3 Dim passCount
As Integer
4 Dim failCount
As Integer
7 Function doUnitTest() As String
8 result
= verify_testCInt()
9 If failCount
<> 0 Or passCount
= 0 Then
18 Function verify_testCInt() As String
23 result
= "Test Results" & Chr
$(10) & "============" & Chr
$(10)
25 Dim testName
As String
26 Dim nr1
, nr2
As Integer 'variables for test
27 testName
= "Test CInt function"
30 On Error GoTo errorHandler
34 TestLog_ASSERT nr1
= nr2
, "the return CInt is: " & nr1
38 TestLog_ASSERT nr1
= nr2
, "the return CInt is: " & nr1
42 TestLog_ASSERT nr1
= nr2
, "the return CInt is: " & nr1
46 TestLog_ASSERT nr1
= nr2
, "the return CInt is: " & nr1
49 REM If the fraction is less than or equal to .5, the result will round down.
50 REM If the fraction is greater than .5, the result will round up.
54 REM TestLog_ASSERT nr1 = nr2, "the return CInt is: " & nr1
58 REM TestLog_ASSERT nr1 = nr2, "the return CInt is: " & nr1
62 REM TestLog_ASSERT nr1 = nr2, "the return CInt is: " & nr1
66 TestLog_ASSERT nr1
= nr2
, "the return CInt is: " & nr1
70 TestLog_ASSERT nr1
= nr2
, "the return CInt is: " & nr1
74 TestLog_ASSERT nr1
= nr2
, "the return CInt is: " & nr1
76 result
= result
& Chr
$(10) & "Tests passed: " & passCount
& Chr
$(10) & "Tests failed: " & failCount
& Chr
$(10)
77 verify_testCInt
= result
81 TestLog_ASSERT (False), testName
& ": hit error handler"
84 Sub TestLog_ASSERT(assertion
As Boolean, Optional testId
As String, Optional testComment
As String)
86 If assertion
= True Then
87 passCount
= passCount
+ 1
90 If Not IsMissing(testId
) Then
91 testMsg
= testMsg
+ " : " + testId
93 If Not IsMissing(testComment
) And Not (testComment
= "") Then
94 testMsg
= testMsg
+ " (" + testComment
+ ")"
97 result
= result
& Chr
$(10) & " Failed: " & testMsg
98 failCount
= failCount
+ 1