LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / basic / qa / vba_tests / strconv.vb
blobb0295df428b2dcb78407a56cd561b0dc62e808e2
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_testStrConv
15 doUnitTest = TestUtil.GetResult()
16 End Function
18 Sub verify_testStrConv()
19 On Error GoTo errorHandler
21 TestUtil.AssertEqual(StrConv("abc EFG hij", vbUpperCase), "ABC EFG HIJ", "StrConv(""abc EFG hij"", vbUpperCase)")
22 TestUtil.AssertEqual(StrConv("abc EFG hij", vbLowerCase), "abc efg hij", "StrConv(""abc EFG hij"", vbLowerCase)")
23 TestUtil.AssertEqual(StrConv("abc EFG hij", vbProperCase), "Abc Efg Hij", "StrConv(""abc EFG hij"", vbProperCase)")
25 ' Converts narrow (single-byte) characters in string to wide
26 TestUtil.AssertEqual(StrConv("ABCDEVB¥ì¥¹¥­¥å©", vbWide), "ABCDEVB¥ì¥¹¥­¥å©", "StrConv(""ABCDEVB¥ì¥¹¥­¥å©"", vbWide)")
28 ' Converts wide (double-byte) characters in string to narrow (single-byte) characters
29 TestUtil.AssertEqual(StrConv("ABCD@$%23'?EG", vbNarrow), "ABCD@$%23'?EG", "StrConv(""ABCD@$%23'?EG"", vbNarrow)")
31 ' Converts Hiragana characters in string to Katakana characters
32 TestUtil.AssertEqual(StrConv("かたかな", vbKatakana), "カタカナ", "StrConv(""かたかな"", vbKatakana)")
34 ' Converts Katakana characters in string to Hiragana characters
35 TestUtil.AssertEqual(StrConv("カタカナ", vbHiragana), "かたかな", "StrConv(""カタカナ"", vbHiragana)")
37 ' Assumes CP-1252 encoding associated with en-US locale used in unit tests.
38 Dim x() As Byte
39 x = StrConv("ÉϺ£ÊÐABC", vbFromUnicode)
40 TestUtil.AssertEqual(UBound(x), 8, "UBound(x)")
41 TestUtil.AssertEqual(x(0), 201, "x(0)")
42 TestUtil.AssertEqual(x(1), 207, "x(1)")
43 TestUtil.AssertEqual(x(2), 186, "x(2)")
44 TestUtil.AssertEqual(x(3), 163, "x(3)")
45 TestUtil.AssertEqual(x(4), 202, "x(4)")
46 TestUtil.AssertEqual(x(5), 208, "x(5)")
47 TestUtil.AssertEqual(x(6), 65, "x(6)")
48 TestUtil.AssertEqual(x(7), 66, "x(7)")
49 TestUtil.AssertEqual(x(8), 67, "x(8)")
50 TestUtil.AssertEqual(StrConv(x, vbUnicode), "ÉϺ£ÊÐABC", "StrConv(x, vbUnicode)")
52 Exit Sub
53 errorHandler:
54 TestUtil.ReportErrorHandler("verify_testStrConv", Err, Error$, Erl)
55 End Sub