diff options
Diffstat (limited to 'qadevOOo/tests/basic/ifc/i18n/XTransliteration/i18n_XTransliteration.xba')
-rw-r--r-- | qadevOOo/tests/basic/ifc/i18n/XTransliteration/i18n_XTransliteration.xba | 282 |
1 files changed, 0 insertions, 282 deletions
diff --git a/qadevOOo/tests/basic/ifc/i18n/XTransliteration/i18n_XTransliteration.xba b/qadevOOo/tests/basic/ifc/i18n/XTransliteration/i18n_XTransliteration.xba deleted file mode 100644 index faaf0bab69f4..000000000000 --- a/qadevOOo/tests/basic/ifc/i18n/XTransliteration/i18n_XTransliteration.xba +++ /dev/null @@ -1,282 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> -<script:module xmlns:script="http://openoffice.org/2000/script" script:name="i18n_XTransliteration" script:language="StarBasic"> - - -'************************************************************************* -' -' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -' -' Copyright 2000, 2010 Oracle and/or its affiliates. -' -' OpenOffice.org - a multi-platform office productivity suite -' -' This file is part of OpenOffice.org. -' -' OpenOffice.org is free software: you can redistribute it and/or modify -' it under the terms of the GNU Lesser General Public License version 3 -' only, as published by the Free Software Foundation. -' -' OpenOffice.org is distributed in the hope that it will be useful, -' but WITHOUT ANY WARRANTY; without even the implied warranty of -' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -' GNU Lesser General Public License version 3 for more details -' (a copy is included in the LICENSE file that accompanied this code). -' -' You should have received a copy of the GNU Lesser General Public License -' version 3 along with OpenOffice.org. If not, see -' <http://www.openoffice.org/license.html> -' for a copy of the LGPLv3 License. -' -'************************************************************************* -'************************************************************************* - - - -'************************************************************************* -' This Interface/Service test depends on the following GLOBAL variables, -' which must be specified in the object creation: - -' - Global oLocale As Object - -'************************************************************************* - - - - - -Sub RunTest() - -'************************************************************************* -' INTERFACE: -' com.sun.star.i18n.XTransliteration -'************************************************************************* -On Error Goto ErrHndl - Dim bOK As Boolean - Dim availableModules As Variant - Dim _string As String - Dim i As Integer - - - Test.StartMethod("getAvailableModules()") - bOK = true - availableModules = oObj.getAvailableModules(oLocale, com.sun.star.i18n.TransliterationModules.UPPERCASE_LOWERCASE) - _string = "" - for i = 0 to ubound(availableModules) - _string = _string + availableModules(i) + "; " - next i - Out.Log("AvailableModules: " + _string) - bOK = bOK AND _string <> "" - Test.MethodTested("getAvailableModules()", bOK) - - Test.StartMethod("loadModuleByImplName()") - bOK = true - oObj.loadModuleByImplName("LOWERCASE_UPPERCASE", oLocale) - Dim module_name As String - module_name = oObj.getName() - out.log("getName return: " + module_name) - bOK = module_name = "lower_to_upper(generic)" - Test.MethodTested("loadModuleByImplName()", bOK) - - Test.StartMethod("getName()") - bOK = true - Out.Log("Module name is " + oObj.getName()) - bOK = bOK AND oObj.getName() <> "" - Test.MethodTested("getName()", bOK) - - Test.StartMethod("getType()") - bOK = true - Out.Log("Type is " + oObj.getType()) - bOK = bOK AND oObj.getType() = 1 ' for UPPERCASE_LOWERCASE it is ONE_TO_ONE - Test.MethodTested("getType()", bOK) - - Test.StartMethod("loadModule()") - bOK = true - oObj.loadModule(com.sun.star.i18n.TransliterationModules.LOWERCASE_UPPERCASE, oLocale) - bOK = bOK AND oObj.getType = com.sun.star.i18n.TransliterationType.ONE_TO_ONE - Test.MethodTested("loadModule()", bOK) - - Test.StartMethod("loadModulesByImplNames()") - bOK = true - Dim Names(0) As String - Names(0) = "UPPERCASE_LOWERCASE" - oObj.loadModulesByImplNames(Names(), oLocale) - module_name = oObj.getName() - out.log("getName return: " + module_name) - bOK = module_name = "upper_to_lower(generic)" - Test.MethodTested("loadModulesByImplNames()", bOK) - - Test.StartMethod("loadModuleNew()") - bOK = true - Dim ModulesNew(0) As Variant - ModulesNew(0) = com.sun.star.i18n.TransliterationModulesNew.LOWERCASE_UPPERCASE - oObj.loadModuleNew(ModulesNew(), oLocale) - bOK = bOK AND oObj.getType = com.sun.star.i18n.TransliterationType.ONE_TO_ONE - Test.MethodTested("loadModuleNew()", bOK) - - Test.StartMethod("transliterate()") - Dim offset() As Variant - bOK = true - Out.Log("LOWERCASE_UPPERCASE-transliterate part of string 'AaBbCc'") - _string = oObj.transliterate("AaBbCc", 1, 4, offset()) - Out.Log("Result of transliteration: " + _string) - bOK = bOK AND "ABBC" = _string - bOK = bOK AND ubound(offset()) = 3 - for i = 0 to ubound(offset()) - bOK = bOK AND offset(i) = i + 1 - next i - Test.MethodTested("transliterate()", bOK) - - Test.StartMethod("equals()") - bOK = true - Dim Match1 As Variant, Match2 As Variant - bOK = bOK AND oObj.equals("This is an example string to be transliterate", 2, 20, Match1, _ - "IS IS AN EXAMPLE STR", 0, 20, Match2) - Test.MethodTested("equals()", bOK) - - Test.StartMethod("folding()") - bOK = true - _string = oObj.folding("AaBbCc", 1, 4, offset()) - Out.Log("Result of folding: " + _string) - bOK = bOK AND "ABBC" = _string - bOK = bOK AND ubound(offset()) = 3 - for i = 0 to ubound(offset()) - bOK = bOK AND offset(i) = i + 1 - next i - Test.MethodTested("folding()", bOK) - - Test.StartMethod("transliterateRange()") - Dim Result As Variant - bOK = true - oObj.loadModule(com.sun.star.i18n.TransliterationModules.IGNORE_CASE, _Locale) - Result = oObj.transliterateRange("a", "c") - for i = 0 to ubound(Result) - Out.Log(Result(i)) - next i - bOK = bOK AND ubound(Result()) = 3 AND _ - ((Result(0) = "a" AND Result(1) = "c" AND Result(2) = "A" AND Result(3) = "C" ) OR _ - (Result(0) = "A" AND Result(1) = "C" AND Result(2) = "a" AND Result(3) = "c" )) - Test.MethodTested("transliterateRange()", bOK) - - Test.StartMethod("compareString()") - oObj.loadModule(com.sun.star.i18n.TransliterationModules.LOWERCASE_UPPERCASE, _Locale) - bOK = true - bOK = bOK AND testString("", "", 0) - bOK = bOK AND testString("a", "", 1) - bOK = bOK AND testString("a", "a", 0) - bOK = bOK AND testString("A", "a", 1) - bOK = bOK AND testString("b", "a", 1) - bOK = bOK AND testString(chr(10), chr(10), 0) - bOK = bOK AND testString(chr(10), chr(9), 1) - bOK = bOK AND testString("aaa", "aaa", 0) - bOK = bOK AND testString("aaA", "aaa", 1) - bOK = bOK AND testString("aaa", "aa", 1) - bOK = bOK AND testString("ab", "aaa", 1) - bOK = bOK AND testString("aba", "aa", 1) - bOK = bOK AND testString("aaa" + chr(10) + chr(9) + "a", "aaa" + chr(10) + chr(9) + "a", 0) - bOK = bOK AND testString("aaa" + chr(9) + chr(10) + "b", "aaa" + chr(9) + chr(10) + "a", 1) - Test.MethodTested("compareString()", bOK) - - Test.StartMethod("compareSubstring()") - bOK = true - ' substrings below must be equal - bOK = bOK AND testSubstring("", 0, 0, "", 0, 0, 0) - bOK = bOK AND testSubstring("aa", 1, 0, "", 0, 0, 0) - bOK = bOK AND testSubstring("aa", 1, 0, "aa", 2, 0, 0) - bOK = bOK AND testSubstring("a", 0, 1, "a", 0, 1, 0) - bOK = bOK AND testSubstring("ab", 0, 2, "ab", 0, 2, 0) - bOK = bOK AND testSubstring("abc", 1, 2, "abc", 1, 2, 0) - bOK = bOK AND testSubstring("abcdef", 0, 3, "123abc", 3, 3, 0) - bOK = bOK AND testSubstring("abcdef", 1, 1, "123abc", 4, 1, 0) - - ' substrings below must NOT be equal - bOK = bOK AND testSubstring("a", 0, 1, "a", 0, 0, 1) - bOK = bOK AND testSubstring("aaa", 1, 1, "", 0, 0, 1) - bOK = bOK AND testSubstring("bbb", 2, 1, "aaa", 2, 1, 1) - bOK = bOK AND testSubstring("abc", 0, 3, "abc", 0, 2, 1) - bOK = bOK AND testSubstring("bbc", 1, 2, "bbc", 0, 2, 1) - - Test.MethodTested("compareSubstring()", bOK) -Exit Sub -ErrHndl: - Test.Exception() - bOK = false - resume next -End Sub - -Function testString(str1 As String, str2 As String, expRes As Integer) As Boolean - if expRes = 0 then - testString = testStringCommon(str1, str2, expRes, false) - else - testString = testStringCommon(str1, str2, expRes, true) - end if -End Function - -Function testStringCommon(str1 As String, str2 As String, expRes As Integer, testReverse As Boolean) As Boolean - Dim res As Integer - - testStringCommon = true - - res = -666 - - res = oObj.compareString(str1, str2) - - if res = expRes then - Out.Log("Comparing of '" + str1 + "' and '" + str2 + "' OK" ) - else - Out.Log("Comparing of '" + str1 + "' and '" + str2 + _ - "' FAILED; return: " + res + ", expected: " + expRes) - testStringCommon = false - end if - - if NOT testReverse then - Exit Function - end if - - res = -666 - - res = oObj.compareString(str2, str1) - - if res = -expRes then - Out.Log("Comparing of '" + str2 + "' and '" + str1 + "' OK" ) - else - Out.Log("Comparing of '" + str2 + "' and '" + str1 + _ - "' FAILED; return: " + res + ", expected: " + -expRes) - testStringCommon = false - end if -End Function - -Function testSubstring(str1 As String, p1 As Integer, len1 As Integer, _ - str2 As String, p2 As Integer, len2 As Integer, expRes As Integer) As Boolean - - testSubstring = true - - Dim res As Integer - res = -666 - - res = oObj.compareSubstring(str1, p1, len1, str2, p2, len2) - - if res <> expRes then - Out.Log("Comparing FAILED; return: " + res + ", expected: " + expRes + " ") - testSubstring = false - else - Out.Log("Comparing OK : ") - end if - Out.Log("('" + str1 + "', " + p1 + ", " + len1 + ", '" + _ - str2 + "', " + p2 + ", " + len2 + ")") - - res = -666 - - res = oObj.compareSubstring(str2, p2, len2, str1, p1, len1) - - if res <> -expRes then - Out.Log("Comparing FAILED; return: " + res + ", expected: " + _ - -expRes + " ") - testSubstring = false - else - Out.Log("Comparing OK :") - end if - Out.Log("('" + str2 + "', " + p2 + ", " + len2 + ", '" + _ - str1 + "', " + p1 + ", " + len1 + ")") -End Function -</script:module> |