tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / basic / qa / basic_coverage / test_string_replace.bas
blob2b0f6354cd040cb235c11335e3075c2ff7db2c07
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/.
8 Option VBASupport 0
9 Option Explicit
11 Function doUnitTest() As String
12 TestUtil.TestInit
13 verify_stringReplace
14 doUnitTest = TestUtil.GetResult()
15 End Function
17 Sub verify_stringReplace()
18 On Error GoTo errorHandler
19 ' tdf#132389 - case-insensitive operation for non-ASCII characters
20 Dim retStr
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:
38 ' - Expected: Straßen
39 ' - Actual : Straßeen
40 retStr = Replace("Straße", "e", "en")
41 TestUtil.AssertEqual(retStr, "Straßen", "special unicode character: " & retStr)
43 Exit Sub
44 errorHandler:
45 TestUtil.ReportErrorHandler("verify_stringReplace", Err, Error$, Erl)
46 End Sub