3 Dim passCount
As Integer
4 Dim failCount
As Integer
7 Function doUnitTest() As String
8 result
= verify_testCOS()
9 If failCount
<> 0 or passCount
= 0 Then
18 Function verify_testCOS() As String
23 result
= "Test Results" & Chr
$(10) & "============" & Chr
$(10)
25 Dim testName
As String
26 Dim nr1
, nr2
As Double 'variables for test
27 testName
= "Test COS function"
30 On Error GoTo errorHandler
32 nr2
= -0.532833020333398
34 TestLog_ASSERT
Round(nr1
, 14) = Round(nr2
, 14), "the return COS is: " & nr1
36 nr2
= 0.980066577841242
38 TestLog_ASSERT
Round(nr1
, 14) = Round(nr2
, 14), "the return COS is: " & nr1
40 nr2
= 0.487187675007006
42 TestLog_ASSERT
Round(nr1
, 14) = Round(nr2
, 14), "the return COS is: " & nr1
45 result
= result
& Chr
$(10) & "Tests passed: " & passCount
& Chr
$(10) & "Tests failed: " & failCount
& Chr
$(10)
46 verify_testCOS
= 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