Bump version to 6.4.7.2.M8
[LibreOffice.git] / basic / qa / vba_tests / rate.vb
blob898705911b32a54f148f387d9d34d4d8d8368eaa
1 Option VBASupport 1
2 Rem Option VBASupport 1
3 Option Explicit
4 Dim passCount As Integer
5 Dim failCount As Integer
6 Dim result As String
8 Function doUnitTest() As String
9 result = verify_testRATE()
10 If failCount <> 0 or passCount = 0 Then
11 doUnitTest = result
12 Else
13 doUnitTest = "OK"
14 End If
15 End Function
19 Function verify_testRATE() As String
21 passCount = 0
22 failCount = 0
24 result = "Test Results" & Chr$(10) & "============" & Chr$(10)
26 Dim testName As String
27 Dim TestDateTime As Date
28 Dim TestStr As String
29 Dim date1, date2
30 testName = "Test RATE function"
31 On Error GoTo errorHandler
33 date2 = 0.07
34 date1 = Rate(3, -5, 0, 16)
35 TestLog_ASSERT Round(date1, 2) = Round(date2, 2), "the return RATE is: " & date1
37 date2 = 0
38 date1 = Rate(3, -5, 0, 15)
39 TestLog_ASSERT Round(date1, 2) = Round(date2, 2), "the return RATE is: " & date1
41 date2 = 0.79
42 date1 = Rate(3, -5, 0, 30)
43 TestLog_ASSERT Round(date1, 2) = Round(date2, 2), "the return RATE is: " & date1
45 date2 = 1
46 date1 = Rate(3, -5, 0, 35)
47 TestLog_ASSERT Round(date1, 2) = Round(date2, 2), "the return RATE is: " & date1
49 date2 = 0.077
50 date1 = Rate(4, -300, 1000, 0, 0)
51 TestLog_ASSERT Round(date1, 2) = Round(date2, 2), "the return RATE is: " & date1
53 date2 = 0.14
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
61 Exit Function
62 errorHandler:
63 TestLog_ASSERT (False), testName & ": hit error handler"
64 End Function
66 Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
68 If assertion = True Then
69 passCount = passCount + 1
70 Else
71 Dim testMsg As String
72 If Not IsMissing(testId) Then
73 testMsg = testMsg + " : " + testId
74 End If
75 If Not IsMissing(testComment) And Not (testComment = "") Then
76 testMsg = testMsg + " (" + testComment + ")"
77 End If
79 result = result & Chr$(10) & " Failed: " & testMsg
80 failCount = failCount + 1
81 End If
83 End Sub