X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/b75a7d8f3b4adbae880cab104ce2c6a50eee4db2..HEAD:/icuSources/test/intltest/jamotest.cpp diff --git a/icuSources/test/intltest/jamotest.cpp b/icuSources/test/intltest/jamotest.cpp index bfae910e..63925ab3 100644 --- a/icuSources/test/intltest/jamotest.cpp +++ b/icuSources/test/intltest/jamotest.cpp @@ -1,6 +1,8 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html /******************************************************************** * COPYRIGHT: - * Copyright (c) 1997-2003, International Business Machines Corporation and + * Copyright (c) 1997-2016, International Business Machines Corporation and * others. All Rights Reserved. ******************************************************************** ************************************************************************ @@ -16,27 +18,28 @@ #include "jamotest.h" #include "unicode/utypes.h" #include "unicode/translit.h" -#include "rbt.h" +#include "cmemory.h" #include "cpdtrans.h" // SEP is the disambiguation separator used by Latin-Jamo and Jamo-Latin -#define SEP "'" +#define SEP "-" JamoTest::JamoTest() { + UParseError parseError; UErrorCode status = U_ZERO_ERROR; - NAME_JAMO = new RuleBasedTransliterator("Name-Jamo", - JAMO_NAMES_RULES, - UTRANS_FORWARD, status); + NAME_JAMO = Transliterator::createFromRules("Name-Jamo", + UnicodeString(JAMO_NAMES_RULES, -1, US_INV), + UTRANS_FORWARD, parseError, status); if (U_FAILURE(status)) { delete NAME_JAMO; NAME_JAMO = NULL; } status = U_ZERO_ERROR; - JAMO_NAME = new RuleBasedTransliterator("Jamo-Name", - JAMO_NAMES_RULES, - UTRANS_REVERSE, status); + JAMO_NAME = Transliterator::createFromRules("Jamo-Name", + UnicodeString(JAMO_NAMES_RULES, -1, US_INV), + UTRANS_REVERSE, parseError, status); if (U_FAILURE(status)) { delete JAMO_NAME; JAMO_NAME = NULL; @@ -67,7 +70,7 @@ JamoTest::TestJamo() { Transliterator* latinJamo = Transliterator::createInstance("Latin-Jamo", UTRANS_FORWARD, parseError, status); if (latinJamo == 0 || U_FAILURE(status)) { - errln("FAIL: createInstance() returned 0"); + dataerrln("FAIL: createInstance() returned 0 - %s", u_errorName(status)); return; } @@ -88,28 +91,47 @@ JamoTest::TestJamo() { // Column 3 is expected value of L2. If the expected // value of L2 is L1, then L2 is NULL. + + // add tests for the update to fix problems where it didn't follow the standard + // see also http://www.unicode.org/cldr/data/charts/transforms/Latin-Hangul.html + "gach", "(Gi)(A)(Cf)", NULL, + "geumhui", "(Gi)(EU)(Mf)(Hi)(YI)", NULL, + "choe", "(Ci)(OE)", NULL, + "wo", "(IEUNG)(WEO)", NULL, + "Wonpil", "(IEUNG)(WEO)(Nf)(Pi)(I)(L)", "wonpil", + "GIPPEUM", "(Gi)(I)(BB)(EU)(Mf)", "gippeum", + "EUTTEUM", "(IEUNG)(EU)(DD)(EU)(Mf)", "eutteum", + "KKOTNAE", "(GGi)(O)(Tf)(Ni)(AE)", "kkotnae", + "gaga", "(Gi)(A)(Gi)(A)", NULL, + "gag-a", "(Gi)(A)(Gf)(IEUNG)(A)", NULL, + "gak-ka", "(Gi)(A)(Kf)(Ki)(A)", NULL, + "gakka", "(Gi)(A)(GGi)(A)", NULL, + "gakk-a", "(Gi)(A)(GGf)(IEUNG)(A)", NULL, + "gakkka", "(Gi)(A)(GGf)(Ki)(A)", NULL, + "gak-kka", "(Gi)(A)(Kf)(GGi)(A)", NULL, + "bab", "(Bi)(A)(Bf)", NULL, - "babb", "(Bi)(A)(Bf)(Bi)(EU)", "bab" SEP "beu", - "babbba", "(Bi)(A)(Bf)(BB)(A)", NULL, - "bagg", "(Bi)(A)(GGf)", NULL, - "baggga", "(Bi)(A)(GGf)(Gi)(A)", NULL, - "bag" SEP "gga", "(Bi)(A)(Gf)(GGi)(A)", NULL, + "babb", "(Bi)(A)(Bf)(Bi)(EU)", "babbeu", + "babbba", "(Bi)(A)(Bf)(Bi)(EU)(Bi)(A)", "babbeuba", + "bagg", "(Bi)(A)(Gf)(Gi)(EU)", "baggeu", + "baggga", "(Bi)(A)(Gf)(Gi)(EU)(Gi)(A)", "baggeuga", + //"bag" SEP "gga", "(Bi)(A)(Gf)" SEP "(Gi)(EU)(Gi)(A)", "bag" SEP "geuga", "kabsa", "(Ki)(A)(Bf)(Si)(A)", NULL, "kabska", "(Ki)(A)(BS)(Ki)(A)", NULL, "gabsbka", "(Gi)(A)(BS)(Bi)(EU)(Ki)(A)", "gabsbeuka", // not (Kf) - "gga", "(GGi)(A)", NULL, + "gga", "(Gi)(EU)(Gi)(A)", "geuga", "bsa", "(Bi)(EU)(Si)(A)", "beusa", - "agg", "(IEUNG)(A)(GGf)", NULL, - "agga", "(IEUNG)(A)(GGi)(A)", NULL, - "la", "(R)(A)", "ra", + "agg", "(IEUNG)(A)(Gf)(Gi)(EU)", "aggeu", + "agga", "(IEUNG)(A)(Gf)(Gi)(A)", NULL, + "la", "(R)(A)", NULL, "bs", "(Bi)(EU)(Sf)", "beus", - "kalgga", "(Ki)(A)(L)(GGi)(A)", NULL, + "kalgga", "(Ki)(A)(L)(Gi)(EU)(Gi)(A)", "kalgeuga", // 'r' in a final position is treated like 'l' "karka", "(Ki)(A)(L)(Ki)(A)", "kalka", }; - enum { CASE_length = sizeof(CASE) / sizeof(CASE[0]) }; + enum { CASE_length = UPRV_LENGTHOF(CASE) }; int32_t i; for (i=0; icreateInverse(status); @@ -376,7 +403,7 @@ JamoTest::TestRealText() { int32_t i; for (i=0; i < WHAT_IS_UNICODE_length; ++i) { ++total; - UnicodeString hangul = WHAT_IS_UNICODE[i]; + UnicodeString hangul = UnicodeString(WHAT_IS_UNICODE[i], -1, US_INV); hangul = hangul.unescape(); // Parse backslash-u escapes UnicodeString hangulX = hangul; rt.transliterate(hangulX);