1 ' This file is part of the LibreOffice project.
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/.
11 Function doUnitTest() As String
14 doUnitTest
= TestUtil
.GetResult()
17 Sub verify_stringReplace()
18 On Error GoTo errorHandler
19 ' tdf#132389 - case-insensitive operation for non-ASCII characters
21 retStr
= Replace("ABCabc", "b", "*")
22 TestUtil
.AssertEqual(retStr
, "A*Ca*c", "case-insensitive ASCII: " & retStr
)
23 retStr
= Replace("АБВабв", "б", "*")
24 TestUtil
.AssertEqual(retStr
, "А*Ва*в", "case-insensitive non-ASCII: " & retStr
)
26 ' tdf#141045 - different length of search and replace string. It is important
27 ' that the search string starts with the original string in order to test the error.
28 ' Without the fix in place, the string index calculations result in a crash.
29 retStr
= Replace("a", "abc", "ab")
30 TestUtil
.AssertEqual(retStr
, "a", "different length of search and replace string: " & retStr
)
32 ' tdf#143081 - Without the fix in place, this test would have crashed here
33 retStr
= Replace("""Straße""", """", """)
34 TestUtil
.AssertEqual(retStr
, ""Straße"", "replace doesn't crash: " & retStr
)
36 ' tdf#142487 - replace of special unicode characters.
37 ' Without the fix in place, this test would have failed with:
40 retStr
= Replace("Straße", "e", "en")
41 TestUtil
.AssertEqual(retStr
, "Straßen", "special unicode character: " & retStr
)
45 TestUtil
.ReportErrorHandler("verify_stringReplace", Err
, Error$, Erl
)