2 Rem Option VBASupport 1
4 Dim passCount
As Integer
5 Dim failCount
As Integer
8 Function doUnitTest() As String
9 result
= verify_testRATE()
10 If failCount
<> 0 or passCount
= 0 Then
19 Function verify_testRATE() As String
24 result
= "Test Results" & Chr
$(10) & "============" & Chr
$(10)
26 Dim testName
As String
27 Dim TestDateTime
As Date
30 testName
= "Test RATE function"
31 On Error GoTo errorHandler
34 date1
= Rate(3, -5, 0, 16)
35 TestLog_ASSERT
Round(date1
, 2) = Round(date2
, 2), "the return RATE is: " & date1
38 date1
= Rate(3, -5, 0, 15)
39 TestLog_ASSERT
Round(date1
, 2) = Round(date2
, 2), "the return RATE is: " & date1
42 date1
= Rate(3, -5, 0, 30)
43 TestLog_ASSERT
Round(date1
, 2) = Round(date2
, 2), "the return RATE is: " & date1
46 date1
= Rate(3, -5, 0, 35)
47 TestLog_ASSERT
Round(date1
, 2) = Round(date2
, 2), "the return RATE is: " & date1
50 date1
= Rate(4, -300, 1000, 0, 0)
51 TestLog_ASSERT
Round(date1
, 2) = Round(date2
, 2), "the return RATE is: " & date1
54 date1
= Rate(4, -300, 1000, 0, 1)
55 TestLog_ASSERT
Round(date1
, 2) = Round(date2
, 2), "the return RATE is: " & date1
58 result
= result
& Chr
$(10) & "Tests passed: " & passCount
& Chr
$(10) & "Tests failed: " & failCount
& Chr
$(10)
59 verify_testRATE
= result
63 TestLog_ASSERT (False), testName
& ": hit error handler"
66 Sub TestLog_ASSERT(assertion
As Boolean, Optional testId
As String, Optional testComment
As String)
68 If assertion
= True Then
69 passCount
= passCount
+ 1
72 If Not IsMissing(testId
) Then
73 testMsg
= testMsg
+ " : " + testId
75 If Not IsMissing(testComment
) And Not (testComment
= "") Then
76 testMsg
= testMsg
+ " (" + testComment
+ ")"
79 result
= result
& Chr
$(10) & " Failed: " & testMsg
80 failCount
= failCount
+ 1