Bump version to 6.4.7.2.M8
[LibreOffice.git] / basic / qa / vba_tests / cdbl.vb
blobbb51c6a00e609ed3f84c41fb9c0d4eb342a22dcc
1 Option VBASupport 1
2 Option Explicit
3 Dim passCount As Integer
4 Dim failCount As Integer
5 Dim result As String
7 Function doUnitTest() As String
8 result = verify_testCdbl()
9 If failCount <> 0 Or passCount = 0 Then
10 doUnitTest = result
11 Else
12 doUnitTest = "OK"
13 End If
14 End Function
18 Function verify_testCdbl() As String
20 passCount = 0
21 failCount = 0
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 Cdbl function"
28 On Error GoTo errorHandler
30 nr2 = 0
31 nr1 = CDbl(0)
32 TestLog_ASSERT nr1 = nr2, "the return Cdbl is: " & nr1
34 nr2 = 10.1234567890123
35 nr1 = CDbl(10.1234567890123)
36 TestLog_ASSERT nr1 = nr2, "the return Cdbl is: " & nr1
38 nr2 = 0.00005
39 nr1 = CDbl(0.005 * 0.01)
40 TestLog_ASSERT nr1 = nr2, "the return Cdbl is: " & nr1
42 nr2 = 20
43 nr1 = CDbl("20")
44 TestLog_ASSERT nr1 = nr2, "the return Cdbl is: " & nr1
47 result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
48 verify_testCdbl = result
50 Exit Function
51 errorHandler:
52 TestLog_ASSERT (False), testName & ": hit error handler"
53 End Function
55 Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
57 If assertion = True Then
58 passCount = passCount + 1
59 Else
60 Dim testMsg As String
61 If Not IsMissing(testId) Then
62 testMsg = testMsg + " : " + testId
63 End If
64 If Not IsMissing(testComment) And Not (testComment = "") Then
65 testMsg = testMsg + " (" + testComment + ")"
66 End If
68 result = result & Chr$(10) & " Failed: " & testMsg
69 failCount = failCount + 1
70 End If
72 End Sub