Debian Codegraph @

basic/qa/basic_coverage/test_str_method.bas

raw
1 ' This file is part of the LibreOffice project.
2 '
3 ' This Source Code Form is subject to the terms of the Mozilla Public
4 ' License, v. 2.0. If a copy of the MPL was not distributed with this
5 ' file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 '
7
8 Option Explicit
9
10 Function doUnitTest as String
11 TestUtil.TestInit
12 verify_testStr
13 doUnitTest = TestUtil.GetResult()
14 End Function
15
16 Dim failedAssertion As Boolean, messages As String
17
18 Sub verify_testStr
19 On Error GoTo errorHandler
20
21 ' If a string is passed as argument, it is returned without any changes
22 TestUtil.AssertEqualStrict(Str(""), "", "Str("""")")
23 TestUtil.AssertEqualStrict(Str(" "), " ", "Str("" "")")
24 TestUtil.AssertEqualStrict(Str(" 00 "), " 00 ", "Str("" 00 "")")
25
26 ' Non-negative numbers are preceded by a blank space
27 TestUtil.AssertEqualStrict(Str(0), " 0", "Str(0)")
28 TestUtil.AssertEqualStrict(Str(1 / 10), " 0.1", "Str(1 / 10)")
29
30 ' Negative numbers are preceded by a minus sign
31 TestUtil.AssertEqualStrict(Str(-1 / 10), "-0.1", "Str(-1 / 10)")
32
33 ' Dates are converted into locale-dependent strings (test uses en-US)
34 TestUtil.AssertEqualStrict(Str(CDate("2025-09-26")), "09/26/2025", "Str(CDate(""2025-09-26""))")
35 TestUtil.AssertEqualStrict(Str(#2025-09-26#), "09/26/2025", "Str(#2025-09-26#)")
36
37 TestUtil.AssertEqualStrict(Str(true), "True", "Str(true)")
38
39 Exit Sub
40 errorHandler:
41 TestUtil.ReportErrorHandler("verify_testStr", Err, Error$, Erl)
42 End Sub