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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
'
' This file is part of the LibreOffice project.
'
' This Source Code Form is subject to the terms of the Mozilla Public
' License, v. 2.0. If a copy of the MPL was not distributed with this
' file, You can obtain one at http://mozilla.org/MPL/2.0/.
'
Option Explicit
Function doUnitTest as String
TestUtil.TestInit
verify_testCCur
doUnitTest = TestUtil.GetResult()
End Function
Sub verify_testCCur
On Error GoTo errorHandler
' CCUR
TestUtil.AssertEqual(CCur("100"), 100, "CCur(100)")
' tdf#141050 - passing a number with + sign
TestUtil.AssertEqual(CCur("+100"), 100, "CCur(100)")
' tdf#141050 - passing a number with - sign
TestUtil.AssertEqual(CCur("-100"), -100, "CCur(-100)")
' tdf#128122 - verify en_US locale currency format behavior
TestUtil.AssertEqual(CCur("$100"), 100, "CCur($100)")
TestUtil.AssertEqual(CCur("$1.50"), 1.5, "CCur($1.50)")
verify_testCCurUnderflow
verify_testCCurOverflow
verify_testCCurInvalidFormat
Exit Sub
errorHandler:
TestUtil.ReportErrorHandler("verify_testCCur", Err, Error$, Erl)
End Sub
sub verify_testCCurUnderflow
On Error GoTo underflowHandler
' tdf$128122 - test underflow condition
CCur("-9223372036854775809")
TestUtil.Assert(False, "verify_testCCur", "underflow error not raised")
Exit Sub
underflowHandler:
If(Err <> 6) Then
TestUtil.Assert(False, "verify_testCCur", "underflow error incorrect type")
Endif
End Sub
sub verify_testCCurOverflow
On Error GoTo overflowHandler
' tdf$128122 - test overflow condition
CCur("9223372036854775808")
TestUtil.Assert(False, "verify_testCCur", "overflow error not raised")
Exit Sub
overflowHandler:
If(Err <> 6) Then
TestUtil.Assert(False, "verify_testCCur", "overflow error incorrect type")
Endif
End Sub
sub verify_testCCurInvalidFormat
On Error GoTo invalidFormatHandler
' tdf$128122 - test invalid format in en_US locale
CCur("75,50 kr")
TestUtil.Assert(False, "verify_testCCur", "invalid format error not raised")
Exit Sub
invalidFormatHandler:
If(Err <> 13) Then
TestUtil.Assert(False, "verify_testCCur", "invalid format error incorrect type")
Endif
End Sub
|