Files
odfstudio/basic/qa/basic_coverage/test_str_method.bas
T
Mike Kaganski 22d7827c66 tdf#168569: support date values in string pool
Commit f45463d8e2 (tdf#93727 Support date
literals in basic, 2017-05-24) introduced correct parsing of literals
like #2025-09-26#. However, it didn't retain the value type; there was
a discussion about that in gerrit, but no solution was found, and type
was set to double.

Later, a similar problem (storing type of value in compiled image) was
fixed in commit 5eedb3beea (tdf#142460:
properly handle boolean values in string pool, 2021-06-25).

This change reuses the same method to store date type using 'd' char in
the string pool.

Change-Id: I32e8497ece1f30980ba6d4fca248687b817348f2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191555
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2025-09-26 23:17:10 +02:00

43 lines
1.5 KiB
VB.net

' 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_testStr
doUnitTest = TestUtil.GetResult()
End Function
Dim failedAssertion As Boolean, messages As String
Sub verify_testStr
On Error GoTo errorHandler
' If a string is passed as argument, it is returned without any changes
TestUtil.AssertEqualStrict(Str(""), "", "Str("""")")
TestUtil.AssertEqualStrict(Str(" "), " ", "Str("" "")")
TestUtil.AssertEqualStrict(Str(" 00 "), " 00 ", "Str("" 00 "")")
' Non-negative numbers are preceded by a blank space
TestUtil.AssertEqualStrict(Str(0), " 0", "Str(0)")
TestUtil.AssertEqualStrict(Str(1 / 10), " 0.1", "Str(1 / 10)")
' Negative numbers are preceded by a minus sign
TestUtil.AssertEqualStrict(Str(-1 / 10), "-0.1", "Str(-1 / 10)")
' Dates are converted into locale-dependent strings (test uses en-US)
TestUtil.AssertEqualStrict(Str(CDate("2025-09-26")), "09/26/2025", "Str(CDate(""2025-09-26""))")
TestUtil.AssertEqualStrict(Str(#2025-09-26#), "09/26/2025", "Str(#2025-09-26#)")
TestUtil.AssertEqualStrict(Str(true), "True", "Str(true)")
Exit Sub
errorHandler:
TestUtil.ReportErrorHandler("verify_testStr", Err, Error$, Erl)
End Sub