/******************************************************************** * COPYRIGHT: * Copyright (c) 1997-2008, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ #include "unicode/ustring.h" #include "unicode/uchar.h" #include "unicode/uniset.h" #include "unicode/putil.h" #include "cstring.h" #include "uparse.h" #include "ucdtest.h" #define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof(array[0])) UnicodeTest::UnicodeTest() { } UnicodeTest::~UnicodeTest() { } void UnicodeTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ ) { if (exec) logln("TestSuite UnicodeTest: "); switch (index) { case 0: name = "TestAdditionalProperties"; if(exec) TestAdditionalProperties(); break; case 1: name = "TestBinaryValues"; if(exec) TestBinaryValues(); break; default: name = ""; break; //needed to end loop } } //==================================================== // private data used by the tests //==================================================== // test DerivedCoreProperties.txt ------------------------------------------- // copied from genprops.c static int32_t getTokenIndex(const char *const tokens[], int32_t countTokens, const char *s) { const char *t, *z; int32_t i, j; s=u_skipWhitespace(s); for(i=0; ierrln("UnicodeTest: syntax error in DerivedCoreProperties.txt field 0 at %s\n", fields[0][0]); return; } /* parse derived binary property name, ignore unknown names */ i=getTokenIndex(derivedCorePropsNames, LENGTHOF(derivedCorePropsNames), fields[1][0]); if(i<0) { me->errln("UnicodeTest warning: unknown property name '%s' in \n", fields[1][0]); return; } me->derivedCoreProps[i].add(start, end); } void UnicodeTest::TestAdditionalProperties() { // test DerivedCoreProperties.txt if(LENGTHOF(derivedCoreProps) 100) { errln("Too many errors, moving to the next test"); break; } } } } } noErrors = 0; // invert all properties for(i=0; i 100) { errln("Too many errors, moving to the next test"); break; } } } } } } void UnicodeTest::TestBinaryValues() { /* * Unicode 5.1 explicitly defines binary property value aliases. * Verify that they are all recognized. */ UErrorCode errorCode=U_ZERO_ERROR; UnicodeSet alpha(UNICODE_STRING_SIMPLE("[:Alphabetic:]"), errorCode); if(U_FAILURE(errorCode)) { errln("UnicodeSet([:Alphabetic:]) failed - %s\n", u_errorName(errorCode)); return; } static const char *const falseValues[]={ "N", "No", "F", "False" }; static const char *const trueValues[]={ "Y", "Yes", "T", "True" }; int32_t i; for(i=0; i