1 Rem Attribute VBA_ModuleType=VBAModule
4 Dim passCount
As Integer
5 Dim failCount
As Integer
8 Function doUnitTest() As String
9 result
= verify_testASC()
10 If failCount
<> 0 Or passCount
= 0 Then
19 Function verify_testASC() As String
24 result
= "Test Results" & Chr
$(10) & "============" & Chr
$(10)
26 Dim testName
As String
27 Dim nr1
, nr2
As Double
29 testName
= "Test ASC function"
30 On Error GoTo errorHandler
34 TestLog_ASSERT nr1
= nr2
, "the return ASC is: " & nr1
38 TestLog_ASSERT nr1
= nr2
, "the return ASC is: " & nr1
43 TestLog_ASSERT nr1
= nr2
, "the return ASC is: " & nr1
45 result
= result
& Chr
$(10) & "Tests passed: " & passCount
& Chr
$(10) & "Tests failed: " & failCount
& Chr
$(10)
46 verify_testASC
= result
50 TestLog_ASSERT (False), testName
& ": hit error handler"
53 Sub TestLog_ASSERT(assertion
As Boolean, Optional testId
As String, Optional testComment
As String)
55 If assertion
= True Then
56 passCount
= passCount
+ 1
59 If Not IsMissing(testId
) Then
60 testMsg
= testMsg
+ " : " + testId
62 If Not IsMissing(testComment
) And Not (testComment
= "") Then
63 testMsg
= testMsg
+ " (" + testComment
+ ")"
66 result
= result
& Chr
$(10) & " Failed: " & testMsg
67 failCount
= failCount
+ 1