2 ' This file is part of the LibreOffice project.
4 ' This Source Code Form is subject to the terms of the Mozilla Public
5 ' License, v. 2.0. If a copy of the MPL was not distributed with this
6 ' file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 Function doUnitTest() As String
15 doUnitTest
= TestUtil
.GetResult()
18 Sub verify_testReplace()
19 On Error GoTo errorHandler
21 TestUtil
.AssertEqual(Replace("abcbcdBc", "bc", "ef"), "aefefdBc", "Replace(""abcbcdBc"", ""bc"", ""ef"")")
22 TestUtil
.AssertEqual(Replace("abcbcdbc", "bc", "ef"), "aefefdef", "Replace(""abcbcdbc"", ""bc"", ""ef"")")
23 TestUtil
.AssertEqual(Replace("abcbcdBc", "bc", "ef", 1, -1, vbBinaryCompare
), "aefefdBc", "Replace(""abcbcdBc"", ""bc"", ""ef"", 1, -1, vbBinaryCompare)")
24 TestUtil
.AssertEqual(Replace("abcbcdBc", "bc", "ef", 1, -1, vbTextCompare
), "aefefdef", "Replace(""abcbcdBc"", ""bc"", ""ef"", 1, -1, vbTextCompare)")
25 TestUtil
.AssertEqual(Replace("abcbcdBc", "bc", "ef", compare:=vbTextCompare
), "aefefdef", "Replace(""abcbcdBc"", ""bc"", ""ef"", compare:=vbTextCompare)")
26 TestUtil
.AssertEqual(Replace("abcbcdBc", "bc", "ef", 3, -1, vbBinaryCompare
), "cefdBc", "Replace(""abcbcdBc"", ""bc"", ""ef"", 3, -1, vbBinaryCompare)")
27 TestUtil
.AssertEqual(Replace("abcbcdBc", "bc", "ef", 1, 2, vbBinaryCompare
), "aefefdBc", "Replace(""abcbcdBc"", ""bc"", ""ef"", 1, 2, vbBinaryCompare)")
28 TestUtil
.AssertEqual(Replace("abcbcdBc", "bc", "ef", 1, 0, vbBinaryCompare
), "abcbcdBc", "Replace(""abcbcdBc"", ""bc"", ""ef"", 1, 0, vbBinaryCompare)") ' not support in Unix
30 ' tdf#132389 - case-insensitive operation for non-ASCII characters
31 TestUtil
.AssertEqual(Replace("ABCabc", "b", "*", 1, 2, vbTextCompare
), "A*Ca*c", "Replace(""ABCabc"", ""b"", ""*"", 1, 2, vbTextCompare)")
32 TestUtil
.AssertEqual(Replace("АБВабв", "б", "*", 1, 2, vbTextCompare
), "А*Ва*в", "Replace(""АБВабв"", ""б"", ""*"", 1, 2, vbTextCompare)")
36 TestUtil
.ReportErrorHandler("verify_testReplace", Err
, Error$, Erl
)