Debian Codegraph @

basic/qa/basic_coverage/test_isnumeric_method.bas

raw
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_IsNumeric
14 doUnitTest = TestUtil.GetResult()
15 End Function
16
17 Sub verify_IsNumeric
18 On Error GoTo errorHandler
19
20 dim aVariant as Variant
21 aVariant = 3
22 TestUtil.Assert(IsNumeric(aVariant), "IsNumeric(aVariant)")
23
24 TestUtil.Assert(IsNumeric(" 0 "), "IsNumeric("" 0 "")")
25 TestUtil.Assert(IsNumeric(" +0 "), "IsNumeric("" +0 "")")
26 TestUtil.Assert(IsNumeric(" -0 "), "IsNumeric("" -0 "")")
27
28 ' Note: the following test behaves different in VBA;
29 ' should it be unified maybe in non-VBA, too (a breaking change)?
30 TestUtil.Assert(Not IsNumeric(True), "Not IsNumeric(True)")
31
32 TestUtil.Assert(Not IsNumeric(""), "Not IsNumeric("""")")
33 TestUtil.Assert(Not IsNumeric(" "), "Not IsNumeric("" "")")
34 TestUtil.Assert(Not IsNumeric(" + "), "Not IsNumeric("" + "")")
35 TestUtil.Assert(Not IsNumeric(" - "), "Not IsNumeric("" - "")")
36 ' Note: the two following tests behave different in VBA;
37 ' should it be unified maybe in non-VBA, too (a breaking change)?
38 TestUtil.Assert(Not IsNumeric(" + 0 "), "Not IsNumeric("" + 0 "")")
39 TestUtil.Assert(Not IsNumeric(" - 0 "), "Not IsNumeric("" - 0 "")")
40
41 Exit Sub
42 errorHandler:
43 TestUtil.ReportErrorHandler("verify_IsNumeric", Err, Error$, Erl)
44 End Sub