Files
odfstudio/basic/qa/basic_coverage/test_string_replace.bas
T
Mike Kaganski 9258f7009e Rename LibreOffice Basic test files from .vb to .bas: they are not VBA
Change-Id: I4ff8a8dc855da2c60084318e067d4ec8149d055e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118330
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
2021-07-02 20:48:34 +02:00

31 lines
1.2 KiB
VB.net
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
Option VBASupport 0
Function doUnitTest() As String
TestUtil.TestInit
verify_stringReplace
doUnitTest = TestUtil.GetResult()
End Function
Sub verify_stringReplace()
On Error GoTo errorHandler
' tdf#132389 - case-insensitive operation for non-ASCII characters
retStr = Replace("ABCabc", "b", "*")
TestUtil.AssertEqual(retStr, "A*Ca*c", "case-insensitive ASCII: " & retStr)
retStr = Replace("АБВабв", "б", "*")
TestUtil.AssertEqual(retStr, "А*Ва*в", "case-insensitive non-ASCII: " & retStr)
' tdf#141045 - different length of search and replace string. It is important
' that the search string starts with the original string in order to test the error.
' Without the fix in place, the string index calculations result in a crash.
retStr = Replace("a", "abc", "ab")
TestUtil.AssertEqual(retStr, "a", "different length of search and replace string: " & retStr)
' tdf#143081 - Without the fix in place, this test would have crashed here
retStr = Replace("""Straße""", """", "&quot;")
TestUtil.AssertEqual(retStr, "&quot;Straße""&quot;", "replace doesn't crash: " & retStr)
Exit Sub
errorHandler:
TestUtil.ReportErrorHandler("verify_stringReplace", Err, Error$, Erl)
End Sub