diff options
Diffstat (limited to 'qadevOOo/tests/basic/ifc/i18n/XCharacterClassification/i18n_XCharacterClassification.xba')
-rw-r--r-- | qadevOOo/tests/basic/ifc/i18n/XCharacterClassification/i18n_XCharacterClassification.xba | 223 |
1 files changed, 223 insertions, 0 deletions
diff --git a/qadevOOo/tests/basic/ifc/i18n/XCharacterClassification/i18n_XCharacterClassification.xba b/qadevOOo/tests/basic/ifc/i18n/XCharacterClassification/i18n_XCharacterClassification.xba new file mode 100644 index 000000000000..d31b612cab49 --- /dev/null +++ b/qadevOOo/tests/basic/ifc/i18n/XCharacterClassification/i18n_XCharacterClassification.xba @@ -0,0 +1,223 @@ +<?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_XCharacterClassification" 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. +' +'************************************************************************* +'************************************************************************* + + + +' Be sure that all variables are dimensioned: +option explicit + + + +Sub RunTest() + +'************************************************************************* +' INTERFACE: +' com.sun.star.i18n.XCharacterClassification +'************************************************************************* +On Error Goto ErrHndl + Dim bOK As Boolean + Dim sType As Variant + Dim cString1 As String, cString2 As String + Dim cRes As Variant, sDir As Variant + + Const cString = "TestString1" + + Dim Locale As New com.sun.star.lang.Locale + + Locale.Language = "DE" + Locale.Country = "GERMANY" + Locale.Variant = "" + + Test.StartMethod("toUpper()") + bOK = true + cRes = oObj.toUpper(cString, 2, 3, Locale) + bOK = bOK AND Comp(cRes, "STS") + Test.MethodTested("toUpper()", bOK) + + Test.StartMethod("toLower()") + bOK = true + cRes = oObj.toLower(cString, 2, 3, Locale) + bOK = bOK AND Comp(cRes, "sts") + Test.MethodTested("toLower()", bOK) + + Test.StartMethod("toTitle()") + bOK = true + cRes = oObj.toTitle(cString, 2, 3, Locale) + bOK = bOK AND Comp(cRes, "STS") + Test.MethodTested("toTitle()", bOK) + + Test.StartMethod("getType()") + bOK = true + bOK = bOK AND oObj.getType(cString, 0) <> oObj.getType(cString, 2) + Test.MethodTested("getType()", bOK) + + Test.StartMethod("getCharacterDirection()") + bOK = true + sDir = oObj.getCharacterDirection(cString, 1) + bOK = bOK AND isNumeric(sDir) + Test.MethodTested("getCharacterDirection()", bOK) + + Test.StartMethod("getScript()") + bOK = true + bOK = bOK AND isNUmeric(oObj.getScript(cString, 0)) + Test.MethodTested("getScript()", bOK) + + Test.StartMethod("getCharacterType()") + bOK = true + sType = oObj.getCharacterType(cString, 0, Locale) + bOK = bOK AND (sType AND com.sun.star.i18n.KCharacterType.UPPER) + bOK = bOK AND NOT (sType AND com.sun.star.i18n.KCharacterType.DIGIT) + bOK = bOK AND (sType AND com.sun.star.i18n.KCharacterType.BASE_FORM) + sType = oObj.getCharacterType(cString, 1, Locale) + bOK = bOK AND (sType AND com.sun.star.i18n.KCharacterType.LOWER) + bOK = bOK AND NOT (sType AND com.sun.star.i18n.KCharacterType.DIGIT) + bOK = bOK AND (sType AND com.sun.star.i18n.KCharacterType.BASE_FORM) + sType = oObj.getCharacterType(cString, 10, Locale) + bOK = bOK AND NOT (sType AND com.sun.star.i18n.KCharacterType.UPPER) + bOK = bOK AND (sType AND com.sun.star.i18n.KCharacterType.DIGIT) + bOK = bOK AND (sType AND com.sun.star.i18n.KCharacterType.BASE_FORM) + Test.MethodTested("getCharacterType()", bOK) + + Test.StartMethod("getStringType()") + bOK = true + sType = oObj.getStringType(cString, 0, 10, Locale) + bOK = bOK AND (sType AND com.sun.star.i18n.KCharacterType.UPPER) + bOK = bOK AND (sType AND com.sun.star.i18n.KCharacterType.LOWER) + bOK = bOK AND (sType AND com.sun.star.i18n.KCharacterType.BASE_FORM) + bOK = bOK AND NOT (sType AND com.sun.star.i18n.KCharacterType.DIGIT) + sType = oObj.getStringType(cString, 0, 11, Locale) + bOK = bOK AND (sType AND com.sun.star.i18n.KCharacterType.UPPER) + bOK = bOK AND (sType AND com.sun.star.i18n.KCharacterType.LOWER) + bOK = bOK AND (sType AND com.sun.star.i18n.KCharacterType.BASE_FORM) + bOK = bOK AND (sType AND com.sun.star.i18n.KCharacterType.DIGIT) + Test.MethodTested("getStringType()", bOK) + + Test.StartMethod("parseAnyToken()") + bOK = true + + cString1 = "int _ind1 = 1234;" + Out.Log ("Parsing string: " + cString1) + Dim tTypes(10) As Integer + Dim tVals(10) As String + Dim nStartChartFlags As Variant, userDefinedCharactersStart As Variant + Dim nContCharFlags As Variant, userDefinedCharactersCont As Variant, nTokenType As Variant + + with com.sun.star.i18n.KParseType + tTypes(0) = .IDENTNAME: tVals(0) = "int" + tTypes(1) = .IDENTNAME: tVals(1) = "_ind1" + tTypes(2) = .ONE_SINGLE_CHAR: tVals(2) = "=" + tTypes(3) = .ANY_NUMBER: tVals(3) = "1234" + end with + + with com.sun.star.i18n.KParseTokens + nStartChartFlags = .ANY_ALPHA OR .IGNORE_LEADING_WS + userDefinedCharactersStart = "_" + nContCharFlags = nStartChartFlags OR .ANY_ALNUM + userDefinedCharactersCont = "" + end with + + Dim nStart As Integer, idx As Integer, nPos As Integer + Dim pRes As Variant + Dim cActStr As String + + nStart = 1 + idx = 0 + + while nStart < Len(cString1) + pRes = oObj.parseAnyToken(cString1, nStart - 1, Locale, nStartChartFlags, userDefinedCharactersStart, _ + nContCharFlags, userDefinedCharactersCont) + + Out.Log("Type is " + pRes.TokenType) + if (pRes.TokenType = 0) then + nStart = nStart + 1 + else + Out.Log("Type is as expexted - " + ((pRes.TokenType AND tTypes(idx)) > 0)) + bOK = bOK AND (pRes.TokenType AND tTypes(idx)) + cActStr = mid(cString1, (nStart + pRes.LeadingWhiteSpace), pRes.EndPos - (nStart + pRes.LeadingWhiteSpace) + 1) + Out.Log("Expected: '" + tVals(idx) + "'; actual is: '" + cActStr + "'") + bOK = bOK AND (cActStr = tVals(idx)) + nStart = pRes.EndPos + 1 + end if + idx = idx + 1 + wend + Test.MethodTested("parseAnyToken()", bOK) + + Test.StartMethod("parsePredefinedToken()") + bOK = true + + cString2 = "1a, _a1$5" + with com.sun.star.i18n.KParseType + nTokenType = .IDENTNAME + end with + with com.sun.star.i18n.KParseTokens + nStartChartFlags = .ANY_ALPHA OR .IGNORE_LEADING_WS + userDefinedCharactersStart = "_" + nContCharFlags = nStartChartFlags OR .ANY_ALNUM + userDefinedCharactersCont = "" + end with + + tVals(0) = "a" + tVals(1) = "_a1" + + nPos = 1 + idx = 0 + while nPos < Len(cString2) + pRes = oObj.parsePredefinedToken(nTokenType, cString2, nPos - 1, Locale, nStartChartFlags, userDefinedCharactersStart, _ + nContCharFlags, userDefinedCharactersCont) + + Out.Log("Type is " + pRes.TokenType) + if (pRes.TokenType = 0) then + nPos = nPos + 1 + else + bOK = bOK AND (pRes.TokenType AND tTypes(idx)) + cActStr = mid(cString2, (nPos + pRes.LeadingWhiteSpace), pRes.EndPos - (nPos + pRes.LeadingWhiteSpace) + 1) + bOK = bOK AND Comp(cActStr, tVals(idx)) + nPos = pRes.EndPos + 1 + idx = idx + 1 + end if + wend + + bOK = bOK AND true + Test.MethodTested("parsePredefinedToken()", bOK) + +Exit Sub +ErrHndl: + Test.Exception() + bOK = false + resume next +End Sub +Function Comp(cS1 As String, cS2 As String) As Boolean + Out.Log("Expected : '" + cS2 + "', actual : '" + cS1 + "'") + Comp = cS1 = cS2 +End Function +</script:module> |