LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / basic / qa / vba_tests / instrrev.vb
blob7d047fc74aa6bf1cd10e2917ff856f19919a6704
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/.
9 Option VBASupport 1
10 Option Explicit
12 Function doUnitTest() As String
13 TestUtil.TestInit
14 verify_testInStrRev
15 doUnitTest = TestUtil.GetResult()
16 End Function
18 Sub verify_testInStrRev()
19 On Error GoTo errorHandler
21 TestUtil.AssertEqual(InStrRev("somemoretext", "more", -1), 5, "InStrRev(""somemoretext"", ""more"", -1)")
22 TestUtil.AssertEqual(InStrRev("somemoretext", "more"), 5, "InStrRev(""somemoretext"", ""more"")")
23 TestUtil.AssertEqual(InStrRev("somemoretext", "somemoretext"), 1, "InStrRev(""somemoretext"", ""somemoretext"")")
24 TestUtil.AssertEqual(InStrRev("somemoretext", "nothing"), 0, "InStrRev(""somemoretext"", ""nothing"")")
26 Dim SearchString, SearchChar
27 SearchString = "XXpXXpXXPXXP" ' String to search in.
28 SearchChar = "P" ' Search for "P".
29 TestUtil.AssertEqual(InStrRev(SearchString, SearchChar, 4, 1), 3, "InStrRev(SearchString, SearchChar, 4, 1)")
30 TestUtil.AssertEqual(InStrRev(SearchString, SearchChar, -1, 0), 12, "InStrRev(SearchString, SearchChar, -1, 0)")
31 TestUtil.AssertEqual(InStrRev(SearchString, "W", 1), 0, "InStrRev(SearchString, ""W"", 1)")
33 ' tdf#143332 - case-insensitive operation for non-ASCII characters
34 TestUtil.AssertEqual(InStrRev("α", "Α", -1, 1), 1, "InStrRev(""α"", ""Α"", -1, 1)")
35 TestUtil.AssertEqual(InStrRev("abc", "d", -1, 1), 0, "InStrRev(""abc"", ""d"", -1, 1)")
36 ' tdf#143332 - German Eszett is uppercased to a two-character 'SS'.
37 ' This test should fail after tdf#110003 has been fixed.
38 TestUtil.AssertEqual(InStrRev("Straße", "s", -1, 1), 5, "InStrRev(""Straße"", ""s"", -1, 1)")
40 Exit Sub
41 errorHandler:
42 TestUtil.ReportErrorHandler("verify_testInStrRev", Err, Error$, Erl)
43 End Sub