ICU-6281 Fix Fullwidth_Halfwidth data, add TestHalfwidthFullwidth()

X-SVN-Rev: 24145
This commit is contained in:
Peter Edberg 2008-06-11 01:31:45 +00:00
parent 90da026c87
commit 2eb61f142a
3 changed files with 53 additions and 3 deletions

View File

@ -253,9 +253,9 @@
¥<>'¥'; # from FULLWIDTH YEN SIGN
₩<>₩; # from FULLWIDTH WON SIGN
│<>; # to HALFWIDTH FORMS LIGHT VERTICAL
'\u2190'<>'←'; # to HALFWIDTH LEFTWARDS ARROW
''<>'←'; # to HALFWIDTH LEFTWARDS ARROW
↑<>↑; # to HALFWIDTH UPWARDS ARROW
'\u2192'<>'→'; # to HALFWIDTH RIGHTWARDS ARROW
''<>'→'; # to HALFWIDTH RIGHTWARDS ARROW
↓<>↓; # to HALFWIDTH DOWNWARDS ARROW
■<>■; # to HALFWIDTH BLACK SQUARE
○<>○; # to HALFWIDTH WHITE CIRCLE

View File

@ -188,6 +188,7 @@ TransliteratorTest::runIndexedTest(int32_t index, UBool exec,
TESTCASE(79,TestBeginEndToRules);
TESTCASE(80,TestRegisterAlias);
TESTCASE(81,TestRuleStripping);
TESTCASE(82,TestHalfwidthFullwidth);
default: name = ""; break;
}
}
@ -4466,6 +4467,53 @@ void TransliteratorTest::TestRuleStripping() {
}
}
/**
* Test the Halfwidth-Fullwidth transliterator (ticket 6281).
*/
void TransliteratorTest::TestHalfwidthFullwidth(void) {
UParseError parseError;
UErrorCode status = U_ZERO_ERROR;
Transliterator* hf = Transliterator::createInstance("Halfwidth-Fullwidth", UTRANS_FORWARD, parseError, status);
Transliterator* fh = Transliterator::createInstance("Fullwidth-Halfwidth", UTRANS_FORWARD, parseError, status);
if (hf == 0 || fh == 0) {
errln("FAIL: createInstance failed");
delete hf;
delete fh;
return;
}
// Array of 2n items
// Each item is
// "hf"|"fh"|"both",
// <Halfwidth>,
// <Fullwidth>
const char* DATA[] = {
"both",
"\\uFFE9\\uFFEA\\uFFEB\\uFFEC\\u0061\\uFF71\\u00AF\\u0020",
"\\u2190\\u2191\\u2192\\u2193\\uFF41\\u30A2\\uFFE3\\u3000",
};
int32_t DATA_length = (int32_t)(sizeof(DATA) / sizeof(DATA[0]));
for (int32_t i=0; i<DATA_length; i+=3) {
UnicodeString h = CharsToUnicodeString(DATA[i+1]);
UnicodeString f = CharsToUnicodeString(DATA[i+2]);
switch (*DATA[i]) {
case 0x68: //'h': // Halfwidth-Fullwidth only
expect(*hf, h, f);
break;
case 0x66: //'f': // Fullwidth-Halfwidth only
expect(*fh, f, h);
break;
case 0x62: //'b': // both directions
expect(*hf, h, f);
expect(*fh, f, h);
break;
}
}
delete hf;
delete fh;
}
//======================================================================
// Support methods
//======================================================================

View File

@ -1,6 +1,6 @@
/*
**********************************************************************
* Copyright (C) 1999-2007, International Business Machines
* Copyright (C) 1999-2008, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
* Date Name Description
@ -346,6 +346,8 @@ private:
void TestRuleStripping(void);
void TestHalfwidthFullwidth(void);
/**
* Tests the multiple-pass syntax
*/