ICU-410 test unescape code

X-SVN-Rev: 2293
This commit is contained in:
Alan Liu 2000-08-16 20:25:29 +00:00
parent 52826c7008
commit 63880d0371
2 changed files with 26 additions and 0 deletions

View File

@ -36,6 +36,7 @@ void UnicodeStringTest::runIndexedTest( int32_t index, UBool exec, const char* &
case 11: name = "TestReverse"; if (exec) TestReverse(); break;
case 12: name = "TestMiscellaneous"; if (exec) TestMiscellaneous(); break;
case 13: name = "TestStackAllocation"; if (exec) TestStackAllocation(); break;
case 14: name = "TestUnescape"; if (exec) TestUnescape(); break;
default: name = ""; break; //needed to end loop
}
@ -785,3 +786,24 @@ UnicodeStringTest::TestStackAllocation()
errln("The UnicodeString capacity constructor does not work with a 0x10ff2a filler");
}
}
/**
* Test the unescape() function.
*/
void UnicodeStringTest::TestUnescape(void) {
UnicodeString IN("abc\\u4567 \\n\\r \\U00101234xyz");
UnicodeString OUT("abc");
OUT.append((UChar)0x4567);
OUT.append(" ");
OUT.append((UChar)0xA);
OUT.append((UChar)0xD);
OUT.append(" ");
OUT.append((UChar32)0x00101234);
OUT.append("xyz");
UnicodeString result = IN.unescape();
if (result != OUT) {
errln("FAIL: " + prettify(IN) + ".unescape() -> " +
prettify(result) + ", expected " +
prettify(OUT));
}
}

View File

@ -68,5 +68,9 @@ public:
* Test the functionality of allocating UnicodeStrings on the stack
**/
void TestStackAllocation(void);
/**
* Test the unescape() function.
*/
void TestUnescape(void);
};