Bump version to 6.4.7.2.M8
[LibreOffice.git] / basic / qa / vba_tests / clng.vb
blob768bafee19e6795b9a5e003a33ed83675f9cec4c
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_testCLng()
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_testCLng() 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 Long 'variables for test
27 testName = "Test CLng function"
30 On Error GoTo errorHandler
32 nr2 = -1
33 nr1 = CLng(-1.1)
34 TestLog_ASSERT nr1 = nr2, "the return CLng is: " & nr1
36 nr2 = -1
37 nr1 = CLng(-1.1)
38 TestLog_ASSERT nr1 = nr2, "the return CLng is: " & nr1
40 nr2 = -2
41 nr1 = CLng(-1.9)
42 TestLog_ASSERT nr1 = nr2, "the return CLng is: " & nr1
44 nr2 = 0
45 nr1 = CLng(0.2)
46 TestLog_ASSERT nr1 = nr2, "the return CLng is: " & nr1
48 REM nr2 = 0
49 REM nr1 = CLng(0.5)
50 REM TestLog_ASSERT nr1 = nr2, "the return CLng is: " & nr1
52 REM If the fraction is less than or equal to .5, the result will round down.
53 REM If the fraction is greater than .5, the result will round up.
55 nr2 = 11
56 nr1 = CLng(10.51)
57 TestLog_ASSERT nr1 = nr2, "the return CLng is: " & nr1
59 nr2 = 30207
60 nr1 = CLng("&H75FF")
61 TestLog_ASSERT nr1 = nr2, "the return CLng is: " & nr1
63 nr2 = 1876
64 nr1 = CLng("&H754")
65 TestLog_ASSERT nr1 = nr2, "the return CLng is: " & nr1
67 result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
68 verify_testCLng = result
70 Exit Function
71 errorHandler:
72 TestLog_ASSERT (False), testName & ": hit error handler"
73 End Function
75 Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
77 If assertion = True Then
78 passCount = passCount + 1
79 Else
80 Dim testMsg As String
81 If Not IsMissing(testId) Then
82 testMsg = testMsg + " : " + testId
83 End If
84 If Not IsMissing(testComment) And Not (testComment = "") Then
85 testMsg = testMsg + " (" + testComment + ")"
86 End If
88 result = result & Chr$(10) & " Failed: " & testMsg
89 failCount = failCount + 1
90 End If
92 End Sub