LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / basic / qa / basic_coverage / test_string_replace.bas
blobd68f36fbb662c131d9cb372b85e0e23d502c21dc
1 Option VBASupport 0
2 Option Explicit
4 Function doUnitTest() As String
5 TestUtil.TestInit
6 verify_stringReplace
7 doUnitTest = TestUtil.GetResult()
8 End Function
10 Sub verify_stringReplace()
11 On Error GoTo errorHandler
12 ' tdf#132389 - case-insensitive operation for non-ASCII characters
13 Dim retStr
14 retStr = Replace("ABCabc", "b", "*")
15 TestUtil.AssertEqual(retStr, "A*Ca*c", "case-insensitive ASCII: " & retStr)
16 retStr = Replace("АБВабв", "б", "*")
17 TestUtil.AssertEqual(retStr, "А*Ва*в", "case-insensitive non-ASCII: " & retStr)
19 ' tdf#141045 - different length of search and replace string. It is important
20 ' that the search string starts with the original string in order to test the error.
21 ' Without the fix in place, the string index calculations result in a crash.
22 retStr = Replace("a", "abc", "ab")
23 TestUtil.AssertEqual(retStr, "a", "different length of search and replace string: " & retStr)
25 ' tdf#143081 - Without the fix in place, this test would have crashed here
26 retStr = Replace("""Straße""", """", """)
27 TestUtil.AssertEqual(retStr, ""Straße"", "replace doesn't crash: " & retStr)
29 ' tdf#142487 - replace of special unicode characters.
30 ' Without the fix in place, this test would have failed with:
31 ' - Expected: Straßen
32 ' - Actual : Straßeen
33 retStr = Replace("Straße", "e", "en")
34 TestUtil.AssertEqual(retStr, "Straßen", "special unicode character: " & retStr)
36 Exit Sub
37 errorHandler:
38 TestUtil.ReportErrorHandler("verify_stringReplace", Err, Error$, Erl)
39 End Sub