summaryrefslogtreecommitdiffstats
path: root/basic/qa/basic_coverage/test_string_replace.bas
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
commited5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch)
tree7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /basic/qa/basic_coverage/test_string_replace.bas
parentInitial commit. (diff)
downloadlibreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.tar.xz
libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.zip
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'basic/qa/basic_coverage/test_string_replace.bas')
-rw-r--r--basic/qa/basic_coverage/test_string_replace.bas39
1 files changed, 39 insertions, 0 deletions
diff --git a/basic/qa/basic_coverage/test_string_replace.bas b/basic/qa/basic_coverage/test_string_replace.bas
new file mode 100644
index 000000000..d68f36fbb
--- /dev/null
+++ b/basic/qa/basic_coverage/test_string_replace.bas
@@ -0,0 +1,39 @@
+Option VBASupport 0
+Option Explicit
+
+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
+ Dim retStr
+ 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)
+
+ ' tdf#142487 - replace of special unicode characters.
+ ' Without the fix in place, this test would have failed with:
+ ' - Expected: Straßen
+ ' - Actual : Straßeen
+ retStr = Replace("Straße", "e", "en")
+ TestUtil.AssertEqual(retStr, "Straßen", "special unicode character: " & retStr)
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_stringReplace", Err, Error$, Erl)
+End Sub