Debian Codegraph @

basic/qa/basic_coverage/test_transliteration.bas

raw
1 ' This file is part of the LibreOffice project.
2 '
3 ' This Source Code Form is subject to the terms of the Mozilla Public
4 ' License, v. 2.0. If a copy of the MPL was not distributed with this
5 ' file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 '
7
8 Option Explicit
9
10 Function doUnitTest() As String
11 TestUtil.TestInit
12 verify_testTransliteration
13 doUnitTest = TestUtil.GetResult()
14 End Function
15
16 Sub verify_testTransliteration
17 On Error GoTo errorHandler
18
19 Dim oTr As Object, s$, oLoc as new com.sun.star.lang.Locale
20
21 With oLoc
22 .Country="US"
23 .Language="en"
24 .Variant=""
25 End With
26
27 s="AB cd. eF. "
28 oTr = CreateUnoService("com.sun.star.i18n.Transliteration")
29
30 oTr.LoadModuleByImplName("LOWERCASE_UPPERCASE", oLoc)
31 TestUtil.AssertEqual(oTr.transliterateString2String(s, 0, Len(s)), "AB CD. EF. ", "LOWERCASE_UPPERCASE")
32
33 oTr.LoadModuleByImplName("UPPERCASE_LOWERCASE", oLoc)
34 TestUtil.AssertEqual(oTr.transliterateString2String(s, 0, Len(s)), "ab cd. ef. ", "UPPERCASE_LOWERCASE")
35
36 oTr.LoadModuleByImplName("TOGGLE_CASE", oLoc)
37 TestUtil.AssertEqual(oTr.transliterateString2String(s, 0, Len(s)), "ab CD. Ef. ", "TOGGLE_CASE")
38
39 oTr.LoadModuleByImplName("IGNORE_CASE", oLoc)
40 TestUtil.AssertEqual(oTr.transliterateString2String(s, 0, Len(s)), "ab cd. ef. ", "IGNORE_CASE")
41
42 ' tdf#152520: Without the fix in place, this test would have crashed here
43 oTr.LoadModuleByImplName("TITLE_CASE", oLoc)
44 TestUtil.AssertEqual(oTr.transliterateString2String(s, 0, Len(s)), "Ab cd. ef. ", "TITLE_CASE")
45
46 oTr.LoadModuleByImplName("SENTENCE_CASE", oLoc)
47 TestUtil.AssertEqual(oTr.transliterateString2String(s, 0, Len(s)), "Ab cd. ef. ", "SENTENCE_CASE")
48
49 Exit Sub
50 errorHandler:
51 TestUtil.ReportErrorHandler("verify_testTransliteration", Err, Error$, Erl)
52 End Sub