| 1 |
' |
| 2 |
' This file is part of the LibreOffice project. |
| 3 |
' |
| 4 |
' This Source Code Form is subject to the terms of the Mozilla Public |
| 5 |
' License, v. 2.0. If a copy of the MPL was not distributed with this |
| 6 |
' file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 7 |
' |
| 8 |
|
| 9 |
Option Explicit |
| 10 |
|
| 11 |
Function doUnitTest as String |
| 12 |
TestUtil.TestInit |
| 13 |
verify_testCCur |
| 14 |
doUnitTest = TestUtil.GetResult() |
| 15 |
End Function |
| 16 |
|
| 17 |
Sub verify_testCCur |
| 18 |
On Error GoTo errorHandler |
| 19 |
|
| 20 |
' CCUR |
| 21 |
TestUtil.AssertEqual(CCur("100"), 100, "CCur(100)") |
| 22 |
|
| 23 |
' tdf#141050 - passing a number with + sign |
| 24 |
TestUtil.AssertEqual(CCur("+100"), 100, "CCur(100)") |
| 25 |
' tdf#141050 - passing a number with - sign |
| 26 |
TestUtil.AssertEqual(CCur("-100"), -100, "CCur(-100)") |
| 27 |
|
| 28 |
' tdf#128122 - verify en_US locale currency format behavior |
| 29 |
TestUtil.AssertEqual(CCur("$100"), 100, "CCur($100)") |
| 30 |
TestUtil.AssertEqual(CCur("$1.50"), 1.5, "CCur($1.50)") |
| 31 |
|
| 32 |
' tdf#162724 - CStr must create strings that allow CCur round-trip |
| 33 |
TestUtil.AssertEqual(CCur(CStr(CCur(75.50))), 75.5, "CCur(CStr(CCur(75.50)))") |
| 34 |
|
| 35 |
verify_testCCurUnderflow |
| 36 |
verify_testCCurOverflow |
| 37 |
verify_testCCurInvalidFormat |
| 38 |
|
| 39 |
Exit Sub |
| 40 |
errorHandler: |
| 41 |
TestUtil.ReportErrorHandler("verify_testCCur", Err, Error$, Erl) |
| 42 |
End Sub |
| 43 |
|
| 44 |
sub verify_testCCurUnderflow |
| 45 |
On Error GoTo underflowHandler |
| 46 |
|
| 47 |
' tdf$128122 - test underflow condition |
| 48 |
CCur("-9223372036854775809") |
| 49 |
TestUtil.Assert(False, "verify_testCCur", "underflow error not raised") |
| 50 |
|
| 51 |
Exit Sub |
| 52 |
underflowHandler: |
| 53 |
If(Err <> 6) Then |
| 54 |
TestUtil.Assert(False, "verify_testCCur", "underflow error incorrect type") |
| 55 |
Endif |
| 56 |
End Sub |
| 57 |
|
| 58 |
sub verify_testCCurOverflow |
| 59 |
On Error GoTo overflowHandler |
| 60 |
|
| 61 |
' tdf$128122 - test overflow condition |
| 62 |
CCur("9223372036854775808") |
| 63 |
TestUtil.Assert(False, "verify_testCCur", "overflow error not raised") |
| 64 |
|
| 65 |
Exit Sub |
| 66 |
overflowHandler: |
| 67 |
If(Err <> 6) Then |
| 68 |
TestUtil.Assert(False, "verify_testCCur", "overflow error incorrect type") |
| 69 |
Endif |
| 70 |
End Sub |
| 71 |
|
| 72 |
sub verify_testCCurInvalidFormat |
| 73 |
On Error GoTo invalidFormatHandler |
| 74 |
|
| 75 |
' tdf$128122 - test invalid format in en_US locale |
| 76 |
CCur("75,50 kr") |
| 77 |
TestUtil.Assert(False, "verify_testCCur", "invalid format error not raised") |
| 78 |
|
| 79 |
Exit Sub |
| 80 |
invalidFormatHandler: |
| 81 |
If(Err <> 13) Then |
| 82 |
TestUtil.Assert(False, "verify_testCCur", "invalid format error incorrect type") |
| 83 |
Endif |
| 84 |
End Sub |