summaryrefslogtreecommitdiff
path: root/basic/qa/vba_tests/rate.vb
blob: 86da7e08a1d33c79d5cf1349f4d1078f652ed364 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Option VBASupport 1
Rem Option VBASupport 1
Option Explicit

Function doUnitTest() As String
verify_testRATE
doUnitTest = TestUtilModule.GetResult()
End Function

Sub verify_testRATE()

    TestUtilModule.TestInit

    Dim testName As String
    Dim TestDateTime As Date
    Dim TestStr As String
    Dim date1, date2
    testName = "Test RATE function"
    On Error GoTo errorHandler

    date2 = 0.07
    date1 = Rate(3, -5, 0, 16)
    TestUtilModule.AssertTrue(Round(date1, 2) = Round(date2, 2), "the return RATE is: " & date1)

    date2 = 0
    date1 = Rate(3, -5, 0, 15)
    TestUtilModule.AssertTrue(Round(date1, 2) = Round(date2, 2), "the return RATE is: " & date1)
    
    date2 = 0.79
    date1 = Rate(3, -5, 0, 30)
    TestUtilModule.AssertTrue(Round(date1, 2) = Round(date2, 2), "the return RATE is: " & date1)

    date2 = 1
    date1 = Rate(3, -5, 0, 35)
    TestUtilModule.AssertTrue(Round(date1, 2) = Round(date2, 2), "the return RATE is: " & date1)

    date2 = 0.077
    date1 = Rate(4, -300, 1000, 0, 0)
    TestUtilModule.AssertTrue(Round(date1, 2) = Round(date2, 2), "the return RATE is: " & date1)

    date2 = 0.14
    date1 = Rate(4, -300, 1000, 0, 1)
    TestUtilModule.AssertTrue(Round(date1, 2) = Round(date2, 2), "the return RATE is: " & date1)

    TestUtilModule.TestEnd

    Exit Sub
errorHandler:
        TestUtilModule.AssertTrue(False, testName & ": hit error handler")
End Sub