update emoji autocorrect entries from po-files
[LibreOffice.git] / basic / qa / vba_tests / cdec.vb
blob56166cae5a4e6354786d29db4718f429b4401093
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_testCDec()
9 If failCount <> 0 And passCount > 0 Then
10 doUnitTest = result
11 Else
12 doUnitTest = "OK"
13 End If
14 End Function
16 Function verify_testCDec() as String
17 passCount = 0
18 failCount = 0
20 result = "Test Results" & Chr$(10) & "============" & Chr$(10)
22 Dim testName As String
23 Dim ret As Double
24 testName = "Test CDec function"
25 On Error GoTo errorHandler
27 ret = CDec("")
28 TestLog_ASSERT ret = 0, "Empty string test:" & ret
30 ret = CDec("1234")
31 TestLog_ASSERT ret = 1234, "Simple number:" & ret
33 ret = CDec(" 1234 ")
34 TestLog_ASSERT ret = 1234, "Simple number with whitespaces:" & ret
36 ret = CDec("-1234")
37 TestLog_ASSERT ret = -1234, "Simple negative number:" & ret
39 ret = CDec(" - 1234 ")
40 TestLog_ASSERT ret = -1234, "Simple negative number with whitespaces:" & ret
42 '''''''''''''''
43 ' Those are erroneous, see i#64348
44 ret = CDec("1234-")
45 TestLog_ASSERT ret = -1234, "Wrong negative number1:" & ret
47 ret = CDec(" 1234 -")
48 TestLog_ASSERT ret = -1234, "Wrong negative number2:" & ret
50 'ret = CDec("79228162514264300000000000001")
51 'TestLog_ASSERT ret = 79228162514264300000000000001, "Very long number1:" & ret
52 'ret = ret+1
53 'TestLog_ASSERT ret = 79228162514264300000000000002, "Very long number2:" & ret
55 ret = CDec("79228162514264400000000000000")
56 TestLog_ASSERT ret = 62406456049664, "Very long number3:" & ret
58 ret = CDec("79228162514264340000000000000") ' gives zero
59 TestLog_ASSERT ret = 0, "Very long number4:" & ret
61 result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
62 verify_testCDec = result
64 Exit Function
65 errorHandler:
66 TestLog_ASSERT (False), testName & ": hit error handler"
67 End Function
69 Sub TestLog_ASSERT(assertion As Boolean, Optional testId As String, Optional testComment As String)
71 If assertion = True Then
72 passCount = passCount + 1
73 Else
74 Dim testMsg As String
75 If Not IsMissing(testId) Then
76 testMsg = testMsg + " : " + testId
77 End If
78 If Not IsMissing(testComment) And Not (testComment = "") Then
79 testMsg = testMsg + " (" + testComment + ")"
80 End If
82 result = result & Chr$(10) & " Failed: " & testMsg
83 failCount = failCount + 1
84 End If
86 End Sub