From a782748606e6c55c1dfbbdb085624c91184a3207 Mon Sep 17 00:00:00 2001 From: Norbert Runge Date: Fri, 8 Sep 2017 16:46:18 +0000 Subject: [PATCH] ICU-12603 Annotates ICU4J unit test classes which use JUnit with @RunWith(JUnit4.class). X-SVN-Rev: 40375 --- .../ibm/icu/dev/test/charset/TestCharset.java | 1625 +++++++++-------- .../icu/dev/test/charset/TestSelection.java | 31 +- .../test/collator/AlphabeticIndexTest.java | 3 + .../dev/test/collator/CollationAPITest.java | 3 + .../test/collator/CollationChineseTest.java | 21 +- .../collator/CollationCreationMethodTest.java | 25 +- .../test/collator/CollationCurrencyTest.java | 33 +- .../dev/test/collator/CollationDummyTest.java | 185 +- .../test/collator/CollationEnglishTest.java | 75 +- .../test/collator/CollationFinnishTest.java | 41 +- .../test/collator/CollationFrenchTest.java | 51 +- .../collator/CollationFrozenMonkeyTest.java | 91 +- .../test/collator/CollationGermanTest.java | 41 +- .../test/collator/CollationIteratorTest.java | 179 +- .../dev/test/collator/CollationKanaTest.java | 51 +- .../dev/test/collator/CollationMiscTest.java | 3 + .../test/collator/CollationMonkeyTest.java | 77 +- .../collator/CollationRegressionTest.java | 251 +-- .../test/collator/CollationServiceTest.java | 72 +- .../test/collator/CollationSpanishTest.java | 39 +- .../icu/dev/test/collator/CollationTest.java | 67 +- .../dev/test/collator/CollationThaiTest.java | 82 +- .../test/collator/CollationThreadTest.java | 5 + .../test/collator/CollationTurkishTest.java | 39 +- .../dev/test/collator/G7CollationTest.java | 89 +- .../collator/LotusCollationKoreanTest.java | 37 +- .../dev/test/collator/UCAConformanceTest.java | 3 + .../format/GlobalizationPreferencesTest.java | 81 +- .../test/format/RbnfLenientScannerTest.java | 5 +- .../ibm/icu/dev/test/search/SearchTest.java | 3 + .../util/ICUResourceBundleCollationTest.java | 6 +- .../test/util/LocaleAliasCollationTest.java | 3 + .../dev/test/util/ULocaleCollationTest.java | 182 +- .../dev/test/bidi/BiDiConformanceTest.java | 3 + .../icu/dev/test/bidi/TestBidiTransform.java | 3 + .../dev/test/bigdec/DiagBigDecimalTest.java | 3 + .../ibm/icu/dev/test/calendar/AstroTest.java | 7 +- .../test/calendar/CalendarRegressionTest.java | 3 + .../dev/test/calendar/CalendarTestFmwk.java | 24 +- .../icu/dev/test/calendar/ChineseTest.java | 97 +- .../dev/test/calendar/ChineseTestCase.java | 7 +- .../dev/test/calendar/CompatibilityTest.java | 22 +- .../ibm/icu/dev/test/calendar/CopticTest.java | 85 +- .../ibm/icu/dev/test/calendar/DangiTest.java | 21 +- .../icu/dev/test/calendar/EthiopicTest.java | 61 +- .../ibm/icu/dev/test/calendar/HebrewTest.java | 61 +- .../icu/dev/test/calendar/HolidayTest.java | 23 +- .../dev/test/calendar/IBMCalendarTest.java | 3 + .../ibm/icu/dev/test/calendar/IndianTest.java | 61 +- .../icu/dev/test/calendar/IslamicTest.java | 101 +- .../icu/dev/test/calendar/JapaneseTest.java | 37 +- .../icu/dev/test/calendar/PersianTest.java | 13 +- .../test/charsetdet/TestCharsetDetector.java | 254 +-- .../test/compression/DecompressionTest.java | 37 +- .../dev/test/compression/ExhaustiveTest.java | 147 +- .../dev/test/duration/DataReadWriteTest.java | 17 +- .../dev/test/duration/ICUDurationTest.java | 27 +- .../dev/test/duration/LanguageTestFmwk.java | 29 +- .../duration/PeriodBuilderFactoryTest.java | 11 +- .../ibm/icu/dev/test/duration/PeriodTest.java | 3 + .../icu/dev/test/duration/RegressionTest.java | 17 +- ...ceBasedPeriodFormatterDataServiceTest.java | 3 + .../dev/test/format/BigNumberFormatTest.java | 3 + .../test/format/CompactDecimalFormatTest.java | 3 + .../dev/test/format/DateFormatMiscTests.java | 40 +- .../test/format/DateFormatRegressionTest.java | 321 ++-- .../format/DateFormatRegressionTestJ.java | 102 +- .../test/format/DateFormatRoundTripTest.java | 6 +- .../icu/dev/test/format/DateFormatTest.java | 16 +- .../test/format/DateIntervalFormatTest.java | 738 ++++---- .../test/format/DateTimeGeneratorTest.java | 3 + .../dev/test/format/IntlTestDateFormat.java | 14 +- .../test/format/IntlTestDateFormatAPI.java | 8 +- .../test/format/IntlTestDateFormatAPIC.java | 26 +- .../format/IntlTestDateFormatSymbols.java | 26 +- .../test/format/IntlTestDecimalFormatAPI.java | 6 +- .../format/IntlTestDecimalFormatAPIC.java | 6 +- .../format/IntlTestDecimalFormatSymbols.java | 6 +- .../format/IntlTestDecimalFormatSymbolsC.java | 6 +- .../dev/test/format/IntlTestNumberFormat.java | 5 +- .../test/format/IntlTestNumberFormatAPI.java | 24 +- .../format/IntlTestSimpleDateFormatAPI.java | 14 +- .../dev/test/format/ListFormatterTest.java | 15 +- .../icu/dev/test/format/MeasureUnitTest.java | 3 + .../test/format/MeasureUnitThreadTest.java | 3 + .../test/format/MessagePatternUtilTest.java | 6 +- .../test/format/MessageRegressionTest.java | 26 +- .../format/NumberFormatRegistrationTest.java | 7 +- .../format/NumberFormatRegressionTest.java | 8 +- .../format/NumberFormatRoundTripTest.java | 118 +- .../format/NumberFormatSpecificationTest.java | 37 +- .../icu/dev/test/format/NumberFormatTest.java | 3 + .../test/format/NumberRegressionTests.java | 3 + .../icu/dev/test/format/PluralFormatTest.java | 3 + .../dev/test/format/PluralFormatUnitTest.java | 5 +- .../icu/dev/test/format/PluralRangesTest.java | 5 +- .../icu/dev/test/format/PluralRulesTest.java | 11 +- .../icu/dev/test/format/RBNFParseTest.java | 3 + .../dev/test/format/RbnfRoundTripTest.java | 3 + .../com/ibm/icu/dev/test/format/RbnfTest.java | 3 + .../format/RelativeDateTimeFormatterTest.java | 3 + .../format/ScientificNumberFormatterTest.java | 15 +- .../dev/test/format/SelectFormatAPITest.java | 29 +- .../dev/test/format/SelectFormatUnitTest.java | 19 +- .../dev/test/format/TestMessageFormat.java | 6 +- .../ibm/icu/dev/test/format/TimeUnitTest.java | 65 +- .../dev/test/format/TimeZoneFormatTest.java | 5 +- .../test/impl/CSCharacterIteratorTest.java | 3 + .../com/ibm/icu/dev/test/impl/CacheTest.java | 3 + .../test/iterator/TestUCharacterIterator.java | 127 +- .../ibm/icu/dev/test/lang/TestUScript.java | 3 + .../ibm/icu/dev/test/lang/TestUScriptRun.java | 109 +- .../icu/dev/test/lang/UCharacterCaseTest.java | 3 + .../dev/test/lang/UCharacterCategoryTest.java | 13 +- .../test/lang/UCharacterDirectionTest.java | 15 +- .../test/lang/UCharacterSurrogateTest.java | 35 +- .../ibm/icu/dev/test/lang/UCharacterTest.java | 3 + .../dev/test/lang/UCharacterThreadTest.java | 10 +- .../dev/test/lang/UPropertyAliasesTest.java | 15 +- .../com/ibm/icu/dev/test/lang/UTF16Test.java | 7 +- .../test/lang/UnicodeSetStringSpanTest.java | 7 +- .../ibm/icu/dev/test/lang/UnicodeSetTest.java | 3 + .../icu/dev/test/normalizer/BasicTest.java | 3 + .../dev/test/normalizer/ConformanceTest.java | 3 + .../normalizer/NormalizationMonkeyTest.java | 11 +- .../normalizer/NormalizerRegressionTests.java | 3 + .../normalizer/TestCanonicalIterator.java | 45 +- .../TestDeprecatedNormalizerAPI.java | 11 +- .../icu/dev/test/normalizer/UTS46Test.java | 3 + .../UnicodeNormalizerConformanceTest.java | 37 +- .../dev/test/number/FormatQuantityTest.java | 3 + .../test/rbbi/AbstractBreakIteratorTests.java | 3 + .../dev/test/rbbi/BreakIteratorRegTest.java | 9 +- .../icu/dev/test/rbbi/BreakIteratorTest.java | 3 + .../ibm/icu/dev/test/rbbi/RBBIAPITest.java | 5 +- .../ibm/icu/dev/test/rbbi/RBBIMonkeyTest.java | 3 + .../com/ibm/icu/dev/test/rbbi/RBBITest.java | 3 + .../icu/dev/test/rbbi/RBBITestExtended.java | 3 + .../ibm/icu/dev/test/rbbi/RBBITestMonkey.java | 3 + .../test/shaping/ArabicShapingRegTest.java | 3 + .../test/stringprep/IDNAConformanceTest.java | 33 +- .../ibm/icu/dev/test/stringprep/TestIDNA.java | 3 + .../icu/dev/test/stringprep/TestIDNARef.java | 157 +- .../dev/test/stringprep/TestStringPrep.java | 49 +- .../stringprep/TestStringPrepProfiles.java | 19 +- .../icu/dev/test/text/SpoofCheckerTest.java | 3 + .../dev/test/timescale/TimeScaleAPITest.java | 89 +- .../dev/test/timescale/TimeScaleDataTest.java | 37 +- .../test/timescale/TimeScaleMonkeyTest.java | 39 +- .../dev/test/timezone/TimeZoneAliasTest.java | 76 +- .../test/timezone/TimeZoneBoundaryTest.java | 23 +- .../timezone/TimeZoneOffsetLocalTest.java | 5 +- .../test/timezone/TimeZoneRegressionTest.java | 26 +- .../dev/test/timezone/TimeZoneRuleTest.java | 53 +- .../icu/dev/test/timezone/TimeZoneTest.java | 52 +- .../ibm/icu/dev/test/util/BytesTrieTest.java | 3 + .../ibm/icu/dev/test/util/CharsTrieTest.java | 3 + .../icu/dev/test/util/CompactArrayTest.java | 15 +- .../ibm/icu/dev/test/util/CurrencyTest.java | 3 + .../icu/dev/test/util/DebugUtilitiesTest.java | 3 + .../icu/dev/test/util/DisplayNameTest.java | 32 +- .../ibm/icu/dev/test/util/GenderInfoTest.java | 7 +- .../ibm/icu/dev/test/util/ICUBinaryTest.java | 16 +- .../dev/test/util/ICUResourceBundleTest.java | 3 + .../ibm/icu/dev/test/util/ICUServiceTest.java | 26 +- .../dev/test/util/ICUServiceThreadTest.java | 14 + .../icu/dev/test/util/LocaleAliasTest.java | 37 +- .../icu/dev/test/util/LocaleBuilderTest.java | 9 +- .../ibm/icu/dev/test/util/LocaleDataTest.java | 27 +- .../icu/dev/test/util/LocaleMatcherTest.java | 3 + .../dev/test/util/LocalePriorityListTest.java | 7 +- .../com/ibm/icu/dev/test/util/RegionTest.java | 29 +- .../dev/test/util/SimpleFormatterTest.java | 47 +- .../dev/test/util/StringTokenizerTest.java | 223 +-- .../icu/dev/test/util/TestLocaleValidity.java | 3 + .../icu/dev/test/util/TextTrieMapTest.java | 3 + .../com/ibm/icu/dev/test/util/Trie2Test.java | 169 +- .../ibm/icu/dev/test/util/TrieMapTest.java | 34 +- .../com/ibm/icu/dev/test/util/TrieTest.java | 221 +-- .../ibm/icu/dev/test/util/ULocaleTest.java | 3 + .../ibm/icu/dev/test/util/UtilityTest.java | 33 +- .../icu/dev/test/util/VersionInfoTest.java | 3 + .../dev/test/util/XLocaleDistanceTest.java | 3 + .../icu/dev/test/util/XLocaleMatcherTest.java | 3 + .../src/com/ibm/icu/text/DigitListTest.java | 3 + .../dev/test/localespi/BreakIteratorTest.java | 7 +- .../icu/dev/test/localespi/CollatorTest.java | 3 + .../dev/test/localespi/CurrencyNameTest.java | 3 + .../test/localespi/DateFormatSymbolsTest.java | 3 + .../dev/test/localespi/DateFormatTest.java | 3 + .../localespi/DecimalFormatSymbolsTest.java | 3 + .../dev/test/localespi/LocaleNameTest.java | 11 +- .../dev/test/localespi/NumberFormatTest.java | 3 + .../dev/test/localespi/TimeZoneNameTest.java | 11 +- .../icu/dev/test/TestLocaleNamePackaging.java | 11 +- .../icu/dev/test/translit/AnyScriptTest.java | 25 +- .../translit/CompoundTransliteratorTest.java | 68 +- .../ibm/icu/dev/test/translit/ErrorTest.java | 4 + .../ibm/icu/dev/test/translit/JamoTest.java | 29 +- .../dev/test/translit/RegexUtilitiesTest.java | 5 +- .../dev/test/translit/ReplaceableTest.java | 40 +- .../icu/dev/test/translit/RoundTripTest.java | 26 +- .../ibm/icu/dev/test/translit/ThreadTest.java | 25 +- .../dev/test/translit/TransliteratorTest.java | 3 + .../icu/dev/test/translit/UnicodeMapTest.java | 23 +- .../ibm/icu/dev/test/util/TestUtilities.java | 3 + 206 files changed, 4852 insertions(+), 4072 deletions(-) diff --git a/icu4j/main/tests/charset/src/com/ibm/icu/dev/test/charset/TestCharset.java b/icu4j/main/tests/charset/src/com/ibm/icu/dev/test/charset/TestCharset.java index a95bc778ac9..9a5dc189d3e 100644 --- a/icu4j/main/tests/charset/src/com/ibm/icu/dev/test/charset/TestCharset.java +++ b/icu4j/main/tests/charset/src/com/ibm/icu/dev/test/charset/TestCharset.java @@ -27,6 +27,8 @@ import java.util.Set; import java.util.SortedMap; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.charset.CharsetCallback; import com.ibm.icu.charset.CharsetDecoderICU; @@ -37,6 +39,7 @@ import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.UTF16; import com.ibm.icu.text.UnicodeSet; +@RunWith(JUnit4.class) public class TestCharset extends TestFmwk { @Test public void TestUTF16Converter(){ @@ -44,18 +47,18 @@ public class TestCharset extends TestFmwk { Charset cs1 = icu.charsetForName("UTF-16BE"); CharsetEncoder e1 = cs1.newEncoder(); CharsetDecoder d1 = cs1.newDecoder(); - + Charset cs2 = icu.charsetForName("UTF-16LE"); CharsetEncoder e2 = cs2.newEncoder(); CharsetDecoder d2 = cs2.newDecoder(); - + for(int i=0x0000; i<0x10FFFF; i+=0xFF){ CharBuffer us = CharBuffer.allocate(0xFF*2); ByteBuffer bs1 = ByteBuffer.allocate(0xFF*8); ByteBuffer bs2 = ByteBuffer.allocate(0xFF*8); for(int j=0;j<0xFF; j++){ int c = i+j; - + if((c>=0xd800&&c<=0xdFFF)||c>0x10FFFF){ continue; } @@ -77,7 +80,7 @@ public class TestCharset extends TestFmwk { bs1.put((byte)(lead&0xFF)); bs1.put((byte)(trail>>8)); bs1.put((byte)(trail&0xFF)); - + bs2.put((byte)(lead&0xFF)); bs2.put((byte)(lead>>8)); bs2.put((byte)(trail&0xFF)); @@ -92,63 +95,63 @@ public class TestCharset extends TestFmwk { }else{ bs1.put((byte)(c>>8)); bs1.put((byte)(c&0xFF)); - + bs2.put((byte)(c&0xFF)); bs2.put((byte)(c>>8)); } us.put((char)c); } } - - + + us.limit(us.position()); us.position(0); if(us.length()==0){ continue; } - + bs1.limit(bs1.position()); bs1.position(0); ByteBuffer newBS = ByteBuffer.allocate(bs1.capacity()); //newBS.put((byte)0xFE); //newBS.put((byte)0xFF); - newBS.put(bs1); + newBS.put(bs1); bs1.position(0); smBufDecode(d1, "UTF-16", bs1, us); smBufEncode(e1, "UTF-16", us, newBS); - + bs2.limit(bs2.position()); bs2.position(0); newBS.clear(); //newBS.put((byte)0xFF); //newBS.put((byte)0xFE); - newBS.put(bs2); + newBS.put(bs2); bs2.position(0); smBufDecode(d2, "UTF16-LE", bs2, us); smBufEncode(e2, "UTF-16LE", us, newBS); - + } } - + @Test public void TestUTF32Converter(){ CharsetProvider icu = new CharsetProviderICU(); Charset cs1 = icu.charsetForName("UTF-32BE"); CharsetEncoder e1 = cs1.newEncoder(); CharsetDecoder d1 = cs1.newDecoder(); - + Charset cs2 = icu.charsetForName("UTF-32LE"); CharsetEncoder e2 = cs2.newEncoder(); CharsetDecoder d2 = cs2.newDecoder(); - + for(int i=0x000; i<0x10FFFF; i+=0xFF){ CharBuffer us = CharBuffer.allocate(0xFF*2); ByteBuffer bs1 = ByteBuffer.allocate(0xFF*8); ByteBuffer bs2 = ByteBuffer.allocate(0xFF*8); for(int j=0;j<0xFF; j++){ int c = i+j; - + if((c>=0xd800&&c<=0xdFFF)||c>0x10FFFF){ continue; } @@ -163,13 +166,13 @@ public class TestCharset extends TestFmwk { us.put((char)c); } bs1.put((byte) (c >>> 24)); - bs1.put((byte) (c >>> 16)); - bs1.put((byte) (c >>> 8)); - bs1.put((byte) (c & 0xFF)); - - bs2.put((byte) (c & 0xFF)); + bs1.put((byte) (c >>> 16)); + bs1.put((byte) (c >>> 8)); + bs1.put((byte) (c & 0xFF)); + + bs2.put((byte) (c & 0xFF)); bs2.put((byte) (c >>> 8)); - bs2.put((byte) (c >>> 16)); + bs2.put((byte) (c >>> 16)); bs2.put((byte) (c >>> 24)); } bs1.limit(bs1.position()); @@ -181,41 +184,41 @@ public class TestCharset extends TestFmwk { if(us.length()==0){ continue; } - + ByteBuffer newBS = ByteBuffer.allocate(bs1.capacity()); - + newBS.put((byte)0x00); newBS.put((byte)0x00); newBS.put((byte)0xFE); newBS.put((byte)0xFF); - + newBS.put(bs1); bs1.position(0); smBufDecode(d1, "UTF-32", bs1, us); smBufEncode(e1, "UTF-32", us, newBS); - - + + newBS.clear(); - + newBS.put((byte)0xFF); newBS.put((byte)0xFE); newBS.put((byte)0x00); newBS.put((byte)0x00); - - newBS.put(bs2); + + newBS.put(bs2); bs2.position(0); smBufDecode(d2, "UTF-32LE", bs2, us); smBufEncode(e2, "UTF-32LE", us, newBS); } } - + @Test public void TestASCIIConverter() { runTestASCIIBasedConverter("ASCII", 0x80); } - + @Test public void Test88591Converter() { runTestASCIIBasedConverter("iso-8859-1", 0x100); @@ -228,8 +231,8 @@ public class TestCharset extends TestFmwk { CharsetDecoder decoder = icuChar.newDecoder(); CoderResult cr; - /* test with and without array-backed buffers */ - + /* test with and without array-backed buffers */ + byte[] bytes = new byte[0x10000]; char[] chars = new char[0x10000]; for (int j = 0; j <= 0xffff; j++) { @@ -241,7 +244,7 @@ public class TestCharset extends TestFmwk { boolean arrays = false; boolean decoding = false; int i; - + // 0 thru limit - 1 ByteBuffer bs = ByteBuffer.wrap(bytes, 0, limit); CharBuffer us = CharBuffer.wrap(chars, 0, limit); @@ -256,26 +259,26 @@ public class TestCharset extends TestFmwk { decoding = true; arrays = true; smBufDecode(decoder, converter, bs, us, true, false, true); - + decoding = true; arrays = false; smBufDecode(decoder, converter, bs, us, true, false, false); - + decoding = false; arrays = true; smBufEncode(encoder, converter, us, bs, true, false, true); - + decoding = false; arrays = false; smBufEncode(encoder, converter, us, bs, true, false, false); - + } catch (Exception ex) { errln("Failed to fail to " + (decoding ? "decode" : "encode") + " 0x" + Integer.toHexString(i) + (arrays ? " with arrays" : " without arrays") + " in " + converter); return; } } - + // decode limit thru 255 for (i = limit; i <= 0xff; i++) { bs = ByteBuffer.wrap(bytes, i, 1).slice(); @@ -300,7 +303,7 @@ public class TestCharset extends TestFmwk { + (arrays ? " with arrays" : " without arrays") + " in " + converter); return; } - + // encode limit thru 0xffff, skipping through much of the 1ff to feff range to save // time (it would take too much time to test every possible case) for (i = limit; i <= 0xffff; i = ((i>=0x1ff && i<0xfeff) ? i+0xfd : i+1)) { @@ -326,7 +329,7 @@ public class TestCharset extends TestFmwk { + (arrays ? " with arrays" : " without arrays") + " in " + converter); return; } - + // test overflow / underflow edge cases outer: for (int n = 1; n <= 3; n++) { for (int m = 0; m < n; m++) { @@ -356,7 +359,7 @@ public class TestCharset extends TestFmwk { fail = true; break outer; } - + // expecting overflow try { bs = ByteBuffer.wrap(bytes, 'a', n).slice(); @@ -409,7 +412,7 @@ public class TestCharset extends TestFmwk { errln("Incorrect result in " + converter + " for underflow / overflow edge cases"); return; } - + // test surrogate combinations in encoding String lead = "\ud888"; String trail = "\udc88"; @@ -439,7 +442,7 @@ public class TestCharset extends TestFmwk { CoderResult.unmappableForLength(1), CoderResult.unmappableForLength(1), }; - + for (int index = 0; index < input.length; index++) { CharBuffer source = CharBuffer.wrap(input[index]); cr = encoder.encode(source, bs, true); @@ -472,7 +475,7 @@ public class TestCharset extends TestFmwk { } } } - + @Test public void TestUTF8Converter() { String converter = "UTF-8"; @@ -484,13 +487,13 @@ public class TestCharset extends TestFmwk { CharBuffer us; CoderResult cr; - + int[] size = new int[] { 1<<7, 1<<11, 1<<16 }; // # of 1,2,3 byte combinations byte[] bytes = new byte[size[0] + size[1]*2 + size[2]*3]; char[] chars = new char[size[0] + size[1] + size[2]]; int i = 0; int x, y; - + // 0 to 1 << 7 (1 byters) for (; i < size[0]; i++) { bytes[i] = (byte) i; @@ -554,7 +557,7 @@ public class TestCharset extends TestFmwk { } else { bs = ByteBuffer.wrap(bytes, x, 3).slice(); us = CharBuffer.wrap(chars, y, 1).slice(); - + decoder.reset(); cr = decoder.decode(bs, us, true); bs.rewind(); @@ -573,10 +576,10 @@ public class TestCharset extends TestFmwk { + Integer.toHexString(i) + " received " + cr); break; } - + bs = ByteBuffer.wrap(bytes, x, 3).slice(); us = CharBuffer.wrap(new String(chars, y, 1)); - + decoder.reset(); cr = decoder.decode(bs, us, true); bs.rewind(); @@ -595,14 +598,14 @@ public class TestCharset extends TestFmwk { + Integer.toHexString(i) + " received " + cr); break; } - - + + } } if (true) return; } - + @Test public void TestHZ() { /* test input */ @@ -620,7 +623,7 @@ public class TestCharset extends TestFmwk { 0x0051, 0x0052, 0x0053, 0x000A, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x000A }; - + String converter = "HZ"; CharsetProvider icu = new CharsetProviderICU(); Charset icuChar = icu.charsetForName(converter); @@ -630,14 +633,14 @@ public class TestCharset extends TestFmwk { CharBuffer start = CharBuffer.wrap(in); ByteBuffer bytes = encoder.encode(start); CharBuffer finish = decoder.decode(bytes); - + if (!equals(start, finish)) { errln(converter + " roundtrip test failed: start does not match finish"); - + char[] finishArray = new char[finish.limit()]; for (int i=0; i. */ /* UTF7: AImIDkQ. */ us.put((char)0x41); us.put((char)0x2262); us.put((char)0x391); us.put((char)0x39B); us.put((char)0x2e); - bs.put((byte)0x41); bs.put((byte)0x2b); bs.put((byte)0x49); bs.put((byte)0x6d); - bs.put((byte)0x49); bs.put((byte)0x44); bs.put((byte)0x6b); bs.put((byte)0x51); + bs.put((byte)0x41); bs.put((byte)0x2b); bs.put((byte)0x49); bs.put((byte)0x6d); + bs.put((byte)0x49); bs.put((byte)0x44); bs.put((byte)0x6b); bs.put((byte)0x51); bs.put((byte)0x4f); bs.put((byte)0x62); bs.put((byte)0x2e); - + bs.limit(bs.position()); bs.position(0); us.limit(us.position()); @@ -2807,20 +2810,20 @@ public class TestCharset extends TestFmwk { smBufDecode(decoder, "UTF-7", bs, us); smBufEncode(encoder, "UTF-7", us, bs); - + /* Testing UTF-7 toUnicode with substitute callbacks */ { byte [] bytesTestErrorConsumption = { /* a~ a+AB~ a+AB\x0c a+AB- a+AB. a+. */ 0x61, 0x7e, 0x61, 0x2b, 0x41, 0x42, 0x7e, 0x61, 0x2b, 0x41, 0x42, 0x0c, 0x61, 0x2b, 0x41, 0x42, 0x2d, 0x61, 0x2b, 0x41, 0x42, 0x2e, 0x61, 0x2b, 0x2e - + }; char [] unicodeTestErrorConsumption = { 0x61, 0xfffd, 0x61, 0xfffd, 0xfffd, 0x61, 0xfffd, 0xfffd, 0x61, 0xfffd, 0x61, 0xfffd, 0x2e, 0x61, 0xfffd, 0x2e }; bs = ByteBuffer.wrap(bytesTestErrorConsumption); us = CharBuffer.wrap(unicodeTestErrorConsumption); - + CodingErrorAction savedMal = decoder.malformedInputAction(); CodingErrorAction savedUMap = decoder.unmappableCharacterAction(); decoder.onMalformedInput(CodingErrorAction.REPLACE); @@ -2839,16 +2842,16 @@ public class TestCharset extends TestFmwk { errln("Buffer Overflow exception should have been thrown while decoding UTF-7."); } catch (Exception ex) { } - + //The rest of the code in this method is to provide better code coverage CharBuffer ccus = CharBuffer.allocate(0x10); ByteBuffer ccbs = ByteBuffer.allocate(0x10); - + //start of charset decoder code coverage code //test for accurate illegal and control character checking ccbs.put((byte)0x0D); ccbs.put((byte)0x05); ccus.put((char)0x0000); - + ccbs.limit(ccbs.position()); ccbs.position(0); ccus.limit(ccus.position()); @@ -2860,131 +2863,131 @@ public class TestCharset extends TestFmwk { } catch (Exception ex) { } - + ccbs.clear(); ccus.clear(); - + //test for illegal base64 character ccbs.put((byte)0x2b); ccbs.put((byte)0xff); ccus.put((char)0x0000); - + ccbs.limit(ccbs.position()); ccbs.position(0); ccus.limit(ccus.position()); ccus.position(0); - + try { smBufDecode(decoder, "UTF-7-CC-DE-2", ccbs, ccus, true, false); errln("Exception while decoding UTF-7 code coverage test should have been thrown."); } catch (Exception ex) { } - + ccbs.clear(); ccus.clear(); - + //test for illegal order of the base64 character sequence ccbs.put((byte)0x2b); ccbs.put((byte)0x2d); ccbs.put((byte)0x2b); ccbs.put((byte)0x49); ccbs.put((byte)0x2d); ccus.put((char)0x0000); ccus.put((char)0x0000); - + ccbs.limit(ccbs.position()); ccbs.position(0); ccus.limit(ccus.position()); ccus.position(0); - + try { smBufDecode(decoder, "UTF-7-CC-DE-3", ccbs, ccus, true, false); errln("Exception while decoding UTF-7 code coverage test should have been thrown."); } catch (Exception ex) { } - + ccbs.clear(); ccus.clear(); - - //test for illegal order of the base64 character sequence + + //test for illegal order of the base64 character sequence ccbs.put((byte)0x2b); ccbs.put((byte)0x0a); ccbs.put((byte)0x09); ccus.put((char)0x0000); - + ccbs.limit(ccbs.position()); ccbs.position(0); ccus.limit(ccus.position()); ccus.position(0); - + try { smBufDecode(decoder, "UTF-7-CC-DE-4", ccbs, ccus, true, false); errln("Exception while decoding UTF-7 code coverage test should have been thrown."); } catch (Exception ex) { } - + ccbs.clear(); ccus.clear(); - + //test for illegal order of the base64 character sequence ccbs.put((byte)0x2b); ccbs.put((byte)0x49); ccbs.put((byte)0x0a); ccus.put((char)0x0000); - + ccbs.limit(ccbs.position()); ccbs.position(0); ccus.limit(ccus.position()); ccus.position(0); - + try { smBufDecode(decoder, "UTF-7-CC-DE-5", ccbs, ccus, true, false); errln("Exception while decoding UTF-7 code coverage test should have been thrown."); } catch (Exception ex) { } - + ccbs.clear(); ccus.clear(); - + //test for illegal order of the base64 character sequence ccbs.put((byte)0x2b); ccbs.put((byte)0x00); ccus.put((char)0x0000); - + ccbs.limit(ccbs.position()); ccbs.position(0); ccus.limit(ccus.position()); ccus.position(0); - + try { smBufDecode(decoder, "UTF-7-CC-DE-6", ccbs, ccus, true, false); errln("Exception while decoding UTF-7 code coverage test should have been thrown."); } catch (Exception ex) { } - + ccbs.clear(); ccus.clear(); - + //test for overflow buffer error ccbs.put((byte)0x2b); ccbs.put((byte)0x49); - + ccbs.limit(ccbs.position()); ccbs.position(0); ccus.limit(0); ccus.position(0); - + try { smBufDecode(decoder, "UTF-7-CC-DE-7", ccbs, ccus, true, false); errln("Exception while decoding UTF-7 code coverage test should have been thrown."); } catch (Exception ex) { } - + ccbs.clear(); ccus.clear(); - + //test for overflow buffer error ccbs.put((byte)0x0c); ccbs.put((byte)0x0c); - + ccbs.limit(ccbs.position()); ccbs.position(0); ccus.limit(0); ccus.position(0); - + try { smBufDecode(decoder, "UTF-7-CC-DE-8", ccbs, ccus, true, false); errln("Exception while decoding UTF-7 code coverage test should have been thrown."); @@ -2992,48 +2995,48 @@ public class TestCharset extends TestFmwk { catch (Exception ex) { } //end of charset decoder code coverage code - + //start of charset encoder code coverage code ccbs.clear(); ccus.clear(); //test for overflow buffer error ccus.put((char)0x002b); - ccbs.put((byte)0x2b); - + ccbs.put((byte)0x2b); + ccbs.limit(ccbs.position()); ccbs.position(0); ccus.limit(ccus.position()); ccus.position(0); - + try { smBufEncode(encoder, "UTF-7-CC-EN-1", ccus, ccbs, true, false); errln("Exception while encoding UTF-7 code coverage test should have been thrown."); } catch (Exception ex) { } - + ccbs.clear(); ccus.clear(); - + //test for overflow buffer error ccus.put((char)0x002b); ccus.put((char)0x2262); ccbs.put((byte)0x2b); ccbs.put((byte)0x2d); ccbs.put((byte)0x00); ccbs.put((byte)0x00); - + ccbs.limit(ccbs.position()); ccbs.position(0); ccus.limit(ccus.position()); ccus.position(0); - + try { smBufEncode(encoder, "UTF-7-CC-EN-2", ccus, ccbs, true, false); errln("Exception while encoding UTF-7 code coverage test should have been thrown."); } catch (Exception ex) { - } - + } + ccbs.clear(); ccus.clear(); - + //test for overflow buffer error ccus.put((char)0x2262); ccus.put((char)0x0049); ccbs.put((byte)0x00); ccbs.put((byte)0x00); ccbs.put((byte)0x00); ccbs.put((byte)0x00); ccbs.put((byte)0x00); @@ -3041,17 +3044,17 @@ public class TestCharset extends TestFmwk { ccbs.position(0); ccus.limit(ccus.position()); ccus.position(0); - + try { smBufEncode(encoder, "UTF-7-CC-EN-3", ccus, ccbs, true, false); errln("Exception while encoding UTF-7 code coverage test should have been thrown."); } catch (Exception ex) { - } - + } + ccbs.clear(); ccus.clear(); - + //test for overflow buffer error ccus.put((char)0x2262); ccus.put((char)0x0395); ccbs.put((byte)0x00); ccbs.put((byte)0x00); ccbs.put((byte)0x00); ccbs.put((byte)0x00); @@ -3059,17 +3062,17 @@ public class TestCharset extends TestFmwk { ccbs.position(0); ccus.limit(ccus.position()); ccus.position(0); - + try { smBufEncode(encoder, "UTF-7-CC-EN-4", ccus, ccbs, true, false); errln("Exception while encoding UTF-7 code coverage test should have been thrown."); } catch (Exception ex) { - } - + } + ccbs.clear(); ccus.clear(); - + //test for overflow buffer error ccus.put((char)0x2262); ccus.put((char)0x0395); ccbs.put((byte)0x00); ccbs.put((byte)0x00); ccbs.put((byte)0x00); ccbs.put((byte)0x00); ccbs.put((byte)0x00); @@ -3077,17 +3080,17 @@ public class TestCharset extends TestFmwk { ccbs.position(0); ccus.limit(ccus.position()); ccus.position(0); - + try { smBufEncode(encoder, "UTF-7-CC-EN-5", ccus, ccbs, true, false); errln("Exception while encoding UTF-7 code coverage test should have been thrown."); } catch (Exception ex) { - } - + } + ccbs.clear(); ccus.clear(); - + //test for overflow buffer error ccus.put((char)0x2262); ccus.put((char)0x0395); ccus.put((char)0x0391); ccbs.put((byte)0x00); ccbs.put((byte)0x00); ccbs.put((byte)0x00); ccbs.put((byte)0x00); ccbs.put((byte)0x00); ccbs.put((byte)0x00); ccbs.put((byte)0x00); @@ -3095,54 +3098,54 @@ public class TestCharset extends TestFmwk { ccbs.position(0); ccus.limit(ccus.position()); ccus.position(0); - + try { smBufEncode(encoder, "UTF-7-CC-EN-6", ccus, ccbs, true, false); errln("Exception while encoding UTF-7 code coverage test should have been thrown."); } catch (Exception ex) { - } - + } + ccbs.clear(); ccus.clear(); - + //test for overflow buffer error ccus.put((char)0x2262); ccus.put((char)0x0395); ccus.put((char)0x0391); - ccbs.put((byte)0x00); ccbs.put((byte)0x00); ccbs.put((byte)0x00); ccbs.put((byte)0x00); + ccbs.put((byte)0x00); ccbs.put((byte)0x00); ccbs.put((byte)0x00); ccbs.put((byte)0x00); ccbs.put((byte)0x00); ccbs.put((byte)0x00); ccbs.put((byte)0x00); ccbs.put((byte)0x00); ccbs.limit(ccbs.position()); ccbs.position(0); ccus.limit(ccus.position()); ccus.position(0); - + try { smBufEncode(encoder, "UTF-7-CC-EN-7", ccus, ccbs, true, false); errln("Exception while encoding UTF-7 code coverage test should have been thrown."); } catch (Exception ex) { - } - + } + ccbs.clear(); ccus.clear(); - + //test for overflow buffer error ccus.put((char)0x0049); ccus.put((char)0x0048); - ccbs.put((byte)0x00); + ccbs.put((byte)0x00); ccbs.limit(ccbs.position()); ccbs.position(0); ccus.limit(ccus.position()); ccus.position(0); - + try { smBufEncode(encoder, "UTF-7-CC-EN-8", ccus, ccbs, true, false); errln("Exception while encoding UTF-7 code coverage test should have been thrown."); } catch (Exception ex) { - } - + } + ccbs.clear(); ccus.clear(); - + //test for overflow buffer error ccus.put((char)0x2262); ccbs.put((byte)0x00); @@ -3150,17 +3153,17 @@ public class TestCharset extends TestFmwk { ccbs.position(0); ccus.limit(ccus.position()); ccus.position(0); - + try { smBufEncode(encoder, "UTF-7-CC-EN-9", ccus, ccbs, true, false); errln("Exception while encoding UTF-7 code coverage test should have been thrown."); } catch (Exception ex) { - } - + } + ccbs.clear(); ccus.clear(); - + //test for overflow buffer error ccus.put((char)0x2262); ccus.put((char)0x0049); ccbs.put((byte)0x00); ccbs.put((byte)0x00); ccbs.put((byte)0x00); ccbs.put((byte)0x00); @@ -3168,21 +3171,21 @@ public class TestCharset extends TestFmwk { ccbs.position(0); ccus.limit(ccus.position()); ccus.position(0); - + try { smBufEncode(encoder, "UTF-7-CC-EN-10", ccus, ccbs, true, false); errln("Exception while encoding UTF-7 code coverage test should have been thrown."); } catch (Exception ex) { - } - + } + ccbs.clear(); ccus.clear(); - + //test for overflow buffer error ccus.put((char)0x2262); ccbs.put((byte)0x2b); ccbs.put((byte)0x49); ccbs.put((byte)0x6d); ccbs.put((byte)0x49); ccbs.put((byte)0x2d); - + ccbs.limit(ccbs.position()); ccbs.position(0); ccus.limit(ccus.position()); @@ -3192,20 +3195,20 @@ public class TestCharset extends TestFmwk { } catch (Exception ex) { errln("Exception while encoding UTF-7 code coverage test should not have been thrown."); } - + ccbs.clear(); ccus.clear(); - + //test for overflow buffer error encoder.reset(); ccus.put((char)0x3980); ccus.put((char)0x2715); ccbs.put((byte)0x2b); ccbs.put((byte)0x4f); ccbs.put((byte)0x59); ccbs.put((byte)0x2d); - + ccbs.limit(ccbs.position()); ccbs.position(0); ccus.limit(ccus.position()); ccus.position(0); - + result = encoder.encode(ccus, ccbs, true); result = encoder.flush(ccbs); if (!result.isOverflow()) { @@ -3218,104 +3221,104 @@ public class TestCharset extends TestFmwk { @Test public void TestCharsetISCII() { CharsetProvider provider = new CharsetProviderICU(); - Charset cs = provider.charsetForName("ISCII,version=0"); + Charset cs = provider.charsetForName("ISCII,version=0"); CharsetEncoder encoder = cs.newEncoder(); CharsetDecoder decoder = cs.newDecoder(); - + CharBuffer us = CharBuffer.allocate(0x100); ByteBuffer bs = ByteBuffer.allocate(0x100); ByteBuffer bsr = ByteBuffer.allocate(0x100); - + //test full range of Devanagari us.put((char)0x0901); us.put((char)0x0902); us.put((char)0x0903); us.put((char)0x0905); us.put((char)0x0906); us.put((char)0x0907); us.put((char)0x0908); us.put((char)0x0909); us.put((char)0x090A); us.put((char)0x090B); us.put((char)0x090E); us.put((char)0x090F); us.put((char)0x0910); us.put((char)0x090D); us.put((char)0x0912); us.put((char)0x0913); us.put((char)0x0914); us.put((char)0x0911); us.put((char)0x0915); us.put((char)0x0916); us.put((char)0x0917); us.put((char)0x0918); us.put((char)0x0919); us.put((char)0x091A); us.put((char)0x091B); us.put((char)0x091C); us.put((char)0x091D); us.put((char)0x091E); us.put((char)0x091F); us.put((char)0x0920); - us.put((char)0x0921); us.put((char)0x0922); us.put((char)0x0923); us.put((char)0x0924); us.put((char)0x0925); us.put((char)0x0926); - us.put((char)0x0927); us.put((char)0x0928); us.put((char)0x0929); us.put((char)0x092A); us.put((char)0x092B); us.put((char)0x092C); - us.put((char)0x092D); us.put((char)0x092E); us.put((char)0x092F); us.put((char)0x095F); us.put((char)0x0930); us.put((char)0x0931); - us.put((char)0x0932); us.put((char)0x0933); us.put((char)0x0934); us.put((char)0x0935); us.put((char)0x0936); us.put((char)0x0937); - us.put((char)0x0938); us.put((char)0x0939); us.put((char)0x200D); us.put((char)0x093E); us.put((char)0x093F); us.put((char)0x0940); - us.put((char)0x0941); us.put((char)0x0942); us.put((char)0x0943); us.put((char)0x0946); us.put((char)0x0947); us.put((char)0x0948); - us.put((char)0x0945); us.put((char)0x094A); us.put((char)0x094B); us.put((char)0x094C); us.put((char)0x0949); us.put((char)0x094D); - us.put((char)0x093D); us.put((char)0x0966); us.put((char)0x0967); us.put((char)0x0968); us.put((char)0x0969); us.put((char)0x096A); - us.put((char)0x096B); us.put((char)0x096C); us.put((char)0x096D); us.put((char)0x096E); us.put((char)0x096F); - + us.put((char)0x0921); us.put((char)0x0922); us.put((char)0x0923); us.put((char)0x0924); us.put((char)0x0925); us.put((char)0x0926); + us.put((char)0x0927); us.put((char)0x0928); us.put((char)0x0929); us.put((char)0x092A); us.put((char)0x092B); us.put((char)0x092C); + us.put((char)0x092D); us.put((char)0x092E); us.put((char)0x092F); us.put((char)0x095F); us.put((char)0x0930); us.put((char)0x0931); + us.put((char)0x0932); us.put((char)0x0933); us.put((char)0x0934); us.put((char)0x0935); us.put((char)0x0936); us.put((char)0x0937); + us.put((char)0x0938); us.put((char)0x0939); us.put((char)0x200D); us.put((char)0x093E); us.put((char)0x093F); us.put((char)0x0940); + us.put((char)0x0941); us.put((char)0x0942); us.put((char)0x0943); us.put((char)0x0946); us.put((char)0x0947); us.put((char)0x0948); + us.put((char)0x0945); us.put((char)0x094A); us.put((char)0x094B); us.put((char)0x094C); us.put((char)0x0949); us.put((char)0x094D); + us.put((char)0x093D); us.put((char)0x0966); us.put((char)0x0967); us.put((char)0x0968); us.put((char)0x0969); us.put((char)0x096A); + us.put((char)0x096B); us.put((char)0x096C); us.put((char)0x096D); us.put((char)0x096E); us.put((char)0x096F); + bs.put((byte)0xEF); bs.put((byte)0x42); bs.put((byte)0xA1); bs.put((byte)0xA2); bs.put((byte)0xA3); bs.put((byte)0xA4); bs.put((byte)0xA5); bs.put((byte)0xA6); - bs.put((byte)0xA7); bs.put((byte)0xA8); bs.put((byte)0xA9); bs.put((byte)0xAA); bs.put((byte)0xAB); bs.put((byte)0xAC); - bs.put((byte)0xAD); bs.put((byte)0xAE); bs.put((byte)0xAF); bs.put((byte)0xB0); bs.put((byte)0xB1); bs.put((byte)0xB2); - bs.put((byte)0xB3); bs.put((byte)0xB4); bs.put((byte)0xB5); bs.put((byte)0xB6); bs.put((byte)0xB7); bs.put((byte)0xB8); - bs.put((byte)0xB9); bs.put((byte)0xBA); bs.put((byte)0xBB); bs.put((byte)0xBC); bs.put((byte)0xBD); bs.put((byte)0xBE); - bs.put((byte)0xBF); bs.put((byte)0xC0); bs.put((byte)0xC1); bs.put((byte)0xC2); bs.put((byte)0xC3); bs.put((byte)0xC4); - bs.put((byte)0xC5); bs.put((byte)0xC6); bs.put((byte)0xC7); bs.put((byte)0xC8); bs.put((byte)0xC9); bs.put((byte)0xCA); - bs.put((byte)0xCB); bs.put((byte)0xCC); bs.put((byte)0xCD); bs.put((byte)0xCE); bs.put((byte)0xCF); bs.put((byte)0xD0); - bs.put((byte)0xD1); bs.put((byte)0xD2); bs.put((byte)0xD3); bs.put((byte)0xD4); bs.put((byte)0xD5); bs.put((byte)0xD6); - bs.put((byte)0xD7); bs.put((byte)0xD8); bs.put((byte)0xD9); bs.put((byte)0xDA); bs.put((byte)0xDB); bs.put((byte)0xDC); - bs.put((byte)0xDD); bs.put((byte)0xDE); bs.put((byte)0xDF); bs.put((byte)0xE0); bs.put((byte)0xE1); bs.put((byte)0xE2); - bs.put((byte)0xE3); bs.put((byte)0xE4); bs.put((byte)0xE5); bs.put((byte)0xE6); bs.put((byte)0xE7); bs.put((byte)0xE8); - bs.put((byte)0xEA); bs.put((byte)0xE9); bs.put((byte)0xF1); bs.put((byte)0xF2); bs.put((byte)0xF3); bs.put((byte)0xF4); - bs.put((byte)0xF5); bs.put((byte)0xF6); bs.put((byte)0xF7); bs.put((byte)0xF8); bs.put((byte)0xF9); bs.put((byte)0xFA); - + bs.put((byte)0xA7); bs.put((byte)0xA8); bs.put((byte)0xA9); bs.put((byte)0xAA); bs.put((byte)0xAB); bs.put((byte)0xAC); + bs.put((byte)0xAD); bs.put((byte)0xAE); bs.put((byte)0xAF); bs.put((byte)0xB0); bs.put((byte)0xB1); bs.put((byte)0xB2); + bs.put((byte)0xB3); bs.put((byte)0xB4); bs.put((byte)0xB5); bs.put((byte)0xB6); bs.put((byte)0xB7); bs.put((byte)0xB8); + bs.put((byte)0xB9); bs.put((byte)0xBA); bs.put((byte)0xBB); bs.put((byte)0xBC); bs.put((byte)0xBD); bs.put((byte)0xBE); + bs.put((byte)0xBF); bs.put((byte)0xC0); bs.put((byte)0xC1); bs.put((byte)0xC2); bs.put((byte)0xC3); bs.put((byte)0xC4); + bs.put((byte)0xC5); bs.put((byte)0xC6); bs.put((byte)0xC7); bs.put((byte)0xC8); bs.put((byte)0xC9); bs.put((byte)0xCA); + bs.put((byte)0xCB); bs.put((byte)0xCC); bs.put((byte)0xCD); bs.put((byte)0xCE); bs.put((byte)0xCF); bs.put((byte)0xD0); + bs.put((byte)0xD1); bs.put((byte)0xD2); bs.put((byte)0xD3); bs.put((byte)0xD4); bs.put((byte)0xD5); bs.put((byte)0xD6); + bs.put((byte)0xD7); bs.put((byte)0xD8); bs.put((byte)0xD9); bs.put((byte)0xDA); bs.put((byte)0xDB); bs.put((byte)0xDC); + bs.put((byte)0xDD); bs.put((byte)0xDE); bs.put((byte)0xDF); bs.put((byte)0xE0); bs.put((byte)0xE1); bs.put((byte)0xE2); + bs.put((byte)0xE3); bs.put((byte)0xE4); bs.put((byte)0xE5); bs.put((byte)0xE6); bs.put((byte)0xE7); bs.put((byte)0xE8); + bs.put((byte)0xEA); bs.put((byte)0xE9); bs.put((byte)0xF1); bs.put((byte)0xF2); bs.put((byte)0xF3); bs.put((byte)0xF4); + bs.put((byte)0xF5); bs.put((byte)0xF6); bs.put((byte)0xF7); bs.put((byte)0xF8); bs.put((byte)0xF9); bs.put((byte)0xFA); + bsr.put((byte)0xA1); bsr.put((byte)0xA2); bsr.put((byte)0xA3); bsr.put((byte)0xA4); bsr.put((byte)0xA5); bsr.put((byte)0xA6); - bsr.put((byte)0xA7); bsr.put((byte)0xA8); bsr.put((byte)0xA9); bsr.put((byte)0xAA); bsr.put((byte)0xAB); bsr.put((byte)0xAC); - bsr.put((byte)0xAD); bsr.put((byte)0xAE); bsr.put((byte)0xAF); bsr.put((byte)0xB0); bsr.put((byte)0xB1); bsr.put((byte)0xB2); - bsr.put((byte)0xB3); bsr.put((byte)0xB4); bsr.put((byte)0xB5); bsr.put((byte)0xB6); bsr.put((byte)0xB7); bsr.put((byte)0xB8); - bsr.put((byte)0xB9); bsr.put((byte)0xBA); bsr.put((byte)0xBB); bsr.put((byte)0xBC); bsr.put((byte)0xBD); bsr.put((byte)0xBE); - bsr.put((byte)0xBF); bsr.put((byte)0xC0); bsr.put((byte)0xC1); bsr.put((byte)0xC2); bsr.put((byte)0xC3); bsr.put((byte)0xC4); - bsr.put((byte)0xC5); bsr.put((byte)0xC6); bsr.put((byte)0xC7); bsr.put((byte)0xC8); bsr.put((byte)0xC9); bsr.put((byte)0xCA); - bsr.put((byte)0xCB); bsr.put((byte)0xCC); bsr.put((byte)0xCD); bsr.put((byte)0xCE); bsr.put((byte)0xCF); bsr.put((byte)0xD0); - bsr.put((byte)0xD1); bsr.put((byte)0xD2); bsr.put((byte)0xD3); bsr.put((byte)0xD4); bsr.put((byte)0xD5); bsr.put((byte)0xD6); - bsr.put((byte)0xD7); bsr.put((byte)0xD8); bsr.put((byte)0xD9); bsr.put((byte)0xDA); bsr.put((byte)0xDB); bsr.put((byte)0xDC); - bsr.put((byte)0xDD); bsr.put((byte)0xDE); bsr.put((byte)0xDF); bsr.put((byte)0xE0); bsr.put((byte)0xE1); bsr.put((byte)0xE2); - bsr.put((byte)0xE3); bsr.put((byte)0xE4); bsr.put((byte)0xE5); bsr.put((byte)0xE6); bsr.put((byte)0xE7); bsr.put((byte)0xE8); - bsr.put((byte)0xEA); bsr.put((byte)0xE9); bsr.put((byte)0xF1); bsr.put((byte)0xF2); bsr.put((byte)0xF3); bsr.put((byte)0xF4); - bsr.put((byte)0xF5); bsr.put((byte)0xF6); bsr.put((byte)0xF7); bsr.put((byte)0xF8); bsr.put((byte)0xF9); bsr.put((byte)0xFA); - + bsr.put((byte)0xA7); bsr.put((byte)0xA8); bsr.put((byte)0xA9); bsr.put((byte)0xAA); bsr.put((byte)0xAB); bsr.put((byte)0xAC); + bsr.put((byte)0xAD); bsr.put((byte)0xAE); bsr.put((byte)0xAF); bsr.put((byte)0xB0); bsr.put((byte)0xB1); bsr.put((byte)0xB2); + bsr.put((byte)0xB3); bsr.put((byte)0xB4); bsr.put((byte)0xB5); bsr.put((byte)0xB6); bsr.put((byte)0xB7); bsr.put((byte)0xB8); + bsr.put((byte)0xB9); bsr.put((byte)0xBA); bsr.put((byte)0xBB); bsr.put((byte)0xBC); bsr.put((byte)0xBD); bsr.put((byte)0xBE); + bsr.put((byte)0xBF); bsr.put((byte)0xC0); bsr.put((byte)0xC1); bsr.put((byte)0xC2); bsr.put((byte)0xC3); bsr.put((byte)0xC4); + bsr.put((byte)0xC5); bsr.put((byte)0xC6); bsr.put((byte)0xC7); bsr.put((byte)0xC8); bsr.put((byte)0xC9); bsr.put((byte)0xCA); + bsr.put((byte)0xCB); bsr.put((byte)0xCC); bsr.put((byte)0xCD); bsr.put((byte)0xCE); bsr.put((byte)0xCF); bsr.put((byte)0xD0); + bsr.put((byte)0xD1); bsr.put((byte)0xD2); bsr.put((byte)0xD3); bsr.put((byte)0xD4); bsr.put((byte)0xD5); bsr.put((byte)0xD6); + bsr.put((byte)0xD7); bsr.put((byte)0xD8); bsr.put((byte)0xD9); bsr.put((byte)0xDA); bsr.put((byte)0xDB); bsr.put((byte)0xDC); + bsr.put((byte)0xDD); bsr.put((byte)0xDE); bsr.put((byte)0xDF); bsr.put((byte)0xE0); bsr.put((byte)0xE1); bsr.put((byte)0xE2); + bsr.put((byte)0xE3); bsr.put((byte)0xE4); bsr.put((byte)0xE5); bsr.put((byte)0xE6); bsr.put((byte)0xE7); bsr.put((byte)0xE8); + bsr.put((byte)0xEA); bsr.put((byte)0xE9); bsr.put((byte)0xF1); bsr.put((byte)0xF2); bsr.put((byte)0xF3); bsr.put((byte)0xF4); + bsr.put((byte)0xF5); bsr.put((byte)0xF6); bsr.put((byte)0xF7); bsr.put((byte)0xF8); bsr.put((byte)0xF9); bsr.put((byte)0xFA); + //test Soft Halant us.put((char)0x0915); us.put((char)0x094d); us.put((char)0x200D); bs.put((byte)0xB3); bs.put((byte)0xE8); bs.put((byte)0xE9); bsr.put((byte)0xB3); bsr.put((byte)0xE8); bsr.put((byte)0xE9); - + //test explicit halant us.put((char)0x0915); us.put((char)0x094D); us.put((char)0x200C); bs.put((byte)0xB3); bs.put((byte)0xE8); bs.put((byte)0xE8); bsr.put((byte)0xB3); bsr.put((byte)0xE8); bsr.put((byte)0xE8); - + //test double danda - us.put((char)0x0965); - bs.put((byte)0xEA); bs.put((byte)0xEA); - bsr.put((byte)0xEA); bsr.put((byte)0xEA); - + us.put((char)0x0965); + bs.put((byte)0xEA); bs.put((byte)0xEA); + bsr.put((byte)0xEA); bsr.put((byte)0xEA); + //test ASCII us.put((char)0x1B); us.put((char)0x24); us.put((char)0x29); us.put((char)0x47); us.put((char)0x0E); us.put((char)0x23); us.put((char)0x21); us.put((char)0x23); us.put((char)0x22); us.put((char)0x23); us.put((char)0x23); us.put((char)0x23); us.put((char)0x24); us.put((char)0x23); us.put((char)0x25); us.put((char)0x23); us.put((char)0x26); us.put((char)0x23); us.put((char)0x27); us.put((char)0x23); us.put((char)0x28); us.put((char)0x23); us.put((char)0x29); us.put((char)0x23); us.put((char)0x2A); us.put((char)0x23); us.put((char)0x2B); us.put((char)0x0F); us.put((char)0x2F); us.put((char)0x2A); - + bs.put((byte)0x1B); bs.put((byte)0x24); bs.put((byte)0x29); bs.put((byte)0x47); bs.put((byte)0x0E); bs.put((byte)0x23); bs.put((byte)0x21); bs.put((byte)0x23); bs.put((byte)0x22); bs.put((byte)0x23); bs.put((byte)0x23); bs.put((byte)0x23); bs.put((byte)0x24); bs.put((byte)0x23); bs.put((byte)0x25); bs.put((byte)0x23); bs.put((byte)0x26); bs.put((byte)0x23); bs.put((byte)0x27); bs.put((byte)0x23); bs.put((byte)0x28); bs.put((byte)0x23); bs.put((byte)0x29); bs.put((byte)0x23); bs.put((byte)0x2A); bs.put((byte)0x23); bs.put((byte)0x2B); bs.put((byte)0x0F); bs.put((byte)0x2F); bs.put((byte)0x2A); - + bsr.put((byte)0x1B); bsr.put((byte)0x24); bsr.put((byte)0x29); bsr.put((byte)0x47); bsr.put((byte)0x0E); bsr.put((byte)0x23); bsr.put((byte)0x21); bsr.put((byte)0x23); bsr.put((byte)0x22); bsr.put((byte)0x23); bsr.put((byte)0x23); bsr.put((byte)0x23); bsr.put((byte)0x24); bsr.put((byte)0x23); bsr.put((byte)0x25); bsr.put((byte)0x23); bsr.put((byte)0x26); bsr.put((byte)0x23); bsr.put((byte)0x27); bsr.put((byte)0x23); bsr.put((byte)0x28); bsr.put((byte)0x23); bsr.put((byte)0x29); bsr.put((byte)0x23); bsr.put((byte)0x2A); bsr.put((byte)0x23); bsr.put((byte)0x2B); bsr.put((byte)0x0F); bsr.put((byte)0x2F); bsr.put((byte)0x2A); - + //test from Lotus //Some of the Lotus ISCII code points have been changed or commented out. us.put((char)0x0061); us.put((char)0x0915); us.put((char)0x000D); us.put((char)0x000A); us.put((char)0x0996); us.put((char)0x0043); us.put((char)0x0930); us.put((char)0x094D); us.put((char)0x200D); us.put((char)0x0901); us.put((char)0x000D); us.put((char)0x000A); us.put((char)0x0905); us.put((char)0x0985); us.put((char)0x0043); us.put((char)0x0915); us.put((char)0x0921); us.put((char)0x002B); - us.put((char)0x095F); + us.put((char)0x095F); bs.put((byte)0x61); bs.put((byte)0xB3); - bs.put((byte)0x0D); bs.put((byte)0x0A); - bs.put((byte)0xEF); bs.put((byte)0x42); + bs.put((byte)0x0D); bs.put((byte)0x0A); + bs.put((byte)0xEF); bs.put((byte)0x42); bs.put((byte)0xEF); bs.put((byte)0x43); bs.put((byte)0xB4); bs.put((byte)0x43); bs.put((byte)0xEF); bs.put((byte)0x42); bs.put((byte)0xCF); bs.put((byte)0xE8); bs.put((byte)0xE9); bs.put((byte)0xA1); bs.put((byte)0x0D); bs.put((byte)0x0A); bs.put((byte)0xEF); bs.put((byte)0x42); bs.put((byte)0xA4); bs.put((byte)0xEF); bs.put((byte)0x43); bs.put((byte)0xA4); bs.put((byte)0x43); bs.put((byte)0xEF); @@ -3329,59 +3332,59 @@ public class TestCharset extends TestFmwk { bsr.put((byte)0x42); bsr.put((byte)0xB3); bsr.put((byte)0xBF); bsr.put((byte)0x2B); bsr.put((byte)0xEF); bsr.put((byte)0x42); bsr.put((byte)0xCE); //end of test from Lotus - + //tamil range us.put((char)0x0B86); us.put((char)0x0B87); us.put((char)0x0B88); bs.put((byte)0xEF); bs.put((byte)0x44); bs.put((byte)0xA5); bs.put((byte)0xA6); bs.put((byte)0xA7); bsr.put((byte)0xEF); bsr.put((byte)0x44); bsr.put((byte)0xA5); bsr.put((byte)0xA6); bsr.put((byte)0xA7); - + //telugu range us.put((char)0x0C05); us.put((char)0x0C02); us.put((char)0x0C03); us.put((char)0x0C31); bs.put((byte)0xEF); bs.put((byte)0x45); bs.put((byte)0xA4); bs.put((byte)0xA2); bs.put((byte)0xA3); bs.put((byte)0xD0); bsr.put((byte)0xEF); bsr.put((byte)0x45); bsr.put((byte)0xA4); bsr.put((byte)0xA2); bsr.put((byte)0xA3); bsr.put((byte)0xD0); - + //kannada range us.put((char)0x0C85); us.put((char)0x0C82); us.put((char)0x0C83); bs.put((byte)0xEF); bs.put((byte)0x48); bs.put((byte)0xA4); bs.put((byte)0xA2); bs.put((byte)0xA3); - bsr.put((byte)0xEF); bsr.put((byte)0x48); bsr.put((byte)0xA4); bsr.put((byte)0xA2); bsr.put((byte)0xA3); - + bsr.put((byte)0xEF); bsr.put((byte)0x48); bsr.put((byte)0xA4); bsr.put((byte)0xA2); bsr.put((byte)0xA3); + //test Abbr sign and Anudatta us.put((char)0x0970); us.put((char)0x0952); us.put((char)0x0960); us.put((char)0x0944); us.put((char)0x090C); us.put((char)0x0962); us.put((char)0x0961); us.put((char)0x0963); us.put((char)0x0950); us.put((char)0x093D); us.put((char)0x0958); us.put((char)0x0959); us.put((char)0x095A); us.put((char)0x095B); us.put((char)0x095C); us.put((char)0x095D); us.put((char)0x095E); us.put((char)0x0020); - us.put((char)0x094D); us.put((char)0x0930); us.put((char)0x0000); us.put((char)0x00A0); + us.put((char)0x094D); us.put((char)0x0930); us.put((char)0x0000); us.put((char)0x00A0); bs.put((byte)0xEF); bs.put((byte)0x42); bs.put((byte)0xF0); bs.put((byte)0xBF); bs.put((byte)0xF0); bs.put((byte)0xB8); bs.put((byte)0xAA); bs.put((byte)0xE9); bs.put((byte)0xDF); bs.put((byte)0xE9); bs.put((byte)0xA6); bs.put((byte)0xE9); bs.put((byte)0xDB); bs.put((byte)0xE9); bs.put((byte)0xA7); bs.put((byte)0xE9); bs.put((byte)0xDC); bs.put((byte)0xE9); bs.put((byte)0xA1); bs.put((byte)0xE9); bs.put((byte)0xEA); bs.put((byte)0xE9); bs.put((byte)0xB3); bs.put((byte)0xE9); bs.put((byte)0xB4); bs.put((byte)0xE9); bs.put((byte)0xB5); bs.put((byte)0xE9); bs.put((byte)0xBA); bs.put((byte)0xE9); bs.put((byte)0xBF); bs.put((byte)0xE9); bs.put((byte)0xC0); bs.put((byte)0xE9); bs.put((byte)0xC9); bs.put((byte)0xE9); - bs.put((byte)0x20); bs.put((byte)0xE8); bs.put((byte)0xCF); bs.put((byte)0x00); bs.put((byte)0xA0); - //bs.put((byte)0xEF); bs.put((byte)0x30); + bs.put((byte)0x20); bs.put((byte)0xE8); bs.put((byte)0xCF); bs.put((byte)0x00); bs.put((byte)0xA0); + //bs.put((byte)0xEF); bs.put((byte)0x30); bsr.put((byte)0xEF); bsr.put((byte)0x42); bsr.put((byte)0xF0); bsr.put((byte)0xBF); bsr.put((byte)0xF0); bsr.put((byte)0xB8); bsr.put((byte)0xAA); bsr.put((byte)0xE9); bsr.put((byte)0xDF); bsr.put((byte)0xE9); bsr.put((byte)0xA6); bsr.put((byte)0xE9); bsr.put((byte)0xDB); bsr.put((byte)0xE9); bsr.put((byte)0xA7); bsr.put((byte)0xE9); bsr.put((byte)0xDC); bsr.put((byte)0xE9); bsr.put((byte)0xA1); bsr.put((byte)0xE9); bsr.put((byte)0xEA); bsr.put((byte)0xE9); bsr.put((byte)0xB3); bsr.put((byte)0xE9); bsr.put((byte)0xB4); bsr.put((byte)0xE9); bsr.put((byte)0xB5); bsr.put((byte)0xE9); bsr.put((byte)0xBA); bsr.put((byte)0xE9); bsr.put((byte)0xBF); bsr.put((byte)0xE9); bsr.put((byte)0xC0); bsr.put((byte)0xE9); bsr.put((byte)0xC9); bsr.put((byte)0xE9); - bsr.put((byte)0xD9); bsr.put((byte)0xE8); bsr.put((byte)0xCF); bsr.put((byte)0x00); bsr.put((byte)0xA0); - + bsr.put((byte)0xD9); bsr.put((byte)0xE8); bsr.put((byte)0xCF); bsr.put((byte)0x00); bsr.put((byte)0xA0); + bs.limit(bs.position()); bs.position(0); us.limit(us.position()); us.position(0); bsr.limit(bsr.position()); bsr.position(0); - + //round trip test try { smBufDecode(decoder, "ISCII-part1", bsr, us, false, true); - smBufEncode(encoder, "ISCII-part2", us, bs); + smBufEncode(encoder, "ISCII-part2", us, bs); smBufDecode(decoder, "ISCII-part3", bs, us, false, true); } catch (Exception ex) { errln("ISCII round trip test failed."); } - + //Test new characters in the ISCII charset encoder = provider.charsetForName("ISCII,version=0").newEncoder(); decoder = provider.charsetForName("ISCII,version=0").newDecoder(); @@ -3398,191 +3401,191 @@ public class TestCharset extends TestFmwk { bs = ByteBuffer.allocate(b_pts.length); us.put(u_pts); bs.put(b_pts); - + bs.limit(bs.position()); bs.position(0); us.limit(us.position()); us.position(0); - + try { - smBufDecode(decoder, "ISCII-update", bs, us, true, true); + smBufDecode(decoder, "ISCII-update", bs, us, true, true); bs.position(0); us.position(0); smBufEncode(encoder, "ISCII-update", us, bs, true, true); } catch (Exception ex) { errln("Error occurred while encoding/decoding ISCII with the new characters."); } - + //The rest of the code in this method is to provide better code coverage CharBuffer ccus = CharBuffer.allocate(0x10); ByteBuffer ccbs = ByteBuffer.allocate(0x10); - + //start of charset decoder code coverage code //test overflow buffer ccbs.put((byte)0x49); - + ccbs.limit(ccbs.position()); ccbs.position(0); ccus.limit(0); ccus.position(0); - + try { smBufDecode(decoder, "ISCII-CC-DE-1", ccbs, ccus, true, false); errln("Exception while decoding ISCII should have been thrown."); } catch (Exception ex) { } - + ccbs.clear(); ccus.clear(); - + //test atr overflow buffer ccbs.put((byte)0xEF); ccbs.put((byte)0x40); ccbs.put((byte)0xEF); ccbs.put((byte)0x20); ccus.put((char)0x00); - + ccbs.limit(ccbs.position()); ccbs.position(0); ccus.limit(ccus.position()); ccus.position(0); - + try { smBufDecode(decoder, "ISCII-CC-DE-2", ccbs, ccus, true, false); errln("Exception while decoding ISCII should have been thrown."); } catch (Exception ex) { } - + //end of charset decoder code coverage code - + ccbs.clear(); ccus.clear(); - + //start of charset encoder code coverage code //test ascii overflow buffer ccus.put((char)0x41); - + ccus.limit(ccus.position()); ccus.position(0); ccbs.limit(0); ccbs.position(0); - + try { smBufEncode(encoder, "ISCII-CC-EN-1", ccus, ccbs, true, false); errln("Exception while encoding ISCII should have been thrown."); } catch (Exception ex) { } - + ccbs.clear(); ccus.clear(); - + //test ascii overflow buffer ccus.put((char)0x0A); ccus.put((char)0x0043); ccbs.put((byte)0x00); ccbs.put((byte)0x00); - + ccus.limit(ccus.position()); ccus.position(0); ccbs.limit(ccbs.position()); ccbs.position(0); - + try { smBufEncode(encoder, "ISCII-CC-EN-2", ccus, ccbs, true, false); errln("Exception while encoding ISCII should have been thrown."); } catch (Exception ex) { } - + ccbs.clear(); ccus.clear(); - + //test surrogate malform ccus.put((char)0x06E3); ccbs.put((byte)0x00); - + ccus.limit(ccus.position()); ccus.position(0); ccbs.limit(ccbs.position()); ccbs.position(0); - + try { smBufEncode(encoder, "ISCII-CC-EN-3", ccus, ccbs, true, false); errln("Exception while encoding ISCII should have been thrown."); } catch (Exception ex) { } - + ccbs.clear(); ccus.clear(); - + //test surrogate malform ccus.put((char)0xD801); ccus.put((char)0xDD01); ccbs.put((byte)0x00); - + ccus.limit(ccus.position()); ccus.position(0); ccbs.limit(ccbs.position()); ccbs.position(0); - + try { smBufEncode(encoder, "ISCII-CC-EN-4", ccus, ccbs, true, false); errln("Exception while encoding ISCII should have been thrown."); } catch (Exception ex) { } - + ccbs.clear(); ccus.clear(); - + //test trail surrogate malform - ccus.put((char)0xDD01); + ccus.put((char)0xDD01); ccbs.put((byte)0x00); - + ccus.limit(ccus.position()); ccus.position(0); ccbs.limit(ccbs.position()); ccbs.position(0); - + try { smBufEncode(encoder, "ISCII-CC-EN-5", ccus, ccbs, true, false); errln("Exception while encoding ISCII should have been thrown."); } catch (Exception ex) { } - + ccbs.clear(); ccus.clear(); - + //test lead surrogates malform - ccus.put((char)0xD801); ccus.put((char)0xD802); + ccus.put((char)0xD801); ccus.put((char)0xD802); ccbs.put((byte)0x00); - + ccus.limit(ccus.position()); ccus.position(0); ccbs.limit(ccbs.position()); ccbs.position(0); - + try { smBufEncode(encoder, "ISCII-CC-EN-6", ccus, ccbs, true, false); errln("Exception while encoding ISCII should have been thrown."); } catch (Exception ex) { } - + ccus.clear(); ccbs.clear(); - + //test overflow buffer - ccus.put((char)0x0901); + ccus.put((char)0x0901); ccbs.put((byte)0x00); - + ccus.limit(ccus.position()); ccus.position(0); ccbs.limit(ccbs.position()); ccbs.position(0); - + cs = provider.charsetForName("ISCII,version=0"); encoder = cs.newEncoder(); - + try { smBufEncode(encoder, "ISCII-CC-EN-7", ccus, ccbs, true, false); errln("Exception while encoding ISCII should have been thrown."); @@ -3591,24 +3594,24 @@ public class TestCharset extends TestFmwk { } //end of charset encoder code coverage code } - + //Test for the IMAP Charset @Test public void TestCharsetIMAP() { CharsetProvider provider = new CharsetProviderICU(); - Charset cs = provider.charsetForName("IMAP-mailbox-name"); + Charset cs = provider.charsetForName("IMAP-mailbox-name"); CharsetEncoder encoder = cs.newEncoder(); CharsetDecoder decoder = cs.newDecoder(); - + CharBuffer us = CharBuffer.allocate(0x20); ByteBuffer bs = ByteBuffer.allocate(0x20); - + us.put((char)0x00A3); us.put((char)0x2020); us.put((char)0x41); - + bs.put((byte)0x26); bs.put((byte)0x41); bs.put((byte)0x4B); bs.put((byte)0x4D); bs.put((byte)0x67); bs.put((byte)0x49); bs.put((byte)0x41); bs.put((byte)0x2D); bs.put((byte)0x41); - - + + bs.limit(bs.position()); bs.position(0); us.limit(us.position()); @@ -3616,350 +3619,350 @@ public class TestCharset extends TestFmwk { smBufDecode(decoder, "IMAP", bs, us); smBufEncode(encoder, "IMAP", us, bs); - + //the rest of the code in this method is for better code coverage us.clear(); bs.clear(); - + //start of charset encoder code coverage //test buffer overflow - us.put((char)0x0026); us.put((char)0x17A9); + us.put((char)0x0026); us.put((char)0x17A9); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); - + bs.limit(bs.position()); bs.position(0); us.limit(us.position()); us.position(0); - + try { smBufEncode(encoder, "IMAP-EN-1", us, bs, true, false); errln("Exception while encoding IMAP (1) should have been thrown."); } catch(Exception ex) { } - + us.clear(); bs.clear(); - + //test buffer overflow us.put((char)0x17A9); us.put((char)0x0941); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); - + bs.limit(bs.position()); bs.position(0); us.limit(us.position()); us.position(0); - + try { smBufEncode(encoder, "IMAP-EN-2", us, bs, true, false); errln("Exception while encoding IMAP (2) should have been thrown."); } catch(Exception ex) { } - + us.clear(); bs.clear(); - + //test buffer overflow us.put((char)0x17A9); us.put((char)0x0941); - bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); - + bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); + bs.limit(bs.position()); bs.position(0); us.limit(us.position()); us.position(0); - + try { smBufEncode(encoder, "IMAP-EN-3", us, bs, true, false); errln("Exception while encoding IMAP (3) should have been thrown."); } catch(Exception ex) { } - + us.clear(); bs.clear(); - + //test buffer overflow us.put((char)0x17A9); us.put((char)0x0941); us.put((char)0x0955); - bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); + bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); - + bs.limit(bs.position()); bs.position(0); us.limit(us.position()); us.position(0); - + try { smBufEncode(encoder, "IMAP-EN-4", us, bs, true, false); errln("Exception while encoding IMAP (4) should have been thrown."); } catch(Exception ex) { } - + us.clear(); bs.clear(); - + //test buffer overflow us.put((char)0x17A9); us.put((char)0x0941); us.put((char)0x0955); - bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); - bs.put((byte)0x00); bs.put((byte)0x00); - + bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); + bs.put((byte)0x00); bs.put((byte)0x00); + bs.limit(bs.position()); bs.position(0); us.limit(us.position()); us.position(0); - + try { smBufEncode(encoder, "IMAP-EN-5", us, bs, true, false); errln("Exception while encoding IMAP (5) should have been thrown."); } catch(Exception ex) { } - + us.clear(); bs.clear(); - + //test buffer overflow us.put((char)0x17A9); us.put((char)0x0941); us.put((char)0x0955); us.put((char)0x0970); - bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); + bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); - + bs.limit(bs.position()); bs.position(0); us.limit(us.position()); us.position(0); - + try { smBufEncode(encoder, "IMAP-EN-6", us, bs, true, false); errln("Exception while encoding IMAP (6) should have been thrown."); } catch(Exception ex) { } - + us.clear(); bs.clear(); - + //test buffer overflow us.put((char)0x17A9); us.put((char)0x0941); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); - bs.put((byte)0x00); - + bs.put((byte)0x00); + bs.limit(bs.position()); bs.position(0); us.limit(us.position()); us.position(0); - + try { smBufEncode(encoder, "IMAP-EN-7", us, bs, true, true); errln("Exception while encoding IMAP (7) should have been thrown."); } catch(Exception ex) { } - + us.clear(); bs.clear(); - + //test flushing - us.put((char)0x17A9); us.put((char)0x0941); + us.put((char)0x17A9); us.put((char)0x0941); bs.put((byte)0x26); bs.put((byte)0x46); bs.put((byte)0x36); bs.put((byte)0x6b); bs.put((byte)0x4a); bs.put((byte)0x51); bs.put((byte)0x51); bs.put((byte)0x2d); - + bs.limit(bs.position()); bs.position(0); us.limit(us.position()); us.position(0); - + try { smBufEncode(encoder, "IMAP-EN-8", us, bs, true, true); } catch(Exception ex) { errln("Exception while encoding IMAP (8) should not have been thrown."); } - + us = CharBuffer.allocate(0x08); bs = ByteBuffer.allocate(0x08); - + //test flushing buffer overflow us.put((char)0x0061); bs.put((byte)0x61); bs.put((byte)0x00); - + bs.limit(bs.position()); bs.position(0); us.limit(us.position()); us.position(0); - + try { smBufEncode(encoder, "IMAP-EN-9", us, bs, true, true); } catch(Exception ex) { errln("Exception while encoding IMAP (9) should not have been thrown."); } //end of charset encoder code coverage - + us = CharBuffer.allocate(0x10); bs = ByteBuffer.allocate(0x10); - + //start of charset decoder code coverage //test malform case 2 - us.put((char)0x0000); us.put((char)0x0000); - bs.put((byte)0x26); bs.put((byte)0x41); bs.put((byte)0x43); bs.put((byte)0x41); - + us.put((char)0x0000); us.put((char)0x0000); + bs.put((byte)0x26); bs.put((byte)0x41); bs.put((byte)0x43); bs.put((byte)0x41); + bs.limit(bs.position()); bs.position(0); us.limit(us.position()); us.position(0); - + try { smBufDecode(decoder, "IMAP-DE-1", bs, us, true, false); errln("Exception while decoding IMAP (1) should have been thrown."); } catch(Exception ex) { } - + us.clear(); bs.clear(); - + //test malform case 5 us.put((char)0x0000); us.put((char)0x0000); us.put((char)0x0000); - bs.put((byte)0x26); bs.put((byte)0x41); bs.put((byte)0x41); bs.put((byte)0x41); - bs.put((byte)0x41); bs.put((byte)0x49); bs.put((byte)0x41); - + bs.put((byte)0x26); bs.put((byte)0x41); bs.put((byte)0x41); bs.put((byte)0x41); + bs.put((byte)0x41); bs.put((byte)0x49); bs.put((byte)0x41); + bs.limit(bs.position()); bs.position(0); us.limit(us.position()); us.position(0); - + try { smBufDecode(decoder, "IMAP-DE-2", bs, us, true, false); errln("Exception while decoding IMAP (2) should have been thrown."); } catch(Exception ex) { } - + us.clear(); bs.clear(); - + //test malform case 7 us.put((char)0x0000); us.put((char)0x0000); us.put((char)0x0000); us.put((char)0x0000); - bs.put((byte)0x26); bs.put((byte)0x41); bs.put((byte)0x41); bs.put((byte)0x41); - bs.put((byte)0x41); bs.put((byte)0x41); bs.put((byte)0x41); bs.put((byte)0x42); - bs.put((byte)0x41); - + bs.put((byte)0x26); bs.put((byte)0x41); bs.put((byte)0x41); bs.put((byte)0x41); + bs.put((byte)0x41); bs.put((byte)0x41); bs.put((byte)0x41); bs.put((byte)0x42); + bs.put((byte)0x41); + bs.limit(bs.position()); bs.position(0); us.limit(us.position()); us.position(0); - + try { smBufDecode(decoder, "IMAP-DE-3", bs, us, true, false); errln("Exception while decoding IMAP (3) should have been thrown."); } catch(Exception ex) { } - //end of charset decoder coder coverage + //end of charset decoder coder coverage } - + //Test for charset UTF32LE to provide better code coverage @Test public void TestCharsetUTF32LE() { CoderResult result = CoderResult.UNDERFLOW; CharsetProvider provider = new CharsetProviderICU(); - Charset cs = provider.charsetForName("UTF-32LE"); + Charset cs = provider.charsetForName("UTF-32LE"); CharsetEncoder encoder = cs.newEncoder(); //CharsetDecoder decoder = cs.newDecoder(); - + CharBuffer us = CharBuffer.allocate(0x10); ByteBuffer bs = ByteBuffer.allocate(0x10); - - + + //test malform surrogate us.put((char)0xD901); bs.put((byte)0x00); - + bs.limit(bs.position()); bs.position(0); us.limit(us.position()); us.position(0); - + try { smBufEncode(encoder, "UTF32LE-EN-1", us, bs, true, false); errln("Exception while encoding UTF32LE (1) should have been thrown."); } catch (Exception ex) { } - + bs.clear(); us.clear(); - + //test malform surrogate us.put((char)0xD901); us.put((char)0xD902); bs.put((byte)0x00); - + bs.limit(bs.position()); bs.position(0); us.limit(us.position()); us.position(0); - + result = encoder.encode(us, bs, true); - + if (!result.isError() && !result.isOverflow()) { errln("Error while encoding UTF32LE (2) should have occurred."); } - + bs.clear(); us.clear(); - + //test overflow trail surrogate us.put((char)0xDD01); us.put((char)0xDD0E); us.put((char)0xDD0E); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); - bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); - + bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); + bs.limit(bs.position()); bs.position(0); us.limit(us.position()); us.position(0); - + result = encoder.encode(us, bs, true); - + if (!result.isError() && !result.isOverflow()) { errln("Error while encoding UTF32LE (3) should have occurred."); } - + bs.clear(); us.clear(); - + //test malform lead surrogate us.put((char)0xD90D); us.put((char)0xD90E); - bs.put((byte)0x00); - + bs.put((byte)0x00); + bs.limit(bs.position()); bs.position(0); us.limit(us.position()); us.position(0); - + try { smBufEncode(encoder, "UTF32LE-EN-4", us, bs, true, false); errln("Exception while encoding UTF32LE (4) should have been thrown."); } catch (Exception ex) { } - + bs.clear(); us.clear(); - + //test overflow buffer us.put((char)0x0061); - bs.put((byte)0x00); - + bs.put((byte)0x00); + bs.limit(bs.position()); bs.position(0); us.limit(us.position()); us.position(0); - + try { smBufEncode(encoder, "UTF32LE-EN-5", us, bs, true, false); errln("Exception while encoding UTF32LE (5) should have been thrown."); } catch (Exception ex) { } - + bs.clear(); us.clear(); - + //test malform trail surrogate us.put((char)0xDD01); - bs.put((byte)0x00); - + bs.put((byte)0x00); + bs.limit(bs.position()); bs.position(0); us.limit(us.position()); us.position(0); - + try { smBufEncode(encoder, "UTF32LE-EN-6", us, bs, true, false); errln("Exception while encoding UTF32LE (6) should have been thrown."); @@ -3972,163 +3975,163 @@ public class TestCharset extends TestFmwk { public void TestCharsetUTF16LE() { CoderResult result = CoderResult.UNDERFLOW; CharsetProvider provider = new CharsetProviderICU(); - Charset cs = provider.charsetForName("UTF-16LE"); + Charset cs = provider.charsetForName("UTF-16LE"); CharsetEncoder encoder = cs.newEncoder(); //CharsetDecoder decoder = cs.newDecoder(); - + // Test for malform and change fromUChar32 for next call char u_pts1[] = { - (char)0xD805, + (char)0xD805, (char)0xDC01, (char)0xDC02, (char)0xDC03, (char)0xD901, (char)0xD902 }; byte b_pts1[] = { - (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00 }; - + CharBuffer us = CharBuffer.allocate(u_pts1.length); ByteBuffer bs = ByteBuffer.allocate(b_pts1.length); - + us.put(u_pts1); bs.put(b_pts1); - + us.limit(1); us.position(0); bs.limit(1); bs.position(0); - + result = encoder.encode(us, bs, true); - + if (!result.isMalformed()) { - // LE should not output BOM, so this should be malformed + // LE should not output BOM, so this should be malformed errln("Malformed while encoding UTF-16LE (1) should have occured."); } - + // Test for malform surrogate from previous buffer us.limit(4); us.position(1); bs.limit(7); bs.position(1); - + result = encoder.encode(us, bs, true); - + if (!result.isMalformed()) { errln("Error while encoding UTF-16LE (2) should have occured."); - } - + } + // Test for malform trail surrogate encoder.reset(); - + us.limit(1); us.position(0); bs.limit(1); bs.position(0); - - result = encoder.encode(us, bs, true); - + + result = encoder.encode(us, bs, true); + us.limit(6); us.position(4); bs.limit(4); bs.position(1); - + result = encoder.encode(us, bs, true); - + if (!result.isMalformed()) { errln("Error while encoding UTF-16LE (3) should have occured."); - } + } } - + //provide better code coverage for the generic charset UTF32 @Test public void TestCharsetUTF32() { CoderResult result = CoderResult.UNDERFLOW; CharsetProvider provider = new CharsetProviderICU(); - Charset cs = provider.charsetForName("UTF-32"); + Charset cs = provider.charsetForName("UTF-32"); CharsetDecoder decoder = cs.newDecoder(); CharsetEncoder encoder = cs.newEncoder(); - + //start of decoding code coverage char us_array[] = { 0x0000, 0x0000, 0x0000, 0x0000, }; - + byte bs_array1[] = { (byte)0x00, (byte)0x00, (byte)0xFE, (byte)0xFF, (byte)0x00, (byte)0x00, (byte)0x04, (byte)0x43, (byte)0xFF, (byte)0xFE, (byte)0x00, (byte)0x00, (byte)0x43, (byte)0x04, (byte)0x00, (byte)0x00, }; - + byte bs_array2[] = { (byte)0xFF, (byte)0xFE, (byte)0x00, (byte)0x00, (byte)0x43, (byte)0x04, (byte)0x00, (byte)0x00, }; - + CharBuffer us = CharBuffer.allocate(us_array.length); ByteBuffer bs = ByteBuffer.allocate(bs_array1.length); - + us.put(us_array); bs.put(bs_array1); - + us.limit(us.position()); us.position(0); bs.limit(bs.position()); bs.position(0); - + try { smBufDecode(decoder, "UTF32-DE-1", bs, us, true, false); errln("Malform exception while decoding UTF32 charset (1) should have been thrown."); } catch (Exception ex) { } - + decoder = cs.newDecoder(); - + bs = ByteBuffer.allocate(bs_array2.length); bs.put(bs_array2); - + us.limit(4); us.position(0); bs.limit(bs.position()); bs.position(0); - + try { smBufDecode(decoder, "UTF32-DE-2", bs, us, true, false); } catch (Exception ex) { // should recognize little endian BOM errln("Exception while decoding UTF32 charset (2) should not have been thrown."); } - + //Test malform exception bs.clear(); us.clear(); - + bs.put((byte)0x00); bs.put((byte)0xFE); bs.put((byte)0xFF); bs.put((byte)0x00); bs.put((byte)0x00); us.put((char)0x0000); - + us.limit(us.position()); us.position(0); bs.limit(bs.position()); bs.position(0); - + try { smBufDecode(decoder, "UTF32-DE-3", bs, us, true, false); errln("Malform exception while decoding UTF32 charset (3) should have been thrown."); } catch (Exception ex) { } - + //Test BOM testing bs.clear(); us.clear(); - - bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0xFF); bs.put((byte)0xFE); + + bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0xFF); bs.put((byte)0xFE); us.put((char)0x0000); - + us.limit(us.position()); us.position(0); bs.limit(bs.position()); bs.position(0); - + try { smBufDecode(decoder, "UTF32-DE-4", bs, us, true, false); } catch (Exception ex) { @@ -4136,134 +4139,134 @@ public class TestCharset extends TestFmwk { errln("Exception while decoding UTF32 charset (4) should not have been thrown."); } //end of decoding code coverage - + //start of encoding code coverage us = CharBuffer.allocate(0x10); bs = ByteBuffer.allocate(0x10); - + //test wite BOM overflow error us.put((char)0xDC01); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); - + us.limit(us.position()); us.position(0); bs.limit(bs.position()); bs.position(0); - + result = encoder.encode(us, bs, true); // must try to output BOM first for UTF-32 (not UTF-32BE or UTF-32LE) if (!result.isOverflow()) { - errln("Buffer overflow error while encoding UTF32 charset (1) should have occurred."); + errln("Buffer overflow error while encoding UTF32 charset (1) should have occurred."); } - + us.clear(); bs.clear(); - + //test malform surrogate and store value in fromChar32 us.put((char)0xD801); us.put((char)0xD802); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); - + us.limit(us.position()); us.position(0); bs.limit(bs.position()); bs.position(0); - + result = encoder.encode(us, bs, true); if (!result.isMalformed()) { errln("Malformed error while encoding UTF32 charset (2) should have occurred."); - } - + } + us.clear(); bs.clear(); - + //test malform surrogate us.put((char)0x0000); us.put((char)0xD902); - + us.limit(us.position()); us.position(0); bs.limit(bs.position()); bs.position(0); - + result = encoder.encode(us, bs, true); if (!result.isOverflow()) { errln("Overflow error while encoding UTF32 charset (3) should have occurred."); - } - + } + us.clear(); bs.clear(); - + //test malform surrogate encoder.reset(); us.put((char)0xD801); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); - + us.limit(us.position()); us.position(0); bs.limit(bs.position()); bs.position(0); - + result = encoder.encode(us, bs, true); if (!result.isMalformed()) { errln("Malform error while encoding UTF32 charset (4) should have occurred."); - } - + } + us.clear(); bs.clear(); - + //test overflow surrogate us.put((char)0x0000); us.put((char)0xDDE1); us.put((char)0xD915); us.put((char)0xDDF2); - bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); - + bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); + us.limit(us.position()); us.position(0); bs.limit(bs.position()); bs.position(0); - + result = encoder.encode(us, bs, true); if (!result.isOverflow()) { errln("Overflow error while encoding UTF32 charset (5) should have occurred."); - } - + } + us.clear(); bs.clear(); - + //test malform surrogate encoder.reset(); us.put((char)0xDDE1); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); - + us.limit(us.position()); us.position(0); bs.limit(bs.position()); bs.position(0); - + result = encoder.encode(us, bs, true); if (!result.isMalformed()) { errln("Malform error while encoding UTF32 charset (6) should have occurred."); - } + } //end of encoding code coverage } - + //this method provides better code coverage decoding UTF32 LE/BE @Test public void TestDecodeUTF32LEBE() { CoderResult result = CoderResult.UNDERFLOW; - CharsetProvider provider = new CharsetProviderICU(); + CharsetProvider provider = new CharsetProviderICU(); CharsetDecoder decoder; CharBuffer us = CharBuffer.allocate(0x10); ByteBuffer bs = ByteBuffer.allocate(0x10); - + //decode UTF32LE decoder = provider.charsetForName("UTF-32LE").newDecoder(); //test overflow buffer bs.put((byte)0x41); bs.put((byte)0xFF); bs.put((byte)0x01); bs.put((byte)0x00); us.put((char)0x0000); - + us.limit(us.position()); us.position(0); bs.limit(bs.position()); bs.position(0); - + try { smBufDecode(decoder, "UTF-32LE", bs, us, true, false); errln("Overflow exception while decoding UTF32LE (1) should have been thrown."); @@ -4282,165 +4285,165 @@ public class TestCharset extends TestFmwk { } else { errln("Overflow buffer error while decoding UTF32LE should have occurred."); } - + us.clear(); bs.clear(); //test malform buffer bs.put((byte)0x02); bs.put((byte)0xD9); bs.put((byte)0x00); bs.put((byte)0x00); us.put((char)0x0000); - + us.limit(us.position()); us.position(0); bs.limit(bs.position()); bs.position(0); - + try { smBufDecode(decoder, "UTF-32LE", bs, us, true, false); errln("Malform exception while decoding UTF32LE (2) should have been thrown."); } catch (Exception ex) { } - + us.clear(); bs.clear(); //test malform buffer bs.put((byte)0xFF); bs.put((byte)0xFE); bs.put((byte)0x00); bs.put((byte)0x00); - bs.put((byte)0xFF); bs.put((byte)0xDF); bs.put((byte)0x10); + bs.put((byte)0xFF); bs.put((byte)0xDF); bs.put((byte)0x10); us.put((char)0x0000); - + us.limit(us.position()); us.position(0); bs.limit(bs.position()); bs.position(0); - + try { // must flush in order to exhibit malformed behavior smBufDecode(decoder, "UTF-32LE", bs, us, true, true); errln("Malform exception while decoding UTF32LE (3) should have been thrown."); } catch (Exception ex) { } - + us.clear(); bs.clear(); //test malform buffer bs.put((byte)0xFF); bs.put((byte)0xFE); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x02); bs.put((byte)0xD9); bs.put((byte)0x00); bs.put((byte)0x00); us.put((char)0x0000); - + us.limit(us.position()); us.position(0); bs.limit(bs.position()); bs.position(0); - + try { smBufDecode(decoder, "UTF-32LE", bs, us, true, false); errln("Malform exception while decoding UTF32LE (4) should have been thrown."); } catch (Exception ex) { } - + us.clear(); bs.clear(); //test overflow buffer bs.put((byte)0xFF); bs.put((byte)0xFE); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0xDD); bs.put((byte)0xFF); bs.put((byte)0x10); bs.put((byte)0x00); us.put((char)0x0000); - + us.limit(us.position()); us.position(0); bs.limit(bs.position()); bs.position(0); - + try { smBufDecode(decoder, "UTF-32LE", bs, us, true, false); errln("Overflow exception while decoding UTF32LE (5) should have been thrown."); } catch (Exception ex) { } //end of decode UTF32LE - + bs.clear(); us.clear(); - + //decode UTF32BE decoder = provider.charsetForName("UTF-32BE").newDecoder(); //test overflow buffer bs.put((byte)0x00); bs.put((byte)0x01); bs.put((byte)0xFF); bs.put((byte)0x41); us.put((char)0x0000); - + us.limit(us.position()); us.position(0); bs.limit(bs.position()); bs.position(0); - + try { smBufDecode(decoder, "UTF-32BE", bs, us, true, false); errln("Overflow exception while decoding UTF32BE (1) should have been thrown."); } catch (Exception ex) { } - + bs.clear(); us.clear(); //test malform buffer bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0xD9); bs.put((byte)0x02); us.put((char)0x0000); - + us.limit(us.position()); us.position(0); bs.limit(bs.position()); bs.position(0); - + try { smBufDecode(decoder, "UTF-32BE", bs, us, true, false); errln("Malform exception while decoding UTF32BE (2) should have been thrown."); } catch (Exception ex) { } - + bs.clear(); us.clear(); //test malform buffer bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0xFE); bs.put((byte)0xFF); bs.put((byte)0x10); bs.put((byte)0xFF); bs.put((byte)0xDF); us.put((char)0x0000); - + us.limit(us.position()); us.position(0); bs.limit(bs.position()); bs.position(0); - + try { // must flush to exhibit malformed behavior smBufDecode(decoder, "UTF-32BE", bs, us, true, true); errln("Malform exception while decoding UTF32BE (3) should have been thrown."); } catch (Exception ex) { } - + bs.clear(); us.clear(); //test overflow buffer bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0xFE); bs.put((byte)0xFF); bs.put((byte)0x00); bs.put((byte)0x10); bs.put((byte)0xFF); bs.put((byte)0xDD); us.put((char)0x0000); - + us.limit(us.position()); us.position(0); bs.limit(bs.position()); bs.position(0); - + try { smBufDecode(decoder, "UTF-32BE", bs, us, true, false); errln("Overflow exception while decoding UTF32BE (4) should have been thrown."); } catch (Exception ex) { } - + bs.clear(); us.clear(); //test malform buffer - bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0xFE); + bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0xFE); us.put((char)0x0000); - + us.limit(us.position()); us.position(0); bs.limit(bs.position()); bs.position(0); - + try { // must flush to exhibit malformed behavior smBufDecode(decoder, "UTF-32BE", bs, us, true, true); @@ -4449,60 +4452,60 @@ public class TestCharset extends TestFmwk { } //end of decode UTF32BE } - + //provide better code coverage for UTF8 @Test public void TestCharsetUTF8() { CoderResult result = CoderResult.UNDERFLOW; - CharsetProvider provider = new CharsetProviderICU(); + CharsetProvider provider = new CharsetProviderICU(); CharsetDecoder decoder = provider.charsetForName("UTF-8").newDecoder(); CharsetEncoder encoder = provider.charsetForName("UTF-8").newEncoder(); - + CharBuffer us = CharBuffer.allocate(0x10); ByteBuffer bs = ByteBuffer.allocate(0x10); ByteBuffer bs2; CharBuffer us2; int limit_us; int limit_bs; - + //encode and decode using read only buffer encoder.reset(); decoder.reset(); us.put((char)0x0041); us.put((char)0x0081); us.put((char)0xEF65); us.put((char)0xD902); bs.put((byte)0x41); bs.put((byte)0xc2); bs.put((byte)0x81); bs.put((byte)0xee); bs.put((byte)0xbd); bs.put((byte)0xa5); - bs.put((byte)0x00); + bs.put((byte)0x00); limit_us = us.position(); limit_bs = bs.position(); - + us.limit(limit_us); us.position(0); bs.limit(limit_bs); bs.position(0); bs2 = bs.asReadOnlyBuffer(); us2 = us.asReadOnlyBuffer(); - + result = decoder.decode(bs2, us, true); if (!result.isUnderflow() || !equals(us, us2)) { errln("Error while decoding UTF-8 (1) should not have occured."); } - + us2.limit(limit_us); us2.position(0); bs.limit(limit_bs); bs.position(0); - - result = encoder.encode(us2, bs, true); + + result = encoder.encode(us2, bs, true); if (!result.isUnderflow() || !equals(bs, bs2)) { errln("Error while encoding UTF-8 (1) should not have occured."); - } - + } + us.clear(); bs.clear(); - + //test overflow buffer while encoding //readonly buffer encoder.reset(); - us.put((char)0x0081); us.put((char)0xEF65); + us.put((char)0x0081); us.put((char)0xEF65); bs.put((byte)0x00); bs.put((byte)0x00); bs.put((byte)0x00); limit_us = us.position(); us2 = us.asReadOnlyBuffer(); @@ -4514,9 +4517,9 @@ public class TestCharset extends TestFmwk { if (!result.isOverflow()) { errln("Overflow Error should have occured while encoding UTF-8 (2)."); } - + encoder.reset(); - + us2.limit(limit_us); us2.position(1); bs.limit(1); @@ -4525,9 +4528,9 @@ public class TestCharset extends TestFmwk { if (!result.isOverflow()) { errln("Overflow Error should have occured while encoding UTF-8 (3)."); } - + encoder.reset(); - + us2.limit(limit_us); us2.position(1); bs.limit(2); @@ -4536,9 +4539,9 @@ public class TestCharset extends TestFmwk { if (!result.isOverflow()) { errln("Overflow Error should have occured while encoding UTF-8 (4)."); } - + encoder.reset(); - + us2.limit(limit_us); us2.position(0); bs.limit(2); @@ -4546,11 +4549,11 @@ public class TestCharset extends TestFmwk { result = encoder.encode(us2, bs, true); if (!result.isOverflow()) { errln("Overflow Error should have occured while encoding UTF-8 (5)."); - } - + } + //not readonly buffer encoder.reset(); - + us.limit(limit_us); us.position(0); bs.limit(1); @@ -4559,9 +4562,9 @@ public class TestCharset extends TestFmwk { if (!result.isOverflow()) { errln("Overflow Error should have occured while encoding UTF-8 (6)."); } - + encoder.reset(); - + us.limit(limit_us); us.position(0); bs.limit(3); @@ -4570,9 +4573,9 @@ public class TestCharset extends TestFmwk { if (!result.isOverflow()) { errln("Overflow Error should have occured while encoding UTF-8 (7)."); } - + encoder.reset(); - + us.limit(limit_us); us.position(1); bs.limit(2); @@ -4580,10 +4583,10 @@ public class TestCharset extends TestFmwk { result = encoder.encode(us, bs, true); if (!result.isOverflow()) { errln("Overflow Error should have occured while encoding UTF-8 (8)."); - } - + } + encoder.reset(); - + us.limit(limit_us + 1); us.position(1); bs.limit(3); @@ -4591,11 +4594,11 @@ public class TestCharset extends TestFmwk { result = encoder.encode(us, bs, true); if (!result.isOverflow()) { errln("Overflow Error should have occured while encoding UTF-8 (9)."); - } - + } + us.clear(); bs.clear(); - + //test encoding 4 byte characters encoder.reset(); us.put((char)0xD902); us.put((char)0xDD02); us.put((char)0x0041); @@ -4610,9 +4613,9 @@ public class TestCharset extends TestFmwk { if (!result.isOverflow()) { errln("Overflow Error should have occured while encoding UTF-8 (10)."); } - + encoder.reset(); - + us2.limit(limit_us); us2.position(0); bs.limit(2); @@ -4621,9 +4624,9 @@ public class TestCharset extends TestFmwk { if (!result.isOverflow()) { errln("Overflow Error should have occured while encoding UTF-8 (11)."); } - + encoder.reset(); - + us2.limit(limit_us); us2.position(0); bs.limit(3); @@ -4632,9 +4635,9 @@ public class TestCharset extends TestFmwk { if (!result.isOverflow()) { errln("Overflow Error should have occured while encoding UTF-8 (12)."); } - + encoder.reset(); - + us2.limit(limit_us); us2.position(0); bs.limit(4); @@ -4643,35 +4646,35 @@ public class TestCharset extends TestFmwk { if (!result.isOverflow()) { errln("Overflow Error should have occured while encoding UTF-8 (13)."); } - + us.clear(); bs.clear(); - + //decoding code coverage //test malform error decoder.reset(); bs.put((byte)0xC0); bs.put((byte)0xC0); us.put((char)0x0000); bs2 = bs.asReadOnlyBuffer(); - + us.limit(1); us.position(0); bs2.limit(1); bs2.position(0); - + result = decoder.decode(bs2, us, true); result = decoder.flush(us); if (!result.isMalformed()) { errln("Malform error should have occurred while decoding UTF-8 (1)."); - } - + } + us.limit(1); us.position(0); bs2.limit(1); bs2.position(0); - + decoder.reset(); - + result = decoder.decode(bs2, us, true); us.limit(1); us.position(0); @@ -4680,11 +4683,11 @@ public class TestCharset extends TestFmwk { result = decoder.decode(bs2, us, true); if (!result.isMalformed()) { errln("Malform error should have occurred while decoding UTF-8 (2)."); - } - + } + us.clear(); bs.clear(); - + //test overflow buffer bs.put((byte)0x01); bs.put((byte)0x41); us.put((char)0x0000); @@ -4693,15 +4696,15 @@ public class TestCharset extends TestFmwk { us.position(0); bs2.limit(2); bs2.position(0); - + result = decoder.decode(bs2, us, true); if (!result.isOverflow()) { errln("Overflow error should have occurred while decoding UTF-8 (3)."); } - + us.clear(); bs.clear(); - + //test malform string decoder.reset(); bs.put((byte)0xF5); bs.put((byte)0xB4); bs.put((byte)0x8A); bs.put((byte)0x8C); @@ -4711,14 +4714,14 @@ public class TestCharset extends TestFmwk { us.position(0); bs2.limit(4); bs2.position(0); - + result = decoder.decode(bs2, us, true); if (!result.isMalformed()) { errln("Malform error should have occurred while decoding UTF-8 (4)."); } - + bs.clear(); - + //test overflow decoder.reset(); bs.put((byte)0xF3); bs.put((byte)0xB4); bs.put((byte)0x8A); bs.put((byte)0x8C); @@ -4727,38 +4730,38 @@ public class TestCharset extends TestFmwk { us.position(0); bs2.limit(4); bs2.position(0); - + result = decoder.decode(bs2, us, true); if (!result.isOverflow()) { errln("Overflow error should have occurred while decoding UTF-8 (5)."); } - + //test overflow decoder.reset(); us.limit(2); us.position(0); bs2.limit(5); bs2.position(0); - + result = decoder.decode(bs2, us, true); if (!result.isOverflow()) { errln("Overflow error should have occurred while decoding UTF-8 (5)."); } - + //test overflow decoder.reset(); us.limit(1); us.position(0); bs.limit(5); bs.position(0); - + result = decoder.decode(bs, us, true); if (!result.isOverflow()) { errln("Overflow error should have occurred while decoding UTF-8 (6)."); } - + bs.clear(); - + //test overflow decoder.reset(); bs.put((byte)0x41); bs.put((byte)0x42); @@ -4766,50 +4769,50 @@ public class TestCharset extends TestFmwk { us.position(0); bs.limit(2); bs.position(0); - + result = decoder.decode(bs, us, true); if (!result.isOverflow()) { errln("Overflow error should have occurred while decoding UTF-8 (7)."); } - + } - + //provide better code coverage for Charset UTF16 @Test public void TestCharsetUTF16() { CoderResult result = CoderResult.UNDERFLOW; - CharsetProvider provider = new CharsetProviderICU(); + CharsetProvider provider = new CharsetProviderICU(); CharsetDecoder decoder = provider.charsetForName("UTF-16").newDecoder(); CharsetEncoder encoder = provider.charsetForName("UTF-16").newEncoder(); - + CharBuffer us = CharBuffer.allocate(0x10); ByteBuffer bs = ByteBuffer.allocate(0x10); - + //test flush buffer and malform string - bs.put((byte)0xFF); + bs.put((byte)0xFF); us.put((char)0x0000); - + us.limit(us.position()); us.position(0); bs.limit(bs.position()); bs.position(0); - + result = decoder.decode(bs, us, true); result = decoder.flush(us); if (!result.isMalformed()) { errln("Malform error while decoding UTF-16 should have occurred."); } - + us.clear(); bs.clear(); - + us.put((char)0xD902); us.put((char)0xDD01); us.put((char)0x0041); - + us.limit(1); us.position(0); bs.limit(4); bs.position(0); - + result = encoder.encode(us, bs, true); us.limit(3); us.position(0); @@ -4818,35 +4821,35 @@ public class TestCharset extends TestFmwk { result = encoder.encode(us, bs, true); if (!result.isOverflow()) { errln("Overflow buffer while encoding UTF-16 should have occurred."); - } - + } + us.clear(); bs.clear(); - + //test overflow buffer decoder.reset(); decoder = provider.charsetForName("UTF-16BE").newDecoder(); - + bs.put((byte)0xFF); bs.put((byte)0xFE); bs.put((byte)0x41); - + us.limit(0); us.position(0); bs.limit(3); bs.position(0); - + result = decoder.decode(bs, us, true); if (!result.isOverflow()) { errln("Overflow buffer while decoding UTF-16 should have occurred."); - } + } } - + //provide better code coverage for Charset ISO-2022-KR @Test public void TestCharsetISO2022KR() { CoderResult result = CoderResult.UNDERFLOW; - CharsetProvider provider = new CharsetProviderICU(); + CharsetProvider provider = new CharsetProviderICU(); CharsetDecoder decoder = provider.charsetForName("ISO-2022-KR").newDecoder(); - + byte bytearray[] = { (byte)0x1b, (byte)0x24, (byte)0x29, (byte)0x43, (byte)0x41, (byte)0x42, }; @@ -4855,21 +4858,21 @@ public class TestCharset extends TestFmwk { }; ByteBuffer bb = ByteBuffer.wrap(bytearray); CharBuffer cb = CharBuffer.wrap(chararray); - + result = decoder.decode(bb, cb, true); - + if (!result.isOverflow()) { errln("Overflow buffer while decoding ISO-2022-KR should have occurred."); } } - + //provide better code coverage for Charset ISO-2022-JP @Test public void TestCharsetISO2022JP() { CoderResult result = CoderResult.UNDERFLOW; - CharsetProvider provider = new CharsetProviderICU(); + CharsetProvider provider = new CharsetProviderICU(); CharsetDecoder decoder = provider.charsetForName("ISO-2022-JP-2").newDecoder(); - + byte bytearray[] = { (byte)0x1b, (byte)0x24, (byte)0x28, (byte)0x44, (byte)0x0A, (byte)0x41, }; @@ -4878,53 +4881,53 @@ public class TestCharset extends TestFmwk { }; ByteBuffer bb = ByteBuffer.wrap(bytearray); CharBuffer cb = CharBuffer.wrap(chararray); - + result = decoder.decode(bb, cb, true); - + if (!result.isOverflow()) { errln("Overflow buffer while decoding ISO-2022-KR should have occurred."); } } - + //provide better code coverage for Charset ASCII @Test public void TestCharsetASCII() { CoderResult result = CoderResult.UNDERFLOW; - CharsetProvider provider = new CharsetProviderICU(); + CharsetProvider provider = new CharsetProviderICU(); CharsetDecoder decoder = provider.charsetForName("US-ASCII").newDecoder(); - + byte bytearray[] = { (byte)0x41 }; char chararray[] = { (char)0x0041 }; - + ByteBuffer bb = ByteBuffer.wrap(bytearray); CharBuffer cb = CharBuffer.wrap(chararray); - + result = decoder.decode(bb, cb, true); result = decoder.flush(cb); - + if (result.isError()) { errln("Error occurred while decoding US-ASCII."); } } - + // provide better code coverage for Charset Callbacks /* Different aspects of callbacks are being tested including using different context available */ @Test public void TestCharsetCallbacks() { CoderResult result = CoderResult.UNDERFLOW; - CharsetProvider provider = new CharsetProviderICU(); + CharsetProvider provider = new CharsetProviderICU(); CharsetEncoder encoder = provider.charsetForName("iso-2022-jp").newEncoder(); CharsetDecoder decoder = provider.charsetForName("iso-2022-jp").newDecoder(); - + String context3[] = { "i", "J" }; - + // Testing encoder escape callback String context1[] = { "J", @@ -4937,46 +4940,46 @@ public class TestCharset extends TestFmwk { }; ByteBuffer bb = ByteBuffer.allocate(20); CharBuffer cb = CharBuffer.wrap(chararray); - + ((CharsetEncoderICU)encoder).setFromUCallback(CoderResult.OVERFLOW, CharsetCallback.FROM_U_CALLBACK_ESCAPE, null); // This callback is not valid. for (int i = 0; i < context1.length; i++) { encoder.reset(); cb.position(0); bb.position(0); ((CharsetEncoderICU)encoder).setFromUCallback(CoderResult.unmappableForLength(1), CharsetCallback.FROM_U_CALLBACK_ESCAPE, context1[i]); // This callback is valid. - + result = encoder.encode(cb, bb, true); if (result.isError()) { errln("Error occurred while testing of callbacks for ISO-2022-JP encoder."); } } - + // Testing encoder skip callback for (int i = 0; i < context3.length; i++) { encoder.reset(); cb.position(0); bb.position(0); - ((CharsetEncoderICU)encoder).setFromUCallback(CoderResult.unmappableForLength(1), CharsetCallback.FROM_U_CALLBACK_SKIP, context3[i]); - + ((CharsetEncoderICU)encoder).setFromUCallback(CoderResult.unmappableForLength(1), CharsetCallback.FROM_U_CALLBACK_SKIP, context3[i]); + result = encoder.encode(cb, bb, true); if (result.isError() && i == 0) { errln("Error occurred while testing of callbacks for ISO-2022-JP encoder."); } } - + // Testing encoder sub callback for (int i = 0; i < context3.length; i++) { encoder.reset(); cb.position(0); bb.position(0); - ((CharsetEncoderICU)encoder).setFromUCallback(CoderResult.unmappableForLength(1), CharsetCallback.FROM_U_CALLBACK_SUBSTITUTE, context3[i]); - + ((CharsetEncoderICU)encoder).setFromUCallback(CoderResult.unmappableForLength(1), CharsetCallback.FROM_U_CALLBACK_SUBSTITUTE, context3[i]); + result = encoder.encode(cb, bb, true); if (result.isError() && i == 0) { errln("Error occurred while testing of callbacks for ISO-2022-JP encoder."); } } - + // Testing decoder escape callback String context2[] = { "X", @@ -4989,20 +4992,20 @@ public class TestCharset extends TestFmwk { }; bb = ByteBuffer.wrap(bytearray); cb = CharBuffer.allocate(20); - + ((CharsetDecoderICU)decoder).setToUCallback(CoderResult.OVERFLOW, CharsetCallback.TO_U_CALLBACK_ESCAPE, null); // This callback is not valid. for (int i = 0; i < context2.length; i++) { decoder.reset(); cb.position(0); bb.position(0); ((CharsetDecoderICU)decoder).setToUCallback(CoderResult.malformedForLength(1), CharsetCallback.TO_U_CALLBACK_ESCAPE, context2[i]); // This callback is valid. - + result = decoder.decode(bb, cb, true); if (result.isError()) { errln("Error occurred while testing of callbacks for ISO-2022-JP decoder."); } } - + // Testing decoder skip callback for (int i = 0; i < context3.length; i++) { decoder.reset(); @@ -5015,7 +5018,7 @@ public class TestCharset extends TestFmwk { } } } - + // Testing invalid input exceptions @Test public void TestInvalidInput() { @@ -5023,20 +5026,20 @@ public class TestCharset extends TestFmwk { Charset charset = provider.charsetForName("iso-2022-jp"); CharsetEncoder encoder = charset.newEncoder(); CharsetDecoder decoder = charset.newDecoder(); - + try { encoder.encode(CharBuffer.allocate(10), null, true); errln("Illegal argument exception should have been thrown due to null target."); } catch (Exception ex) { } - + try { decoder.decode(ByteBuffer.allocate(10), null, true); errln("Illegal argument exception should have been thrown due to null target."); } catch (Exception ex) { } } - + // Test java canonical names @Test public void TestGetICUJavaCanonicalNames() { @@ -5046,9 +5049,9 @@ public class TestCharset extends TestFmwk { if (javaCName == null || icuCName == null) { errln("Unable to get Java or ICU canonical name from ambiguous alias"); } - + } - + // Port over from ICU4C for test conversion tables (mbcs version 5.x) // Provide better code coverage in CharsetMBCS, CharsetDecoderICU, and CharsetEncoderICU. @Test @@ -5060,47 +5063,47 @@ public class TestCharset extends TestFmwk { this.getClass().getClassLoader()); CharsetEncoder encoder = charset.newEncoder(); CharsetDecoder decoder = charset.newDecoder(); - + byte bytearray[] = { 0x01, 0x02, 0x03, 0x0a, 0x01, 0x02, 0x03, 0x0b, 0x01, 0x02, 0x03, 0x0d, }; - + // set the callback for overflow errors ((CharsetDecoderICU)decoder).setToUCallback(CoderResult.OVERFLOW, CharsetCallback.TO_U_CALLBACK_STOP, null); - + ByteBuffer bb = ByteBuffer.wrap(bytearray); CharBuffer cb = CharBuffer.allocate(10); - + bb.limit(4); cb.limit(1); // Overflow should occur and is expected result = decoder.decode(bb, cb, false); if (result.isError()) { errln("Error occurred while decoding: " + charsetName + " with error: " + result); } - + bb.limit(8); result = decoder.decode(bb, cb, false); if (result.isError()) { errln("Error occurred while decoding: " + charsetName + " with error: " + result); } - + bb.limit(12); result = decoder.decode(bb, cb, true); if (result.isError()) { errln("Error occurred while decoding: " + charsetName + " with error: " + result); } - + char chararray[] = { 0xDBC4,0xDE34,0xD900,0xDC05,/* \U00101234\U00050005 */ 0xD940, /* first half of \U00060006 or \U00060007 */ 0xDC07/* second half of \U00060007 */ }; - + cb = CharBuffer.wrap(chararray); bb = ByteBuffer.allocate(10); - + bb.limit(2); cb.limit(4); result = encoder.encode(cb, bb, false); @@ -5118,7 +5121,7 @@ public class TestCharset extends TestFmwk { errln("Error should have occurred while encoding: " + charsetName); } } - + /* Round trip test of SCSU converter*/ @Test public void TestSCSUConverter(){ @@ -5126,8 +5129,8 @@ public class TestCharset extends TestFmwk { 0x41,(byte) 0xdf, 0x12,(byte) 0x81, 0x03, 0x5f, 0x10, (byte)0xdf, 0x1b, 0x03, (byte)0xdf, 0x1c,(byte) 0x88,(byte) 0x80, 0x0b, (byte)0xbf,(byte) 0xff,(byte) 0xff, 0x0d, 0x0a, 0x41, 0x10, (byte)0xdf, 0x12, (byte)0x81, 0x03, 0x5f, 0x10, (byte)0xdf, 0x13, - (byte)0xdf, 0x14,(byte) 0x80, 0x15, (byte)0xff - }; + (byte)0xdf, 0x14,(byte) 0x80, 0x15, (byte)0xff + }; char allFeaturesUTF16[]={ 0x0041, 0x00df, 0x0401, 0x015f, 0x00df, 0x01df, 0xf000, 0xdbff, @@ -5135,7 +5138,7 @@ public class TestCharset extends TestFmwk { 0x01df, 0xf000, 0xdbff, 0xdfff }; - + char germanUTF16[]={ 0x00d6, 0x006c, 0x0020, 0x0066, 0x006c, 0x0069, 0x0065, 0x00df, 0x0074 }; @@ -5171,7 +5174,7 @@ public class TestCharset extends TestFmwk { }; // SCSUEncoder produces a slightly longer result (179B vs. 178B) because of one different choice: - //it uses an SQn once where a longer look-ahead could have shown that SCn is more efficient + //it uses an SQn once where a longer look-ahead could have shown that SCn is more efficient byte japaneseSCSU[]={ 0x08, 0x00, 0x1b, 0x4c,(byte) 0xea, 0x16, (byte)0xca, (byte)0xd3,(byte) 0x94, 0x0f, 0x53, (byte)0xef, 0x61, 0x1b, (byte)0xe5,(byte) 0x84, (byte)0xc4, 0x0f, (byte)0x53,(byte) 0xef, 0x61, 0x1b, (byte)0xe5, (byte)0x84, (byte)0xc4, 0x16, (byte)0xca, (byte)0xd3, (byte)0x94, 0x08, 0x02, 0x0f, @@ -5186,28 +5189,28 @@ public class TestCharset extends TestFmwk { (byte)0xea, 0x06,(byte) 0xd3,(byte) 0xe6, 0x0f,(byte) 0x8a, 0x00, 0x30, 0x44, 0x65,(byte) 0xb9, (byte)0xe4, (byte)0xfe,(byte) 0xe7,(byte) 0xc2, 0x06, (byte)0xcb, (byte)0x82 }; - + CharsetProviderICU cs = new CharsetProviderICU(); CharsetICU charset = (CharsetICU)cs.charsetForName("scsu"); CharsetDecoder decode = charset.newDecoder(); CharsetEncoder encode = charset.newEncoder(); - + //String[] codePoints = {"allFeatures", "german","russian","japanese"}; byte[][] fromUnicode={allFeaturesSCSU,germanSCSU,russianSCSU,japaneseSCSU}; char[][] toUnicode = {allFeaturesUTF16, germanUTF16,russianUTF16,japaneseUTF16}; - + for(int i=0;i<4;i++){ ByteBuffer decoderBuffer = ByteBuffer.wrap(fromUnicode[i]); CharBuffer encoderBuffer = CharBuffer.wrap(toUnicode[i]); - + try{ - // Decoding + // Decoding CharBuffer decoderResult = decode.decode(decoderBuffer); encoderBuffer.position(0); if(!decoderResult.equals(encoderBuffer)){ errln("Error occured while decoding "+ charset.name()); } - // Encoding + // Encoding ByteBuffer encoderResult = encode.encode(encoderBuffer); // RoundTrip Test ByteBuffer roundTrip = encoderResult; @@ -5231,12 +5234,12 @@ public class TestCharset extends TestFmwk { errln("Exception while converting SCSU thrown: " + e); } } - + /* Provide better code coverage */ /* testing illegal codepoints */ CoderResult illegalResult = CoderResult.UNDERFLOW; CharBuffer illegalDecoderTrgt = CharBuffer.allocate(10); - + byte[] illegalDecoderSrc1 = { (byte)0x41, (byte)0xdf, (byte)0x0c }; decode.reset(); illegalResult = decode.decode(ByteBuffer.wrap(illegalDecoderSrc1), illegalDecoderTrgt, true); @@ -5320,7 +5323,7 @@ public class TestCharset extends TestFmwk { } } } - + /* Monkey test */ { char[] monkeyIn = { @@ -5367,9 +5370,9 @@ public class TestCharset extends TestFmwk { decode.reset(); CharBuffer monkeyCB = CharBuffer.wrap(monkeyIn); try { - ByteBuffer monkeyBB = encode.encode(monkeyCB); + ByteBuffer monkeyBB = encode.encode(monkeyCB); /* CharBuffer monkeyEndResult =*/ decode.decode(monkeyBB); - + } catch (Exception ex) { errln("Exception thrown while encoding/decoding monkey test in SCSU: " + ex); } @@ -5381,7 +5384,7 @@ public class TestCharset extends TestFmwk { }; encode.reset(); CharBuffer malformedSrc = CharBuffer.wrap(malformedSequence); - + try { encode.encode(malformedSrc); errln("Malformed error should have thrown an exception."); @@ -5403,34 +5406,34 @@ public class TestCharset extends TestFmwk { errln("Buffer overflow exception should have been thrown."); } } - + } - } - + } + /* Test for BOCU1 converter*/ @Test public void TestBOCU1Converter(){ char expected[]={ - 0xFEFF, 0x0061, 0x0062, 0x0020, // 0 + 0xFEFF, 0x0061, 0x0062, 0x0020, // 0 0x0063, 0x0061, 0x000D, 0x000A, - 0x0020, 0x0000, 0x00DF, 0x00E6, // 8 + 0x0020, 0x0000, 0x00DF, 0x00E6, // 8 0x0930, 0x0020, 0x0918, 0x0909, - 0x3086, 0x304D, 0x0020, 0x3053, // 16 - 0x4000, 0x4E00, 0x7777, 0x0020, + 0x3086, 0x304D, 0x0020, 0x3053, // 16 + 0x4000, 0x4E00, 0x7777, 0x0020, - 0x9FA5, 0x4E00, 0xAC00, 0xBCDE, // 24 + 0x9FA5, 0x4E00, 0xAC00, 0xBCDE, // 24 0x0020, 0xD7A3, 0xDC00, 0xD800, - 0xD800, 0xDC00, 0xD845, 0xDDDD, // 32 + 0xD800, 0xDC00, 0xD845, 0xDDDD, // 32 0xDBBB, 0xDDEE, 0x0020, 0xDBFF, - 0xDFFF, 0x0001, 0x0E40, 0x0020, // 40 - 0x0009 + 0xDFFF, 0x0001, 0x0E40, 0x0020, // 40 + 0x0009 }; - - byte sampleText[]={ // from cintltst/bocu1tst.c/TestBOCU1 text 1 + + byte sampleText[]={ // from cintltst/bocu1tst.c/TestBOCU1 text 1 (byte) 0xFB, (byte) 0xEE, 0x28, // from source offset 0 @@ -5460,31 +5463,31 @@ public class TestCharset extends TestFmwk { (byte) 0xFC, 0x10, 0x3E, (byte) 0xFE, 0x16, 0x3A, (byte) 0x8C, 0x20, (byte) 0xFC, 0x03, (byte) 0xAC, - 0x01, /// from 41 - (byte) 0xDE, (byte) 0x83, 0x20, 0x09 + 0x01, /// from 41 + (byte) 0xDE, (byte) 0x83, 0x20, 0x09 }; - + CharsetProviderICU cs = new CharsetProviderICU(); CharsetICU charset = (CharsetICU)cs.charsetForName("BOCU-1"); CharsetDecoder decode = charset.newDecoder(); CharsetEncoder encode = charset.newEncoder(); - + ByteBuffer decoderBuffer = ByteBuffer.wrap(sampleText); CharBuffer encoderBuffer = CharBuffer.wrap(expected); try{ - // Decoding + // Decoding CharBuffer decoderResult = decode.decode(decoderBuffer); - + encoderBuffer.position(0); if(!decoderResult.equals(encoderBuffer)){ errln("Error occured while decoding "+ charset.name()); } - // Encoding + // Encoding ByteBuffer encoderResult = encode.encode(encoderBuffer); // RoundTrip Test ByteBuffer roundTrip = encoderResult; CharBuffer roundTripResult = decode.decode(roundTrip); - + encoderBuffer.position(0); if(!roundTripResult.equals(encoderBuffer)){ errln("Error occured while encoding "+ charset.name()); @@ -5493,7 +5496,7 @@ public class TestCharset extends TestFmwk { errln("Exception while converting BOCU-1 thrown: " + e); } } - + /* Test that ICU4C and ICU4J get the same ICU canonical name when given the same alias. */ @Test public void TestICUCanonicalNameConsistency() { @@ -5511,7 +5514,7 @@ public class TestCharset extends TestFmwk { } } } - + /* Increase code coverage for CharsetICU and CharsetProviderICU*/ @Test public void TestCharsetICUCodeCoverage() { @@ -5541,7 +5544,7 @@ public class TestCharset extends TestFmwk { } errln("IllegalArgumentException should have been thrown."); } - + @Test public void TestCharsetLMBCS() { String []lmbcsNames = { @@ -5558,16 +5561,16 @@ public class TestCharset extends TestFmwk { "LMBCS-18", "LMBCS-19" }; - + char[] src = { 0x0192, 0x0041, 0x0061, 0x00D0, 0x00F6, 0x0100, 0x0174, 0x02E4, 0x03F5, 0x03FB, 0x05D3, 0x05D4, 0x05EA, 0x0684, 0x0685, 0x1801, 0x11B3, 0x11E8, 0x1F9A, 0x2EB4, 0x3157, 0x3336, 0x3304, 0xD881, 0xDC88 }; CharBuffer cbInput = CharBuffer.wrap(src); - + CharsetProviderICU provider = new CharsetProviderICU(); - + for (int i = 0; i < lmbcsNames.length; i++) { Charset charset = provider.charsetForName(lmbcsNames[i]); if (charset == null) { @@ -5576,12 +5579,12 @@ public class TestCharset extends TestFmwk { } CharsetEncoder encoder = charset.newEncoder(); CharsetDecoder decoder = charset.newDecoder(); - + try { cbInput.position(0); ByteBuffer bbTmp = encoder.encode(cbInput); CharBuffer cbOutput = decoder.decode(bbTmp); - + if (!equals(cbInput, cbOutput)) { errln("Roundtrip test failed for charset: " + lmbcsNames[i]); } @@ -5592,9 +5595,9 @@ public class TestCharset extends TestFmwk { } errln("Exception thrown: " + ex + " while using charset: " + lmbcsNames[i]); } - + } - + // Test malformed CoderResult malformedResult = CoderResult.UNDERFLOW; byte[] malformedBytes = { @@ -5608,19 +5611,19 @@ public class TestCharset extends TestFmwk { CharsetDecoder malformedDecoderTest = provider.charsetForName("LMBCS-1").newDecoder(); for (int n = 0; n < malformedLimits.length; n++) { malformedDecoderTest.reset(); - + malformedSrc.position(0); malformedSrc.limit(malformedLimits[n]); - + malformedTrgt.clear(); - + malformedResult = malformedDecoderTest.decode(malformedSrc,malformedTrgt, true); if (!malformedResult.isMalformed()) { errln("Malformed error should have resulted."); } } } - + /* * This is a port of ICU4C TestAmbiguousConverter in cintltst. * Since there is no concept of ambiguous converters in ICU4J @@ -5633,11 +5636,11 @@ public class TestCharset extends TestFmwk { }; ByteBuffer src = ByteBuffer.wrap(inBytes); CharBuffer trgt = CharBuffer.allocate(20); - + CoderResult result = CoderResult.UNDERFLOW; CharsetProviderICU provider = new CharsetProviderICU(); String[] names = CharsetProviderICU.getAllNames(); - + for (int i = 0; i < names.length; i++) { Charset charset = provider.charsetForName(names[i]); if (charset == null) { @@ -5645,10 +5648,10 @@ public class TestCharset extends TestFmwk { continue; } CharsetDecoder decoder = charset.newDecoder(); - + src.position(0); trgt.clear(); - + result = decoder.decode(src, trgt, true); if (result.isError()) { /* We don't care about any failures. */ @@ -5656,7 +5659,7 @@ public class TestCharset extends TestFmwk { } } } - + @Test public void TestIsFixedWidth(){ String[] fixedWidth = { @@ -5664,7 +5667,7 @@ public class TestCharset extends TestFmwk { "UTF32", "ibm-5478_P100-1995" }; - + String[] notFixedWidth = { "GB18030", "UTF8", @@ -5673,24 +5676,24 @@ public class TestCharset extends TestFmwk { }; CharsetProvider provider = new CharsetProviderICU(); Charset charset; - + for (int i = 0; i < fixedWidth.length; i++) { charset = provider.charsetForName(fixedWidth[i]); - + if (!((CharsetICU)charset).isFixedWidth()) { errln(fixedWidth[i] + " is a fixedWidth charset but returned false."); } } - + for (int i = 0; i < notFixedWidth.length; i++) { charset = provider.charsetForName(notFixedWidth[i]); - + if (((CharsetICU)charset).isFixedWidth()) { errln(notFixedWidth[i] + " is NOT a fixedWidth charset but returned true."); } } } - + @Test public void TestBytesLengthForString() { CharsetProviderICU provider = new CharsetProviderICU(); @@ -5701,7 +5704,7 @@ public class TestCharset extends TestFmwk { "ISCII,version=0", "ISO_2022,locale=ko,version=0" }; - + int[] expected = { 40, 20, @@ -5709,21 +5712,21 @@ public class TestCharset extends TestFmwk { 80, 160 }; - + int stringLength = 10; int length; int maxCharSize; - + for (int i = 0; i < charsets.length; i++) { maxCharSize = (int)provider.charsetForName(charsets[i]).newEncoder().maxBytesPerChar(); length = CharsetEncoderICU.getMaxBytesForString(stringLength, maxCharSize); - + if (length != expected[i]) { errln("For charset " + charsets[i] + " with string length " + stringLength + ", expected max byte length is " + expected[i] + " but got " + length); } } } - + /* * When converting slices of a larger CharBuffer, Charset88591 and CharsetASCII does not handle the buffer correctly when * an unmappable character occurs. @@ -5733,30 +5736,30 @@ public class TestCharset extends TestFmwk { public void TestCharsetASCII8859BufferHandling() { String firstLine = "C077693790=|MEMO=|00=|022=|Blanche st and the driveway grate was fault and rotated under my car=|\r\n"; String secondLine = "C077693790=|MEMO=|00=|023=|puncturing the fuel tank. I spoke to the store operator (Ram Reddi –=|\r\n"; - + String charsetNames[] = { "ASCII", "ISO-8859-1" }; - + CoderResult result = CoderResult.UNDERFLOW; - + CharsetEncoder encoder; - + ByteBuffer outBuffer = ByteBuffer.allocate(500); CharBuffer charBuffer = CharBuffer.allocate(firstLine.length() + secondLine.length()); charBuffer.put(firstLine); charBuffer.put(secondLine); charBuffer.flip(); - + for (int i = 0; i < charsetNames.length; i++) { encoder = CharsetICU.forNameICU(charsetNames[i]).newEncoder(); - + charBuffer.position(firstLine.length()); CharBuffer charBufferSlice = charBuffer.slice(); charBufferSlice.limit(secondLine.length() - 2); - - + + try { result = encoder.encode(charBufferSlice, outBuffer, false); if (!result.isUnmappable()) { @@ -5767,7 +5770,7 @@ public class TestCharset extends TestFmwk { } } } - + /* * When converting with the String method getBytes(), buffer overflow exception is thrown because * of the way ICU4J is calculating the max bytes per char. This should be changed only on the ICU4J @@ -5778,15 +5781,15 @@ public class TestCharset extends TestFmwk { public void TestBufferOverflowErrorUsingJavagetBytes() { String charsetName = "ibm-5035"; String testCase = "\u7d42"; - + try { testCase.getBytes(charsetName); } catch (Exception ex) { errln("Error calling getBytes(): " + ex); } - + } - + @Test public void TestDefaultIgnorableCallback() { String cnv_name = "euc-jp-2007"; @@ -5812,7 +5815,7 @@ public class TestCharset extends TestFmwk { errln("Error received converting +" + Integer.toHexString(set_ignorable.charAt(i))); } } - + // test non-ignorable code points are not ignored size = set_not_ignorable.size(); for (int i = 0; i < size; i++) { diff --git a/icu4j/main/tests/charset/src/com/ibm/icu/dev/test/charset/TestSelection.java b/icu4j/main/tests/charset/src/com/ibm/icu/dev/test/charset/TestSelection.java index ac38eee83a6..f259bdb2fca 100644 --- a/icu4j/main/tests/charset/src/com/ibm/icu/dev/test/charset/TestSelection.java +++ b/icu4j/main/tests/charset/src/com/ibm/icu/dev/test/charset/TestSelection.java @@ -9,13 +9,13 @@ /** * Test for CharsetSelector - * + * * This is a port of ucnvseltst.c from ICU4C - * + * * Tests related to serialization are not ported in this version. In addition, * the TestConversionUTF8 method is not going to be ported, as UTF8 is seldom used * in Java. - * + * * @author Shaopeng Jia */ @@ -27,6 +27,8 @@ import java.util.Arrays; import java.util.List; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.charset.CharsetICU; import com.ibm.icu.charset.CharsetProviderICU; @@ -35,6 +37,7 @@ import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.UTF16; import com.ibm.icu.text.UnicodeSet; +@RunWith(JUnit4.class) public class TestSelection extends TestFmwk { @Test public void TestConversionUTF16() { @@ -141,7 +144,7 @@ public class TestSelection extends TestFmwk { logln("IllegalArgumentException was thrown by CharsetSelector with a bogus mappingType."); } } - + private String[] texts = { "Cos\'\u00E8 Unicode?\n\nUnicode assegna un numero univoco a ogni carattere,\nindipendentemente dalla piattaforma," + "\nindipendentemente dall\'applicazione,\nindipendentemente dalla lingua.\n\nI computer, in buona sostanza," + @@ -170,7 +173,7 @@ public class TestSelection extends TestFmwk { "o di un sito web siano fruibili con piattaforme, lingue e paesi diversi, evitando la necessit\u00E0 di " + "reingenierizzare il prodotto per ogni situazione specifica. Permette, inoltre, il trasporto del testo " + "fra sistemi diversi senza che abbia luogo alcuna corruzione dei dati.\n", - + "\u0427\u0442\u043E \u0442\u0430\u043A\u043E\u0435 Unicode? Unicode - \u044D\u0442\u043E" + " \u0443\u043D\u0438\u043A\u0430\u043B\u044C\u043D\u044B\u0439 \u043A\u043E\u0434" + " \u0434\u043B\u044F \u043B\u044E\u0431\u043E\u0433\u043E \u0441\u0438\u043C\u0432\u043E\u043B\u0430," + @@ -332,7 +335,7 @@ public class TestSelection extends TestFmwk { "\u0440\u0430\u0437\u043B\u0438\u0447\u043D\u044B\u043C\u0438 \u0441\u0438\u0441\u0442\u0435\u043C\u0430\u043C\u0438 " + "\u043F\u0440\u0435\u0434\u043E\u0445\u0440\u0430\u043D\u044F\u0435\u0442 \u044D\u0442\u0438 " + "\u0434\u0430\u043D\u043D\u044B\u0435 \u043E\u0442 \u043F\u043E\u0432\u0440\u0435\u0436\u0434\u0435", - + "\u0645\u0627 \u0647\u064A \u0627\u0644\u0634\u0641\u0631\u0629 \u0627\u0644\u0645\u0648\u062D\u062F\u0629 " + "\"\u064A\u0648\u0646\u0650\u0643\u0648\u062F\" \u061F\n\n\u0623\u0633\u0627\u0633\u064B\u0627\u060C " + "\u062A\u062A\u0639\u0627\u0645\u0644 \u0627\u0644\u062D\u0648\u0627\u0633\u064A\u0628 \u0641\u0642\u0637 \u0645\u0639 " + @@ -431,7 +434,7 @@ public class TestSelection extends TestFmwk { "\u0643\u062A\u0627\u0628\u0629 \u0627\u0644\u0628\u0631\u0646\u0627\u0645\u062C \u0645\u0631\u0629 " + "\u0648\u0627\u062D\u062F\u0629\u060C \u0648\u0627\u0633\u062A\u062E\u062F\u0627\u0645\u0647 \u0639\u0644\u0649 " + "\u0623\u064A \u0646\u0648\u0639 \u0645\u0646 \u0627\u0644\u0623\u062C\u0647\u0632\u0629", - + "\u4EC0\u9EBD\u662FUnicode(\u7D71\u4E00\u78BC/\u6A19\u6E96\u842C\u570B\u78BC)?\n\n" + "Unicode\u7D66\u6BCF\u500B\u5B57\u5143\u63D0\u4F9B\u4E86\u4E00\u500B\u552F\u4E00\u7684\u6578\u4F4D\uFF0C\n" + "\u4E0D\u8AD6\u662F\u4EC0\u9EBD\u5E73\u81FA\uFF0C\n\u4E0D\u8AD6\u662F\u4EC0\u9EBD\u7A0B\u5F0F\uFF0C\n" + @@ -470,7 +473,7 @@ public class TestSelection extends TestFmwk { "\u570B\u5BB6\uFF0C\u800C\u4E0D\u9700\u8981\u91CD\u5EFA\u3002\u5B83\u53EF\u5C07\u8CC7\u6599\u50B3\u8F38" + "\u5230\u8A31\u591A\u4E0D\u540C\u7684\u7CFB\u7D71\uFF0C\u800C\u7121\u640D\u58DE\u3002\n\u95DC\u65BCUnicode" + "\u5B78\u8853\u5B78\u6703\n\nUnicode\u5B78\u8853\u5B78\u6703", - + "\u00C7\'\u00EBsht\u00EB UNICODE?\n\nUnicode siguron nj\u00EB num\u00EBr t\u00EB vet\u00EBm p\u00EBr \u00E7do " + "g\u00EBrm\u00EB,\np\u00EBr cil\u00EBndo platform\u00EB,\np\u00EBr cilindo program,\np\u00EBr cil\u00EBndo " + "gjuh\u00EB.\n\nN\u00EB themel, kompjuterat veprojn\u00EB me an\u00EBn e numrave. Ata ruajn\u00EB g\u00EBrmat " + @@ -502,7 +505,7 @@ public class TestSelection extends TestFmwk { "softuer ose nj\u00EB faqe interneti t\u00EB p\u00EBrdoret p\u00EBr shum\u00EB platforma, gjuh\u00EB dhe vende " + "pa re-inxhinierim. Ai lejon t\u00EB dh\u00EBnat t\u00EB kalohen p\u00EBrmes shum\u00EB sistemeve t\u00EB ndryshme " + "pa korruptim.", - + "\u092F\u0942\u0928\u093F\u0915\u094B\u0921 \u0915\u094D\u092F\u093E \u0939\u0948?\n\n\u092F\u0942\u0928\u093F\u0915" + "\u094B\u0921 \u092A\u094D\u0930\u0924\u094D\u092F\u0947\u0915 \u0905\u0915\u094D\u0937\u0930 \u0915\u0947 " + "\u0932\u093F\u090F \u090F\u0915 \u0935\u093F\u0936\u0947\u0937 \u0928\u092E\u094D\u092C\u0930 \u092A\u094D" + @@ -611,7 +614,7 @@ public class TestSelection extends TestFmwk { "\u0940 \u092C\u093E\u0927\u093E \u0915\u0947 \u0935\u093F\u092D\u093F\u0928\u094D\u0928 \u092A\u094D" + "\u0930\u0923\u093E\u0932\u093F\u092F\u094B\u0902 \u0938\u0947 \u0939\u094B\u0915\u0930 \u0932\u0947 " + "\u091C\u093E\u092F\u093E \u091C\u093E \u0938\u0915\u0924\u093E \u0939\u0948\u0964\n", - + "\u0E1A\u0E40\u0E23\u0E37\u0E48\u0E2D\u0E07\u0E02\u0E2D\u0E07\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02. \u0E04" + "\u0E2D\u0E21\u0E1E\u0E34\u0E27\u0E40\u0E15\u0E2D\u0E23\u0E4C\u0E08\u0E31\u0E14\u0E40\u0E01\u0E47\u0E1A" + "\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23\u0E41\u0E25\u0E30\u0E2D\u0E31\u0E01\u0E02\u0E23\u0E30" + @@ -683,7 +686,7 @@ public class TestSelection extends TestFmwk { "\u0E48\u0E07\u0E43\u0E19\u0E41\u0E19\u0E27\u0E42\u0E19\u0E49\u0E21\u0E17\u0E32\u0E07\u0E40\u0E17\u0E04\u0E42" + "\u0E19\u0E42\u0E25\u0E22\u0E35\u0E0B\u0E2D\u0E1F\u0E15\u0E4C\u0E41\u0E27\u0E23\u0E4C\u0E23\u0E30\u0E14\u0E31" + "\u0E1A\u0E42\u0E25\u0E01\u0E17\u0E35\u0E48\u0E21\u0E35\u0E04\u0E27\u0E32\u0E21\u0E2A\u0E33\u0E04\n", - + "\u4EC0\u4E48\u662FUnicode(\u7EDF\u4E00\u7801)?\n\nUnicode\u7ED9\u6BCF\u4E2A\u5B57\u7B26\u63D0\u4F9B\u4E86" + "\u4E00\u4E2A\u552F\u4E00\u7684\u6570\u5B57\uFF0C\n\u4E0D\u8BBA\u662F\u4EC0\u4E48\u5E73\u53F0\uFF0C\n\u4E0D" + "\u8BBA\u662F\u4EC0\u4E48\u7A0B\u5E8F\uFF0C\n\u4E0D\u8BBA\u662F\u4EC0\u4E48\u8BED\u8A00\u3002\n\n\u57FA\u672C" + @@ -727,7 +730,7 @@ public class TestSelection extends TestFmwk { "\u8D44\u91D1\u3002Unicode\u5B66\u672F\u5B66\u4F1A\u7684\u4F1A\u5458\u8D44\u683C\u5F00\u653E\u7ED9\u4E16\u754C" + "\u4E0A\u4EFB\u4F55\u652F\u6301Unicode\u6807\u51C6\u548C\u5E0C\u671B\u534F\u52A9\u5176\u6269\u5C55\u548C\u6267" + "\u884C\u7684\u7EC4\u7EC7\u53CA\u4E2A\u4EBA\u3002\n", - + "Mik\u00E4 Unicode on?\n\nUnicode m\u00E4\u00E4ritt\u00E4\u00E4 jokaiselle merkille yksil\u00F6llisen arvon." + "\nRiippumatta k\u00E4ytt\u00F6j\u00E4rjestelm\u00E4st\u00E4\nRiippumatta ohjelmistosta\nRiippumatta kielest" + "\u00E4\n\nTietokoneiden toiminta perustuu numeroiden k\u00E4sittelylle. My\u00F6s kirjaimet ja muut merkit " + @@ -754,7 +757,7 @@ public class TestSelection extends TestFmwk { "\u00E4inen sovellus tai sivusto voidaan tarjota useille eri k\u00E4ytt\u00F6j\u00E4rjestelmille ja monilla " + "eri kielill\u00E4 maailmanlaajuisesti, ilman uudelleenohjelmoinnin tarvetta. Tieto kulkee j\u00E4rjestelmien " + "v\u00E4lill\u00E4 vailla tuhoutumisen tai v\u00E4\u00E4ristymisen vaaraa.\nUnicode-konsortio", - + "Co je Unicode?\n\nUnicode p\u0159i\u0159azuje ka\u017Ed\u00E9mu znaku jedine\u010Dn\u00E9 \u010D\u00EDslo,\nnez" + "\u00E1visle na platform\u011B,\nnez\u00E1visle na programu,\nnez\u00E1visle na jazyce.\n\nPo\u010D\u00EDta\u010De," + " ze sv\u00E9 podstaty, pracuj\u00ED pouze s \u010D\u00EDsly. P\u00EDsmena a dal\u0161\u00ED znaky ukl\u00E1daj\u00ED" + @@ -785,7 +788,7 @@ public class TestSelection extends TestFmwk { "softwarov\u00FD produkt nebo jedin\u00E1 webov\u00E1 str\u00E1nka byla zam\u011B\u0159ena na mnoho platforem, " + "jazyk\u016F a zem\u00ED beze zm\u011Bn n\u00E1vrhu. To dovoluje p\u0159en\u00E1\u0161et data p\u0159es mnoho " + "r\u016Fzn\u00FDch syst\u00E9m\u016F bez poru\u0161en\u00ED.", - + "?\n\n\u05D9\u05D5\u05E0\u05D9\u05E7\u05D5\u05D3 \u05DE\u05E7\u05E6\u05D4 \u05DE\u05E1\u05E4\u05E8 \u05D9\u05D9" + "\u05D7\u05D5\u05D3\u05D9 \u05DC\u05DB\u05DC \u05EA\u05D5,\n\u05DC\u05D0 \u05DE\u05E9\u05E0\u05D4 \u05E2\u05DC " + "\u05D0\u05D9\u05D6\u05D5 \u05E4\u05DC\u05D8\u05E4\u05D5\u05E8\u05DE\u05D4,\n\u05DC\u05D0 \u05DE\u05E9\u05E0\u05D4" + diff --git a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/AlphabeticIndexTest.java b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/AlphabeticIndexTest.java index 06bd1ccfcdb..6cc274a563d 100644 --- a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/AlphabeticIndexTest.java +++ b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/AlphabeticIndexTest.java @@ -18,6 +18,8 @@ import java.util.Set; import java.util.TreeSet; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.dev.util.CollectionUtilities; @@ -43,6 +45,7 @@ import com.ibm.icu.util.ULocale; /** * @author Mark Davis */ +@RunWith(JUnit4.class) public class AlphabeticIndexTest extends TestFmwk { /** * diff --git a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationAPITest.java b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationAPITest.java index d467c6d4bc4..c7b6589ef1f 100644 --- a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationAPITest.java +++ b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationAPITest.java @@ -23,6 +23,8 @@ import java.util.MissingResourceException; import java.util.Set; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.Utility; @@ -38,6 +40,7 @@ import com.ibm.icu.text.UnicodeSet; import com.ibm.icu.util.ULocale; import com.ibm.icu.util.VersionInfo; +@RunWith(JUnit4.class) public class CollationAPITest extends TestFmwk { /** * This tests the collation key related APIs. diff --git a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationChineseTest.java b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationChineseTest.java index a822e0d659a..4c6de0cf3b3 100644 --- a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationChineseTest.java +++ b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationChineseTest.java @@ -7,30 +7,33 @@ ******************************************************************************* */ -/** +/** * Port From: ICU4C v2.1 : Collate/CollationTurkishTest * Source File: $ICU4CRoot/source/test/intltest/trcoll.cpp **/ - + package com.ibm.icu.dev.test.collator; - + import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.Collator; import com.ibm.icu.text.RuleBasedCollator; - + +@RunWith(JUnit4.class) public class CollationChineseTest extends TestFmwk{ - public CollationChineseTest() + public CollationChineseTest() { } - + @Test - public void TestPinYin() + public void TestPinYin() { - String seq[] + String seq[] = {"\u963f", "\u554a", "\u54ce", "\u6371", "\u7231", "\u9f98", "\u4e5c", "\u8baa", "\u4e42", "\u53c8"}; RuleBasedCollator collator = null; @@ -45,4 +48,4 @@ public class CollationChineseTest extends TestFmwk{ CollationTest.doTest(this, collator, seq[i], seq[i + 1], -1); } } -} \ No newline at end of file +} diff --git a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationCreationMethodTest.java b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationCreationMethodTest.java index 25d03421f9d..2797b1c26aa 100644 --- a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationCreationMethodTest.java +++ b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationCreationMethodTest.java @@ -6,13 +6,15 @@ * others. All Rights Reserved. * ******************************************************************************* */ - + package com.ibm.icu.dev.test.collator; import java.util.Locale; import java.util.Random; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.CollationKey; @@ -21,20 +23,21 @@ import com.ibm.icu.text.RuleBasedCollator; /** - * - * CollationCreationMethodTest checks to ensure that the collators act the same whether they are created by choosing a + * + * CollationCreationMethodTest checks to ensure that the collators act the same whether they are created by choosing a * locale and loading the data from file, or by using rules. - * + * * @author Brian Rower - IBM - August 2008 * */ -public class CollationCreationMethodTest extends TestFmwk +@RunWith(JUnit4.class) +public class CollationCreationMethodTest extends TestFmwk { @Test public void TestRuleVsLocaleCreationMonkey() { //create a RBC from a collator reader by reading in a locale collation file - //also create one simply from a rules string (which should be + //also create one simply from a rules string (which should be //pulled from the locale collation file) //and then do crazy monkey testing on it to make sure they are the same. int x,y,z; @@ -60,8 +63,8 @@ public class CollationCreationMethodTest extends TestFmwk localeCollator = (RuleBasedCollator)Collator.getInstance(locale); logln("Rules for " + locale + " are: " + localeCollator.getRules()); ruleCollator = new RuleBasedCollator(localeCollator.getRules()); - } - catch (Exception e) + } + catch (Exception e) { warnln("ERROR: in creation of collator of locale " + locale.getDisplayName() + ": " + e); return; @@ -76,7 +79,7 @@ public class CollationCreationMethodTest extends TestFmwk key1 = localeCollator.getCollationKey(randString1); key2 = ruleCollator.getCollationKey(randString1); - + report(locale.getDisplayName(), randString1, key1, key2); } } @@ -108,9 +111,9 @@ public class CollationCreationMethodTest extends TestFmwk return s; } - private void report(String localeName, String string1, CollationKey k1, CollationKey k2) + private void report(String localeName, String string1, CollationKey k1, CollationKey k2) { - if (!k1.equals(k2)) + if (!k1.equals(k2)) { StringBuilder msg = new StringBuilder(); msg.append("With ").append(localeName).append(" collator\n and input string: ").append(string1).append('\n'); diff --git a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationCurrencyTest.java b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationCurrencyTest.java index 00b1406bae7..b1366b072dc 100644 --- a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationCurrencyTest.java +++ b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationCurrencyTest.java @@ -7,22 +7,25 @@ ******************************************************************************* */ -/** +/** * Port From: ICU4C v2.1 : Collate/CollationCurrencyTest * Source File: $ICU4CRoot/source/test/intltest/currcoll.cpp **/ - + package com.ibm.icu.dev.test.collator; - + import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.CollationKey; import com.ibm.icu.text.Collator; import com.ibm.icu.text.RuleBasedCollator; - + +@RunWith(JUnit4.class) public class CollationCurrencyTest extends TestFmwk { @Test public void TestCurrency() { @@ -59,16 +62,16 @@ public class CollationCurrencyTest extends TestFmwk { { 0x20AE }, /*20AE; L; [14 62, 03, 03] # [0841.0020.0002] # TUGRIK SIGN*/ { 0x20AF } /*20AF; L; [14 64, 03, 03] # [0842.0020.0002] # DRACHMA SIGN*/ }; - + int i, j; int expectedResult = 0; RuleBasedCollator c = (RuleBasedCollator)Collator.getInstance(Locale.ENGLISH); - + // Compare each currency symbol against all the // currency symbols, including itself String source; String target; - + for (i = 0; i < currency.length; i += 1) { for (j = 0; j < currency.length; j += 1) { source = new String(currency[i]); @@ -84,14 +87,14 @@ public class CollationCurrencyTest extends TestFmwk { int compareResult = c.compare(source, target); CollationKey sourceKey = null; - + sourceKey = c.getCollationKey(source); if (sourceKey == null) { errln("Couldn't get collationKey for source"); continue; } - + CollationKey targetKey = null; targetKey = c.getCollationKey(target); if (targetKey == null) { @@ -105,7 +108,7 @@ public class CollationCurrencyTest extends TestFmwk { } } } - + private void reportCResult( String source, String target, CollationKey sourceKey, CollationKey targetKey, int compareResult, int keyResult, int incResult, int expectedResult ) { if (expectedResult < -1 || expectedResult > 1) { @@ -118,13 +121,13 @@ public class CollationCurrencyTest extends TestFmwk { boolean ok3 = (incResult == expectedResult); if (ok1 && ok2 && ok3 && !isVerbose()) { - return; + return; } else { String msg1 = ok1? "Ok: compare(\"" : "FAIL: compare(\""; String msg2 = "\", \""; String msg3 = "\") returned "; String msg4 = "; expected "; - + String sExpect = new String(""); String sResult = new String(""); sResult = CollationTest.appendCompareResult(compareResult, sResult); @@ -134,7 +137,7 @@ public class CollationCurrencyTest extends TestFmwk { } else { errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect); } - + msg1 = ok2 ? "Ok: key(\"" : "FAIL: key(\""; msg2 = "\").compareTo(key(\""; msg3 = "\")) returned "; @@ -147,7 +150,7 @@ public class CollationCurrencyTest extends TestFmwk { msg2 = " vs. "; errln(msg1 + CollationTest.prettify(sourceKey) + msg2 + CollationTest.prettify(targetKey)); } - + msg1 = ok3 ? "Ok: incCompare(\"" : "FAIL: incCompare(\""; msg2 = "\", \""; msg3 = "\") returned "; @@ -158,7 +161,7 @@ public class CollationCurrencyTest extends TestFmwk { logln(msg1 + source + msg2 + target + msg3 + sResult); } else { errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect); - } + } } } } diff --git a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationDummyTest.java b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationDummyTest.java index a332bf8bd09..c785d3e4683 100644 --- a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationDummyTest.java +++ b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationDummyTest.java @@ -7,18 +7,20 @@ ******************************************************************************* */ -/** +/** * Port From: ICU4C v2.1 : Collate/CollationDummyTest * Source File: $ICU4CRoot/source/test/intltest/allcoll.cpp * $ICU4CRoot/source/test/cintltst/callcoll.c **/ - + package com.ibm.icu.dev.test.collator; - + import java.util.Locale; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.CollationElementIterator; @@ -26,7 +28,8 @@ import com.ibm.icu.text.CollationKey; import com.ibm.icu.text.Collator; import com.ibm.icu.text.Normalizer; import com.ibm.icu.text.RuleBasedCollator; - + +@RunWith(JUnit4.class) public class CollationDummyTest extends TestFmwk { //testSourceCases[][] and testTargetCases[][], testCases[][] are ported from the file callcoll.c in icu4c private static char[][] testSourceCases = { @@ -39,34 +42,34 @@ public class CollationDummyTest extends TestFmwk { {0x66, 0x69, 0x76, 0x65}, {0x31}, {0x31}, - {0x31}, // 10 + {0x31}, // 10 {0x32}, {0x32}, {0x48, 0x65, 0x6c, 0x6c, 0x6f}, {0x61, 0x3c, 0x62}, {0x61, 0x3c, 0x62}, {0x61, 0x63, 0x63}, - {0x61, 0x63, 0x48, 0x63}, // simple test + {0x61, 0x63, 0x48, 0x63}, // simple test {0x70, 0x00EA, 0x63, 0x68, 0x65}, {0x61, 0x62, 0x63}, - {0x61, 0x62, 0x63}, // 20 + {0x61, 0x62, 0x63}, // 20 {0x61, 0x62, 0x63}, {0x61, 0x62, 0x63}, {0x61, 0x62, 0x63}, {0x61, 0x00E6, 0x63}, - {0x61, 0x63, 0x48, 0x63}, // primary test + {0x61, 0x63, 0x48, 0x63}, // primary test {0x62, 0x6c, 0x61, 0x63, 0x6b}, {0x66, 0x6f, 0x75, 0x72}, {0x66, 0x69, 0x76, 0x65}, {0x31}, - {0x61, 0x62, 0x63}, // 30 - {0x61, 0x62, 0x63}, + {0x61, 0x62, 0x63}, // 30 + {0x61, 0x62, 0x63}, {0x61, 0x62, 0x63, 0x48}, {0x61, 0x62, 0x63}, - {0x61, 0x63, 0x48, 0x63}, // 34 + {0x61, 0x63, 0x48, 0x63}, // 34 {0x61, 0x63, 0x65, 0x30}, {0x31, 0x30}, - {0x70, 0x00EA,0x30} // 37 + {0x70, 0x00EA,0x30} // 37 }; private static char[][] testTargetCases = { @@ -79,36 +82,36 @@ public class CollationDummyTest extends TestFmwk { {0x35}, {0x6f, 0x6e, 0x65}, {0x6e, 0x6e, 0x65}, - {0x70, 0x6e, 0x65}, // 10 + {0x70, 0x6e, 0x65}, // 10 {0x74, 0x77, 0x6f}, {0x75, 0x77, 0x6f}, {0x68, 0x65, 0x6c, 0x6c, 0x4f}, {0x61, 0x3c, 0x3d, 0x62}, {0x61, 0x62, 0x63}, {0x61, 0x43, 0x48, 0x63}, - {0x61, 0x43, 0x48, 0x63}, // simple test + {0x61, 0x43, 0x48, 0x63}, // simple test {0x70, 0x00E9, 0x63, 0x68, 0x00E9}, {0x61, 0x62, 0x63}, - {0x61, 0x42, 0x43}, // 20 + {0x61, 0x42, 0x43}, // 20 {0x61, 0x62, 0x63, 0x68}, {0x61, 0x62, 0x64}, {0x00E4, 0x62, 0x63}, {0x61, 0x00C6, 0x63}, - {0x61, 0x43, 0x48, 0x63}, // primary test + {0x61, 0x43, 0x48, 0x63}, // primary test {0x62, 0x6c, 0x61, 0x63, 0x6b, 0x2d, 0x62, 0x69, 0x72, 0x64}, {0x34}, {0x35}, {0x6f, 0x6e, 0x65}, {0x61, 0x62, 0x63}, - {0x61, 0x42, 0x63}, // 30 + {0x61, 0x42, 0x63}, // 30 {0x61, 0x62, 0x63, 0x68}, {0x61, 0x62, 0x64}, - {0x61, 0x43, 0x48, 0x63}, // 34 + {0x61, 0x43, 0x48, 0x63}, // 34 {0x61, 0x63, 0x65, 0x30}, {0x31, 0x30}, - {0x70, 0x00EB,0x30} // 37 + {0x70, 0x00EB,0x30} // 37 }; - + private static char[][] testCases = { {0x61}, {0x41}, @@ -124,7 +127,7 @@ public class CollationDummyTest extends TestFmwk { {0x63}, {0x7a} }; - + int[] results = { -1, -1, //Collator::GREATER, @@ -135,7 +138,7 @@ public class CollationDummyTest extends TestFmwk { -1, 1, 1, - -1, // 10 + -1, // 10 1, -1, 1, @@ -143,44 +146,44 @@ public class CollationDummyTest extends TestFmwk { -1, -1, -1, - // test primary > 17 + // test primary > 17 0, 0, - 0, // 20 + 0, // 20 -1, -1, 0, 0, 0, -1, - // test secondary > 26 + // test secondary > 26 0, 0, 0, 0, - 0, // 30 + 0, // 30 0, -1, - 0, // 34 + 0, // 34 0, 0, - -1 + -1 }; - + final int MAX_TOKEN_LEN = 16; - + private RuleBasedCollator myCollation; - + public CollationDummyTest() { } - + @Before public void init() throws Exception { String ruleset = "& C < ch, cH, Ch, CH & Five, 5 & Four, 4 & one, 1 & Ampersand; '&' & Two, 2 "; // String ruleset = "& Four, 4"; myCollation = new RuleBasedCollator(ruleset); } - + // perform test with strength tertiary @Test public void TestTertiary() { @@ -194,7 +197,7 @@ public class CollationDummyTest extends TestFmwk { // perform test with strength PRIMARY @Test public void TestPrimary() { - // problem in strcollinc for unfinshed contractions + // problem in strcollinc for unfinshed contractions myCollation.setStrength(Collator.PRIMARY); for (int i = 17; i < 26 ; i++) { doTest(myCollation, testSourceCases[i], testTargetCases[i], results[i]); @@ -250,17 +253,17 @@ public class CollationDummyTest extends TestFmwk { errln("Comparing two strings with only secondary differences in C failed.\n"); return; } - - // To compare them with just primary differences + + // To compare them with just primary differences coll.setStrength(Collator.PRIMARY); result = coll.compare(source, target); - // result is 0 + // result is 0 if (result != 0) { errln("Comparing two strings with no differences in C failed.\n"); return; - } - - // Now, do the same comparison with keys + } + + // Now, do the same comparison with keys CollationKey sourceKeyOut, targetKeyOut; sourceKeyOut = coll.getCollationKey(source); targetKeyOut = coll.getCollationKey(target); @@ -270,38 +273,38 @@ public class CollationDummyTest extends TestFmwk { return; } } - + //TestSurrogates() is ported from cintltst/callcoll.c - + /** * Tests surrogate support. */ @Test - public void TestSurrogates() + public void TestSurrogates() { String rules = "&z<'\ud800\udc00'<'\ud800\udc0a\u0308' 1) @@ -349,13 +352,13 @@ public class CollationEnglishTest extends TestFmwk{ boolean ok3 = (incResult == expectedResult); if (ok1 && ok2 && ok3 && !isVerbose()){ - return; + return; }else{ String msg1 = ok1? "Ok: compare(\"" : "FAIL: compare(\""; String msg2 = "\", \""; String msg3 = "\") returned "; String msg4 = "; expected "; - + String sExpect = new String(""); String sResult = new String(""); sResult = CollationTest.appendCompareResult(compareResult, sResult); @@ -365,7 +368,7 @@ public class CollationEnglishTest extends TestFmwk{ } else { errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect); } - + msg1 = ok2 ? "Ok: key(\"" : "FAIL: key(\""; msg2 = "\").compareTo(key(\""; msg3 = "\")) returned "; @@ -378,7 +381,7 @@ public class CollationEnglishTest extends TestFmwk{ msg2 = " vs. "; errln(msg1 + CollationTest.prettify(sourceKey) + msg2 + CollationTest.prettify(targetKey)); } - + msg1 = ok3 ? "Ok: incCompare(\"" : "FAIL: incCompare(\""; msg2 = "\", \""; msg3 = "\") returned "; @@ -389,7 +392,7 @@ public class CollationEnglishTest extends TestFmwk{ logln(msg1 + source + msg2 + target + msg3 + sResult); } else { errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect); - } + } } } } diff --git a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationFinnishTest.java b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationFinnishTest.java index 14ad7e43c5a..7e4023cfcd7 100644 --- a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationFinnishTest.java +++ b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationFinnishTest.java @@ -7,21 +7,24 @@ ******************************************************************************* */ -/** +/** * Port From: ICU4C v2.1 : Collate/CollationFinnishTest * Source File: $ICU4CRoot/source/test/intltest/ficoll.cpp **/ - + package com.ibm.icu.dev.test.collator; - + import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.CollationKey; import com.ibm.icu.text.Collator; import com.ibm.icu.util.ULocale; - + +@RunWith(JUnit4.class) public class CollationFinnishTest extends TestFmwk { private static char[][] testSourceCases = { {0x77, 0x61, 0x74}, @@ -49,26 +52,26 @@ public class CollationFinnishTest extends TestFmwk { }; private Collator myCollation = null; - + public CollationFinnishTest() { } - + @Before public void init()throws Exception{ myCollation = Collator.getInstance(new ULocale("fi_FI@collation=standard")); } - - + + // perform tests with strength PRIMARY @Test public void TestPrimary() { int i = 0; myCollation.setStrength(Collator.PRIMARY); for(i = 4; i < 5; i++) { - doTest(testSourceCases[i], testTargetCases[i], results[i]); - } + doTest(testSourceCases[i], testTargetCases[i], results[i]); + } } - + // perform test with strength TERTIARY @Test public void TestTertiary() { @@ -76,9 +79,9 @@ public class CollationFinnishTest extends TestFmwk { myCollation.setStrength(Collator.TERTIARY); for(i = 0; i < 4; i++ ) { doTest(testSourceCases[i], testTargetCases[i], results[i]); - } + } } - + // main test routine, tests rules specific to the finish locale private void doTest(char[] source, char[] target, int result) { String s = new String(source); @@ -90,7 +93,7 @@ public class CollationFinnishTest extends TestFmwk { int keyResult = sortKey1.compareTo(sortKey2); reportCResult(s, t, sortKey1, sortKey2, compareResult, keyResult, compareResult, result); } - + private void reportCResult( String source, String target, CollationKey sourceKey, CollationKey targetKey, int compareResult, int keyResult, int incResult, int expectedResult ) { if (expectedResult < -1 || expectedResult > 1) { @@ -103,13 +106,13 @@ public class CollationFinnishTest extends TestFmwk { boolean ok3 = (incResult == expectedResult); if (ok1 && ok2 && ok3 && !isVerbose()) { - return; + return; } else { String msg1 = ok1? "Ok: compare(\"" : "FAIL: compare(\""; String msg2 = "\", \""; String msg3 = "\") returned "; String msg4 = "; expected "; - + String sExpect = new String(""); String sResult = new String(""); sResult = CollationTest.appendCompareResult(compareResult, sResult); @@ -119,7 +122,7 @@ public class CollationFinnishTest extends TestFmwk { } else { errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect); } - + msg1 = ok2 ? "Ok: key(\"" : "FAIL: key(\""; msg2 = "\").compareTo(key(\""; msg3 = "\")) returned "; @@ -132,7 +135,7 @@ public class CollationFinnishTest extends TestFmwk { msg2 = " vs. "; errln(msg1 + CollationTest.prettify(sourceKey) + msg2 + CollationTest.prettify(targetKey)); } - + msg1 = ok3 ? "Ok: incCompare(\"" : "FAIL: incCompare(\""; msg2 = "\", \""; msg3 = "\") returned "; @@ -143,7 +146,7 @@ public class CollationFinnishTest extends TestFmwk { logln(msg1 + source + msg2 + target + msg3 + sResult); } else { errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect); - } + } } } } diff --git a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationFrenchTest.java b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationFrenchTest.java index 9e383d49b92..d3d77f9bd66 100644 --- a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationFrenchTest.java +++ b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationFrenchTest.java @@ -7,23 +7,26 @@ ******************************************************************************* */ -/** +/** * Port From: ICU4C v2.1 : Collate/CollationFrenchTest * Source File: $ICU4CRoot/source/test/intltest/frcoll.cpp **/ - + package com.ibm.icu.dev.test.collator; - + import java.util.Locale; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.CollationKey; import com.ibm.icu.text.Collator; import com.ibm.icu.text.RuleBasedCollator; - + +@RunWith(JUnit4.class) public class CollationFrenchTest extends TestFmwk{ private static char[][] testSourceCases = { {0x0061/*'a'*/, 0x0062/*'b'*/, 0x0063/*'c'*/}, @@ -78,7 +81,7 @@ public class CollationFrenchTest extends TestFmwk{ /*02*/ {0x0065/*'e'*/, 0x0300, 0x0301, 0x0065/*'e'*/}, /*03*/ {0x0065/*'e'*/, 0x0300, 0x0065/*'e'*/}, /*04*/ {0x0065/*'e'*/, 0x0301, 0x0300, 0x0065/*'e'*/}, - /*05*/ {0x0065/*'e'*/, 0x0065/*'e'*/, 0x0301}, + /*05*/ {0x0065/*'e'*/, 0x0065/*'e'*/, 0x0301}, /*06*/ {0x0065/*'e'*/, 0x0301, 0x0065/*'e'*/, 0x0301}, /*07*/ {0x0065/*'e'*/, 0x0300, 0x0301, 0x0065/*'e'*/, 0x0301}, /*08*/ {0x0065/*'e'*/, 0x0300, 0x0065/*'e'*/, 0x0301}, @@ -112,29 +115,29 @@ public class CollationFrenchTest extends TestFmwk{ {0x0065/*'e'*/, 0x0061/*'a'*/}, {0x0078/*'x'*/} }; - - + + private Collator myCollation = null; - + public CollationFrenchTest() { } - + @Before public void init()throws Exception { myCollation = Collator.getInstance(Locale.CANADA_FRENCH); } - + // perform tests with strength TERTIARY @Test public void TestTertiary() { int i = 0; myCollation.setStrength(Collator.TERTIARY); - + for (i = 0; i < 12 ; i++) { doTest(testSourceCases[i], testTargetCases[i], results[i]); } } - + // perform tests with strength SECONDARY @Test public void TestSecondary() { @@ -144,7 +147,7 @@ public class CollationFrenchTest extends TestFmwk{ int expected; myCollation.setStrength(Collator.SECONDARY); - + for (i = 0; i < testAcute.length; i++) { for (j = 0; j < testAcute.length; j++) { if (i < j) { @@ -170,7 +173,7 @@ public class CollationFrenchTest extends TestFmwk{ } } } - + @Test public void TestContinuationReordering() { @@ -178,7 +181,7 @@ public class CollationFrenchTest extends TestFmwk{ try { RuleBasedCollator collator = new RuleBasedCollator(rule); collator.setFrenchCollation(true); - CollationKey key1 + CollationKey key1 = collator.getCollationKey("a\u0325\u2f00\u2f01b\u0325"); CollationKey key2 = collator.getCollationKey("a\u0325\u2f01\u2f01b\u0325"); @@ -189,7 +192,7 @@ public class CollationFrenchTest extends TestFmwk{ errln(e.toString()); } } - + // main test routine, test rules specific to the french locale private void doTest(char[] source, char[] target, int result) { String s = new String(source); @@ -199,9 +202,9 @@ public class CollationFrenchTest extends TestFmwk{ sortKey1 = myCollation.getCollationKey(s); sortKey2 = myCollation.getCollationKey(t); int keyResult = sortKey1.compareTo(sortKey2); - reportCResult(s, t, sortKey1, sortKey2, compareResult, keyResult, compareResult, result); + reportCResult(s, t, sortKey1, sortKey2, compareResult, keyResult, compareResult, result); } - + private void reportCResult( String source, String target, CollationKey sourceKey, CollationKey targetKey, int compareResult, int keyResult, int incResult, int expectedResult ) { if (expectedResult < -1 || expectedResult > 1) { @@ -214,13 +217,13 @@ public class CollationFrenchTest extends TestFmwk{ boolean ok3 = (incResult == expectedResult); if (ok1 && ok2 && ok3 && !isVerbose()) { - return; + return; } else { String msg1 = ok1? "Ok: compare(\"" : "FAIL: compare(\""; String msg2 = "\", \""; String msg3 = "\") returned "; String msg4 = "; expected "; - + String sExpect = new String(""); String sResult = new String(""); sResult = CollationTest.appendCompareResult(compareResult, sResult); @@ -230,7 +233,7 @@ public class CollationFrenchTest extends TestFmwk{ } else { errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect); } - + msg1 = ok2 ? "Ok: key(\"" : "FAIL: key(\""; msg2 = "\").compareTo(key(\""; msg3 = "\")) returned "; @@ -243,7 +246,7 @@ public class CollationFrenchTest extends TestFmwk{ msg2 = " vs. "; errln(msg1 + CollationTest.prettify(sourceKey) + msg2 + CollationTest.prettify(targetKey)); } - + msg1 = ok3 ? "Ok: incCompare(\"" : "FAIL: incCompare(\""; msg2 = "\", \""; msg3 = "\") returned "; @@ -254,7 +257,7 @@ public class CollationFrenchTest extends TestFmwk{ logln(msg1 + source + msg2 + target + msg3 + sResult); } else { errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect); - } + } } } -} +} diff --git a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationFrozenMonkeyTest.java b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationFrozenMonkeyTest.java index cbb089321e0..bb001e6626a 100644 --- a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationFrozenMonkeyTest.java +++ b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationFrozenMonkeyTest.java @@ -7,7 +7,7 @@ ******************************************************************************* */ -/** +/** * Port From: ICU4C v2.1 : collate/CollationMonkeyTest * Source File: $ICU4CRoot/source/test/intltest/mnkytst.cpp **/ @@ -18,6 +18,8 @@ import java.util.Locale; import java.util.Random; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.CollationKey; @@ -25,16 +27,17 @@ import com.ibm.icu.text.Collator; import com.ibm.icu.text.RuleBasedCollator; /** - * CollationFrozenMonkeyTest is a third level test class. This tests the random - * substrings of the default test strings to verify if the compare and + * CollationFrozenMonkeyTest is a third level test class. This tests the random + * substrings of the default test strings to verify if the compare and * sort key algorithm works correctly on frozen collators. For example, any string is always * less than the string itself appended with any character. */ +@RunWith(JUnit4.class) public class CollationFrozenMonkeyTest extends TestFmwk { - + private String source = "-abcdefghijklmnopqrstuvwxyz#&^$@"; - + @Test public void TestCollationKey() { if(source.length() == 0) { @@ -47,15 +50,15 @@ public class CollationFrozenMonkeyTest extends TestFmwk { try { Collator myCollator = Collator.getInstance(new Locale("en", "CA")); myCollator.freeze(); - + myPrimaryCollator = myCollator.cloneAsThawed(); myPrimaryCollator.setStrength(Collator.PRIMARY); myPrimaryCollator.freeze(); - + mySecondaryCollator = myPrimaryCollator.cloneAsThawed(); mySecondaryCollator.setStrength(Collator.SECONDARY); mySecondaryCollator.freeze(); - + myTertiaryCollator = mySecondaryCollator.cloneAsThawed(); myTertiaryCollator.setStrength(Collator.TERTIARY); myTertiaryCollator.freeze(); @@ -63,7 +66,7 @@ public class CollationFrozenMonkeyTest extends TestFmwk { warnln("ERROR: in creation of collator of ENGLISH locale"); return; } - + Random rand = createRandom(); // use test framework's random seed int s = rand.nextInt(0x7fff) % source.length(); int t = rand.nextInt(0x7fff) % source.length(); @@ -71,30 +74,30 @@ public class CollationFrozenMonkeyTest extends TestFmwk { int tlen = Math.abs(rand.nextInt(0x7fff) % source.length() - source.length()) % source.length(); String subs = source.substring(Math.min(s, slen), Math.min(s + slen, source.length())); String subt = source.substring(Math.min(t, tlen), Math.min(t + tlen, source.length())); - + CollationKey collationKey1, collationKey2; - + collationKey1 = myTertiaryCollator.getCollationKey(subs); collationKey2 = myTertiaryCollator.getCollationKey(subt); int result = collationKey1.compareTo(collationKey2); // Tertiary int revResult = collationKey2.compareTo(collationKey1); // Tertiary report( subs, subt, result, revResult); - + collationKey1 = mySecondaryCollator.getCollationKey(subs); collationKey2 = mySecondaryCollator.getCollationKey(subt); result = collationKey1.compareTo(collationKey2); // Secondary revResult = collationKey2.compareTo(collationKey1); // Secondary report( subs, subt, result, revResult); - + collationKey1 = myPrimaryCollator.getCollationKey(subs); collationKey2 = myPrimaryCollator.getCollationKey(subt); result = collationKey1.compareTo(collationKey2); // Primary revResult = collationKey2.compareTo(collationKey1); // Primary report(subs, subt, result, revResult); - + String msg = ""; String addOne = subs + String.valueOf(0xE000); - + collationKey1 = myPrimaryCollator.getCollationKey(subs); collationKey2 = myPrimaryCollator.getCollationKey(addOne); result = collationKey1.compareTo(collationKey2); @@ -106,7 +109,7 @@ public class CollationFrozenMonkeyTest extends TestFmwk { msg += ") Failed."; errln(msg); } - + msg = ""; result = collationKey2.compareTo(collationKey1); if (result != 1) { @@ -118,7 +121,7 @@ public class CollationFrozenMonkeyTest extends TestFmwk { errln(msg); } } - + // perform monkey tests using Collator.compare @Test public void TestCompare() { @@ -126,22 +129,22 @@ public class CollationFrozenMonkeyTest extends TestFmwk { errln("CollationMonkeyTest.TestCompare(): source is empty - ICU_DATA not set or data missing?"); return; } - + Collator myPrimaryCollator; Collator mySecondaryCollator; Collator myTertiaryCollator; try { Collator myCollator = Collator.getInstance(new Locale("en", "CA")); myCollator.freeze(); - + myPrimaryCollator = myCollator.cloneAsThawed(); myPrimaryCollator.setStrength(Collator.PRIMARY); myPrimaryCollator.freeze(); - + mySecondaryCollator = myPrimaryCollator.cloneAsThawed(); mySecondaryCollator.setStrength(Collator.SECONDARY); mySecondaryCollator.freeze(); - + myTertiaryCollator = mySecondaryCollator.cloneAsThawed(); myTertiaryCollator.setStrength(Collator.TERTIARY); myTertiaryCollator.freeze(); @@ -149,12 +152,12 @@ public class CollationFrozenMonkeyTest extends TestFmwk { warnln("ERROR: in creation of collator of ENGLISH locale"); return; } - - + + /* Seed the random-number generator with current time so that * the numbers will be different every time we run. */ - + Random rand = createRandom(); // use test framework's random seed int s = rand.nextInt(0x7fff) % source.length(); int t = rand.nextInt(0x7fff) % source.length(); @@ -162,22 +165,22 @@ public class CollationFrozenMonkeyTest extends TestFmwk { int tlen = Math.abs(rand.nextInt(0x7fff) % source.length() - source.length()) % source.length(); String subs = source.substring(Math.min(s, slen), Math.min(s + slen, source.length())); String subt = source.substring(Math.min(t, tlen), Math.min(t + tlen, source.length())); - + int result = myTertiaryCollator.compare(subs, subt); // Tertiary int revResult = myTertiaryCollator.compare(subt, subs); // Tertiary report(subs, subt, result, revResult); - + result = mySecondaryCollator.compare(subs, subt); // Secondary revResult = mySecondaryCollator.compare(subt, subs); // Secondary report(subs, subt, result, revResult); - + result = myPrimaryCollator.compare(subs, subt); // Primary revResult = myPrimaryCollator.compare(subt, subs); // Primary report(subs, subt, result, revResult); - + String msg = ""; String addOne = subs + String.valueOf(0xE000); - + result = myPrimaryCollator.compare(subs, addOne); if (result != -1) { msg += "Test : "; @@ -187,7 +190,7 @@ public class CollationFrozenMonkeyTest extends TestFmwk { msg += " Failed."; errln(msg); } - + msg = ""; result = myPrimaryCollator.compare(addOne, subs); if (result != 1) { @@ -199,31 +202,31 @@ public class CollationFrozenMonkeyTest extends TestFmwk { errln(msg); } } - + void report(String s, String t, int result, int revResult) { if (revResult != -result) { String msg = ""; - msg += s; + msg += s; msg += " and "; msg += t; msg += " round trip comparison failed"; - msg += " (result " + result + ", reverse Result " + revResult + ")"; + msg += " (result " + result + ", reverse Result " + revResult + ")"; errln(msg); } } - + @Test public void TestRules() { String testSourceCases[] = { - "\u0061\u0062\u007a", - "\u0061\u0062\u007a", + "\u0061\u0062\u007a", + "\u0061\u0062\u007a", }; - + String testTargetCases[] = { "\u0061\u0062\u00e4", "\u0061\u0062\u0061\u0308", }; - + int i=0; logln("Demo Test 1 : Create a new table collation with rules \"& z < 0x00e4\""); Collator col = Collator.getInstance(new Locale("en", "US")); @@ -237,7 +240,7 @@ public class CollationFrozenMonkeyTest extends TestFmwk { warnln( "Demo Test 1 Table Collation object creation failed."); return; } - + for(i=0; i<2; i++){ doTest(myCollation, testSourceCases[i], testTargetCases[i], -1); } @@ -254,11 +257,11 @@ public class CollationFrozenMonkeyTest extends TestFmwk { doTest(myCollation, testSourceCases[i], testTargetCases[i], -1); } } - + void doTest(RuleBasedCollator myCollation, String mysource, String target, int result) { int compareResult = myCollation.compare(source, target); CollationKey sortKey1, sortKey2; - + try { sortKey1 = myCollation.getCollationKey(source); sortKey2 = myCollation.getCollationKey(target); @@ -269,7 +272,7 @@ public class CollationFrozenMonkeyTest extends TestFmwk { int keyResult = sortKey1.compareTo(sortKey2); reportCResult( mysource, target, sortKey1, sortKey2, compareResult, keyResult, compareResult, result ); } - + public void reportCResult(String src, String target, CollationKey sourceKey, CollationKey targetKey, int compareResult, int keyResult, int incResult, int expectedResult ) { if (expectedResult < -1 || expectedResult > 1) { @@ -280,7 +283,7 @@ public class CollationFrozenMonkeyTest extends TestFmwk { boolean ok2 = (keyResult == expectedResult); boolean ok3 = (incResult == expectedResult); if (ok1 && ok2 && ok3 && !isVerbose()) { - return; + return; } else { String msg1 = ok1? "Ok: compare(\"" : "FAIL: compare(\""; String msg2 = "\", \""; @@ -315,7 +318,7 @@ public class CollationFrozenMonkeyTest extends TestFmwk { logln(msg1 + src + msg2 + target + msg3 + sResult); } else { errln(msg1 + src + msg2 + target + msg3 + sResult + msg4 + sExpect); - } + } } } } diff --git a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationGermanTest.java b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationGermanTest.java index e9917ea6708..8b97d1351af 100644 --- a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationGermanTest.java +++ b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationGermanTest.java @@ -7,23 +7,26 @@ ******************************************************************************* */ -/** +/** * Port From: ICU4C v2.1 : Collate/CollationGermanTest * Source File: $ICU4CRoot/source/test/intltest/decoll.cpp **/ - + package com.ibm.icu.dev.test.collator; - + import java.util.Locale; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.CollationKey; import com.ibm.icu.text.Collator; - - public class CollationGermanTest extends TestFmwk{ + +@RunWith(JUnit4.class) +public class CollationGermanTest extends TestFmwk{ private static char[][] testSourceCases = { {0x47, 0x72, 0x00F6, 0x00DF, 0x65}, {0x61, 0x62, 0x63}, @@ -70,12 +73,12 @@ import com.ibm.icu.text.Collator; { -1, -1 }, { 0, 1 } }; - + private Collator myCollation = null; - + public CollationGermanTest() { } - + @Before public void init() throws Exception { myCollation = Collator.getInstance(Locale.GERMAN); @@ -100,13 +103,13 @@ import com.ibm.icu.text.Collator; doTest(testSourceCases[i], testTargetCases[i], results[i][1]); } } - + // perform test with strength SECONDARY //This method in icu4c has no implementation. @Test public void TestSecondary(){ } - + // perform test with strength PRIMARY @Test public void TestPrimary(){ @@ -122,8 +125,8 @@ import com.ibm.icu.text.Collator; doTest(testSourceCases[i], testTargetCases[i], results[i][0]); } } - - + + //main test routine, tests rules specific to germa locale private void doTest(char[] source, char[] target, int result){ String s = new String(source); @@ -134,9 +137,9 @@ import com.ibm.icu.text.Collator; sortKey2 = myCollation.getCollationKey(t); int keyResult = sortKey1.compareTo(sortKey2); reportCResult(s, t, sortKey1, sortKey2, compareResult, keyResult, compareResult, result); - + } - + private void reportCResult( String source, String target, CollationKey sourceKey, CollationKey targetKey, int compareResult, int keyResult, int incResult, int expectedResult ){ if (expectedResult < -1 || expectedResult > 1) @@ -150,13 +153,13 @@ import com.ibm.icu.text.Collator; boolean ok3 = (incResult == expectedResult); if (ok1 && ok2 && ok3 && !isVerbose()){ - return; + return; }else{ String msg1 = ok1? "Ok: compare(\"" : "FAIL: compare(\""; String msg2 = "\", \""; String msg3 = "\") returned "; String msg4 = "; expected "; - + String sExpect = new String(""); String sResult = new String(""); sResult = CollationTest.appendCompareResult(compareResult, sResult); @@ -166,7 +169,7 @@ import com.ibm.icu.text.Collator; } else { errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect); } - + msg1 = ok2 ? "Ok: key(\"" : "FAIL: key(\""; msg2 = "\").compareTo(key(\""; msg3 = "\")) returned "; @@ -179,7 +182,7 @@ import com.ibm.icu.text.Collator; msg2 = " vs. "; errln(msg1 + CollationTest.prettify(sourceKey) + msg2 + CollationTest.prettify(targetKey)); } - + msg1 = ok3 ? "Ok: incCompare(\"" : "FAIL: incCompare(\""; msg2 = "\", \""; msg3 = "\") returned "; @@ -190,7 +193,7 @@ import com.ibm.icu.text.Collator; logln(msg1 + source + msg2 + target + msg3 + sResult); } else { errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect); - } + } } } } diff --git a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationIteratorTest.java b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationIteratorTest.java index a746f94b62a..15ff81d10e9 100644 --- a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationIteratorTest.java +++ b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationIteratorTest.java @@ -7,7 +7,7 @@ ******************************************************************************* */ -/** +/** * Port From: ICU4C v2.1 : collate/CollationIteratorTest * Source File: $ICU4CRoot/source/test/intltest/itercoll.cpp **/ @@ -20,6 +20,8 @@ import java.util.Arrays; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.lang.UCharacter; @@ -29,11 +31,12 @@ import com.ibm.icu.text.RuleBasedCollator; import com.ibm.icu.text.UCharacterIterator; import com.ibm.icu.util.ULocale; +@RunWith(JUnit4.class) public class CollationIteratorTest extends TestFmwk { - + String test1 = "What subset of all possible test cases?"; String test2 = "has the highest probability of detecting"; - + /* * @bug 4157299 */ @@ -46,7 +49,7 @@ public class CollationIteratorTest extends TestFmwk { warnln("Couldn't create a RuleBasedCollator."); return; } - + String source = "abcd"; CollationElementIterator i = c.getCollationElementIterator(source); int e0 = 0; @@ -56,27 +59,27 @@ public class CollationIteratorTest extends TestFmwk { errln("call to i.next() failed."); return; } - + try { i.setOffset(3); // go to the expanding character } catch (Exception e) { errln("call to i.setOffset(3) failed."); return; } - + try { i.next(); // but only use up half of it } catch (Exception e) { errln("call to i.next() failed."); return; } - + try { i.setOffset(0); // go back to the beginning } catch (Exception e) { errln("call to i.setOffset(0) failed. "); } - + int e = 0; try { e = i.next(); // and get this one again @@ -84,12 +87,12 @@ public class CollationIteratorTest extends TestFmwk { errln("call to i.next() failed. "); return; } - + if (e != e0) { errln("got 0x" + Integer.toHexString(e) + ", expected 0x" + Integer.toHexString(e0)); } } - + /** @bug 4108762 * Test for getMaxExpansion() */ @@ -106,37 +109,37 @@ public class CollationIteratorTest extends TestFmwk { } char ch = 0; String str = String.valueOf(ch); - + CollationElementIterator iter = coll.getCollationElementIterator(str); - + while (ch < 0xFFFF) { int count = 1; ch ++; str = String.valueOf(ch); iter.setText(str); int order = iter.previous(); - - // thai management + + // thai management if (order == 0) { order = iter.previous(); } - + while (iter.previous() != CollationElementIterator.NULLORDER) { - count ++; + count ++; } - + if (iter.getMaxExpansion(order) < count) { errln("Failure at codepoint " + ch + ", maximum expansion count < " + count); } } - - // testing for exact max expansion + + // testing for exact max expansion ch = 0; while (ch < 0x61) { str = String.valueOf(ch); iter.setText(str); int order = iter.previous(); - + if (iter.getMaxExpansion(order) != 1) { errln("Failure at codepoint 0x" + Integer.toHexString(ch) + " maximum expansion count == 1"); @@ -148,7 +151,7 @@ public class CollationIteratorTest extends TestFmwk { str = String.valueOf(ch); iter.setText(str); int temporder = iter.previous(); - + if (iter.getMaxExpansion(temporder) != 3) { errln("Failure at codepoint 0x" + Integer.toHexString(ch) + " maximum expansion count == 3"); @@ -158,7 +161,7 @@ public class CollationIteratorTest extends TestFmwk { str = String.valueOf(ch); iter.setText(str); temporder = iter.previous(); - + if (iter.getMaxExpansion(temporder) != 1) { errln("Failure at codepoint 0x" + Integer.toHexString(ch) + " maximum expansion count == 1"); @@ -167,7 +170,7 @@ public class CollationIteratorTest extends TestFmwk { str = UCharacter.toString(unassigned); iter.setText(str); temporder = iter.previous(); - + if (iter.getMaxExpansion(temporder) != 2) { errln("Failure at codepoint 0x" + Integer.toHexString(ch) + " maximum expansion count == 2"); @@ -179,7 +182,7 @@ public class CollationIteratorTest extends TestFmwk { str = String.valueOf(ch); iter.setText(str); temporder = iter.previous(); - + if (iter.getMaxExpansion(temporder) > 3) { errln("Failure at codepoint 0x" + Integer.toHexString(ch) + " maximum expansion count < 3"); @@ -195,15 +198,15 @@ public class CollationIteratorTest extends TestFmwk { return; } iter = coll.getCollationElementIterator(str); - + temporder = iter.previous(); - + if (iter.getMaxExpansion(temporder) != 6) { errln("Failure at codepoint 0x" + Integer.toHexString(ch) + " maximum expansion count == 6"); } } - + /** * Test for getOffset() and setOffset() */ @@ -211,7 +214,7 @@ public class CollationIteratorTest extends TestFmwk { public void TestOffset(/* char* par */) { RuleBasedCollator en_us; try { - en_us = (RuleBasedCollator)Collator.getInstance(Locale.US); + en_us = (RuleBasedCollator)Collator.getInstance(Locale.US); } catch (Exception e) { warnln("ERROR: in creation of collator of ENGLISH locale"); return; @@ -226,32 +229,32 @@ public class CollationIteratorTest extends TestFmwk { } iter.setOffset(test1.length()); if (iter.next() != CollationElementIterator.NULLORDER) { - errln("Error: After setting offset to the end of the string, we " + errln("Error: After setting offset to the end of the string, we " + "should be at the end of the forwards iteration"); } - + // Run all the way through the iterator, then get the offset int[] orders = CollationTest.getOrders(iter); logln("orders.length = " + orders.length); - + int offset = iter.getOffset(); - + if (offset != test1.length()) { String msg1 = "offset at end != length: "; String msg2 = " vs "; errln(msg1 + offset + msg2 + test1.length()); } - + // Now set the offset back to the beginning and see if it works CollationElementIterator pristine = en_us.getCollationElementIterator(test1); - + try { iter.setOffset(0); } catch(Exception e) { errln("setOffset failed."); } assertEqual(iter, pristine); - + // setting offset in the middle of a contraction String contraction = "change"; RuleBasedCollator tailored = null; @@ -297,8 +300,8 @@ public class CollationIteratorTest extends TestFmwk { } // TODO: try iterating halfway through a messy string. } - - + + void assertEqual(CollationElementIterator i1, CollationElementIterator i2) { int c1, c2, count = 0; @@ -306,7 +309,7 @@ public class CollationIteratorTest extends TestFmwk { c1 = i1.next(); c2 = i2.next(); if (c1 != c2) { - errln(" " + count + ": strength(0x" + + errln(" " + count + ": strength(0x" + Integer.toHexString(c1) + ") != strength(0x" + Integer.toHexString(c2) + ")"); break; } @@ -315,21 +318,21 @@ public class CollationIteratorTest extends TestFmwk { CollationTest.backAndForth(this, i1); CollationTest.backAndForth(this, i2); } - + /** * Test for CollationElementIterator.previous() * * @bug 4108758 - Make sure it works with contracting characters - * + * */ @Test public void TestPrevious(/* char* par */) { RuleBasedCollator en_us = (RuleBasedCollator)Collator.getInstance(Locale.US); CollationElementIterator iter = en_us.getCollationElementIterator(test1); - + // A basic test to see if it's working at all CollationTest.backAndForth(this, iter); - + // Test with a contracting character sequence String source; RuleBasedCollator c1 = null; @@ -339,11 +342,11 @@ public class CollationIteratorTest extends TestFmwk { errln("Couldn't create a RuleBasedCollator with a contracting sequence."); return; } - + source = "abchdcba"; iter = c1.getCollationElementIterator(source); CollationTest.backAndForth(this, iter); - + // Test with an expanding character sequence RuleBasedCollator c2 = null; try { @@ -352,11 +355,11 @@ public class CollationIteratorTest extends TestFmwk { errln("Couldn't create a RuleBasedCollator with an expanding sequence."); return; } - + source = "abcd"; iter = c2.getCollationElementIterator(source); CollationTest.backAndForth(this, iter); - + // Now try both RuleBasedCollator c3 = null; try { @@ -365,11 +368,11 @@ public class CollationIteratorTest extends TestFmwk { errln("Couldn't create a RuleBasedCollator with both an expanding and a contracting sequence."); return; } - + source = "abcdbchdc"; iter = c3.getCollationElementIterator(source); CollationTest.backAndForth(this, iter); - + source= "\u0e41\u0e02\u0e41\u0e02\u0e27abc"; Collator c4 = null; try { @@ -378,10 +381,10 @@ public class CollationIteratorTest extends TestFmwk { errln("Couldn't create a collator"); return; } - + iter = ((RuleBasedCollator)c4).getCollationElementIterator(source); CollationTest.backAndForth(this, iter); - + source= "\u0061\u30CF\u3099\u30FC"; Collator c5 = null; try { @@ -391,12 +394,12 @@ public class CollationIteratorTest extends TestFmwk { return; } iter = ((RuleBasedCollator)c5).getCollationElementIterator(source); - + CollationTest.backAndForth(this, iter); } - - - + + + /** * Test for setText() */ @@ -405,11 +408,11 @@ public class CollationIteratorTest extends TestFmwk { RuleBasedCollator en_us = (RuleBasedCollator)Collator.getInstance(Locale.US); CollationElementIterator iter1 = en_us.getCollationElementIterator(test1); CollationElementIterator iter2 = en_us.getCollationElementIterator(test2); - + // Run through the second iterator just to exercise it int c = iter2.next(); int i = 0; - + while ( ++i < 10 && c != CollationElementIterator.NULLORDER) { try { c = iter2.next(); @@ -418,7 +421,7 @@ public class CollationIteratorTest extends TestFmwk { break; } } - + // Now set it to point to the same string as the first iterator try { iter2.setText(test1); @@ -427,7 +430,7 @@ public class CollationIteratorTest extends TestFmwk { return; } assertEqual(iter1, iter2); - + iter1.reset(); //now use the overloaded setText(ChracterIterator&, UErrorCode) function to set the text CharacterIterator chariter = new StringCharacterIterator(test1); @@ -438,7 +441,7 @@ public class CollationIteratorTest extends TestFmwk { return; } assertEqual(iter1, iter2); - + iter1.reset(); //now use the overloaded setText(ChracterIterator&, UErrorCode) function to set the text UCharacterIterator uchariter = UCharacterIterator.getInstance(test1); @@ -464,7 +467,7 @@ public class CollationIteratorTest extends TestFmwk { source.append("\u0e4d\u0e4e\u0e4f"); // source.append("\u04e8\u04e9"); iter = en_us.getCollationElementIterator(source.toString()); - // A basic test to see if it's working at all + // A basic test to see if it's working at all CollationTest.backAndForth(this, iter); for (codepoint = 1; codepoint < 0xFFFE;) { source.delete(0, source.length()); @@ -474,11 +477,11 @@ public class CollationIteratorTest extends TestFmwk { } codepoint ++; } - + if (UCharacter.isDefined(codepoint)) { source.append(codepoint); } - + if (codepoint != 0xFFFF) { codepoint ++; } @@ -486,18 +489,18 @@ public class CollationIteratorTest extends TestFmwk { System.out.println("codepoint " + Integer.toHexString(codepoint)); String str = source.substring(230, 232); System.out.println(com.ibm.icu.impl.Utility.escape(str)); - System.out.println("codepoint " + Integer.toHexString(codepoint) + System.out.println("codepoint " + Integer.toHexString(codepoint) + "length " + str.length()); iter = en_us.getCollationElementIterator(str); CollationTest.backAndForth(this, iter); } */ iter = en_us.getCollationElementIterator(source.toString()); - // A basic test to see if it's working at all + // A basic test to see if it's working at all CollationTest.backAndForth(this, iter); } } - + /** * Test for CollationElementIterator previous and next for the whole set of * unicode characters with normalization on. @@ -516,7 +519,7 @@ public class CollationIteratorTest extends TestFmwk { } StringBuffer source = new StringBuffer(); source.append('\uFDFA'); - CollationElementIterator iter + CollationElementIterator iter = th_th.getCollationElementIterator(source.toString()); CollationTest.backAndForth(this, iter); for (char codepoint = 0x1; codepoint < 0xfffe;) { @@ -527,35 +530,35 @@ public class CollationIteratorTest extends TestFmwk { } codepoint ++; } - + if (UCharacter.isDefined(codepoint)) { source.append(codepoint); } - + if (codepoint != 0xFFFF) { codepoint ++; } - + /*if (((int)codepoint) >= 0xfe00) { String str = source.substring(185, 190); System.out.println(com.ibm.icu.impl.Utility.escape(str)); - System.out.println("codepoint " - + Integer.toHexString(codepoint) + System.out.println("codepoint " + + Integer.toHexString(codepoint) + "length " + str.length()); iter = th_th.getCollationElementIterator(str); CollationTest.backAndForth(this, iter); */ iter = th_th.getCollationElementIterator(source.toString()); - // A basic test to see if it's working at all + // A basic test to see if it's working at all CollationTest.backAndForth(this, iter); } } - + /** * Testing the discontiguous contractions */ @Test - public void TestDiscontiguous() + public void TestDiscontiguous() { String rulestr ="&z < AB < X\u0300 < ABC < X\u0300\u0315"; String src[] = {"ADB", "ADBC", "A\u0315B", "A\u0315BC", @@ -566,11 +569,11 @@ public class CollationIteratorTest extends TestFmwk { // blocking combining character "X\u0314\u0300", "X\u0314\u0300\u0315", // contraction prefix - "ABDC", "AB\u0315C","X\u0300D\u0315", + "ABDC", "AB\u0315C","X\u0300D\u0315", "X\u0300\u0319\u0315", "X\u0300\u031A\u0315", // ends not with a contraction character - "X\u0319\u0300D", "X\u0319\u0300\u0315D", - "X\u0300D\u0315D", "X\u0300\u0319\u0315D", + "X\u0319\u0300D", "X\u0319\u0300\u0315D", + "X\u0300D\u0315D", "X\u0300\u0319\u0315D", "X\u0300\u031A\u0315D" }; String tgt[] = {// non blocking combining character @@ -582,20 +585,20 @@ public class CollationIteratorTest extends TestFmwk { // blocking combining character "X \u0314 \u0300", "X \u0314 \u0300\u0315", // contraction prefix - "AB DC", "AB \u0315 C","X\u0300 D \u0315", + "AB DC", "AB \u0315 C","X\u0300 D \u0315", "X\u0300\u0315 \u0319", "X\u0300 \u031A \u0315", // ends not with a contraction character - "X\u0300 \u0319D", "X\u0300\u0315 \u0319D", - "X\u0300 D\u0315D", "X\u0300\u0315 \u0319D", + "X\u0300 \u0319D", "X\u0300\u0315 \u0319D", + "X\u0300 D\u0315D", "X\u0300\u0315 \u0319D", "X\u0300 \u031A\u0315D" }; int count = 0; try { RuleBasedCollator coll = new RuleBasedCollator(rulestr); - CollationElementIterator iter + CollationElementIterator iter + = coll.getCollationElementIterator(""); + CollationElementIterator resultiter = coll.getCollationElementIterator(""); - CollationElementIterator resultiter - = coll.getCollationElementIterator(""); while (count < src.length) { iter.setText(src[count]); int s = 0; @@ -609,7 +612,7 @@ public class CollationIteratorTest extends TestFmwk { int ce = resultiter.next(); while (ce != CollationElementIterator.NULLORDER) { if (ce != iter.next()) { - errln("Discontiguos contraction test mismatch at" + errln("Discontiguos contraction test mismatch at" + count); return; } @@ -649,7 +652,7 @@ public class CollationIteratorTest extends TestFmwk { warnln("ERROR: in creation of collator using rules " + rules); return; } - + CollationElementIterator iter = coll.getCollationElementIterator("testing"); for (int count = 0; count < testdata.length; count ++) { iter.setText(testdata[count]); @@ -683,7 +686,7 @@ public class CollationIteratorTest extends TestFmwk { " \u00E6" + // small letter ae, expands " \u1E4D" + // small letter o with tilde and acute, decomposes " "; - + int[] rootStandardOffsets = { 0, 1,2, 2, 3,4,4, @@ -698,7 +701,7 @@ public class CollationIteratorTest extends TestFmwk { 28, 29 }; - + int[] rootSearchOffsets = { 0, 1,2, 2, 3,4,4, @@ -724,7 +727,7 @@ public class CollationIteratorTest extends TestFmwk { public String getLocaleString() { return localeString; } public int[] getOffsets() { return offsets; } } - final TSCEItem[] tsceItems = { + final TSCEItem[] tsceItems = { new TSCEItem( "root", rootStandardOffsets ), new TSCEItem( "root@collation=search", rootSearchOffsets ), }; diff --git a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationKanaTest.java b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationKanaTest.java index 8fbf8c0e04d..b9745ec9380 100644 --- a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationKanaTest.java +++ b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationKanaTest.java @@ -7,24 +7,27 @@ ******************************************************************************* */ -/** +/** * Port From: ICU4C v2.1 : Collate/CollationKanaTest * Source File: $ICU4CRoot/source/test/intltest/jacoll.cpp **/ - + package com.ibm.icu.dev.test.collator; - + import java.util.Locale; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.CollationKey; import com.ibm.icu.text.Collator; import com.ibm.icu.text.RuleBasedCollator; import com.ibm.icu.util.ULocale; - + +@RunWith(JUnit4.class) public class CollationKanaTest extends TestFmwk{ private static char[][] testSourceCases = { {0xff9E}, @@ -91,16 +94,16 @@ public class CollationKanaTest extends TestFmwk{ /*4*/ {0x30AD, 0x30A4, 0x3042}, /*5*/ {0x30AD, 0x30A4, 0x30A2} }; - + private Collator myCollation = null; - + public CollationKanaTest() { } - + @Before - public void init()throws Exception { + public void init()throws Exception { if(myCollation==null){ - myCollation = Collator.getInstance(Locale.JAPANESE); + myCollation = Collator.getInstance(Locale.JAPANESE); } } @@ -109,7 +112,7 @@ public class CollationKanaTest extends TestFmwk{ public void TestTertiary() { int i = 0; myCollation.setStrength(Collator.TERTIARY); - + for (i = 0; i < 6; i++) { doTest(testSourceCases[i], testTargetCases[i], results[i]); } @@ -135,7 +138,7 @@ public class CollationKanaTest extends TestFmwk{ } } - /* + /* * Test Small, Large letters */ @Test @@ -171,7 +174,7 @@ public class CollationKanaTest extends TestFmwk{ doTest(testChooonKigooCases[i], testChooonKigooCases[i + 1], -1); } } - + /* * Test common Hiragana and Katakana characters (e.g. 0x3099) (ticket:6140) */ @@ -186,20 +189,20 @@ public class CollationKanaTest extends TestFmwk{ RuleBasedCollator rb = (RuleBasedCollator)Collator.getInstance(ULocale.JAPANESE); rb.setStrength(Collator.QUATERNARY); rb.setAlternateHandlingShifted(false); - + result = rb.compare(string1, string2); - + key1 = rb.getCollationKey(string1); key2 = rb.getCollationKey(string2); - + if ( result != 0 || !key1.equals(key2)) { errln("Failed Hiragana and Katakana common characters test. Expected results to be equal."); } - + } // main test routine, tests rules specific to "Kana" locale private void doTest(char[] source, char[] target, int result){ - + String s = new String(source); String t = new String(target); int compareResult = myCollation.compare(s, t); @@ -208,9 +211,9 @@ public class CollationKanaTest extends TestFmwk{ sortKey2 = myCollation.getCollationKey(t); int keyResult = sortKey1.compareTo(sortKey2); reportCResult(s, t, sortKey1, sortKey2, compareResult, keyResult, compareResult, result); - + } - + private void reportCResult( String source, String target, CollationKey sourceKey, CollationKey targetKey, int compareResult, int keyResult, int incResult, int expectedResult ){ if (expectedResult < -1 || expectedResult > 1) { @@ -223,13 +226,13 @@ public class CollationKanaTest extends TestFmwk{ boolean ok3 = (incResult == expectedResult); if (ok1 && ok2 && ok3 && !isVerbose()){ - return; + return; } else { String msg1 = ok1? "Ok: compare(\"" : "FAIL: compare(\""; String msg2 = "\", \""; String msg3 = "\") returned "; String msg4 = "; expected "; - + String sExpect = new String(""); String sResult = new String(""); sResult = CollationTest.appendCompareResult(compareResult, sResult); @@ -239,7 +242,7 @@ public class CollationKanaTest extends TestFmwk{ } else { errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect); } - + msg1 = ok2 ? "Ok: key(\"" : "FAIL: key(\""; msg2 = "\").compareTo(key(\""; msg3 = "\")) returned "; @@ -252,7 +255,7 @@ public class CollationKanaTest extends TestFmwk{ msg2 = " vs. "; errln(msg1 + CollationTest.prettify(sourceKey) + msg2 + CollationTest.prettify(targetKey)); } - + msg1 = ok3 ? "Ok: incCompare(\"" : "FAIL: incCompare(\""; msg2 = "\", \""; msg3 = "\") returned "; @@ -263,7 +266,7 @@ public class CollationKanaTest extends TestFmwk{ logln(msg1 + source + msg2 + target + msg3 + sResult); } else { errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect); - } + } } } } diff --git a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationMiscTest.java b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationMiscTest.java index 60cc4e3ed34..f008297fd07 100644 --- a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationMiscTest.java +++ b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationMiscTest.java @@ -20,6 +20,8 @@ import java.util.Set; import java.util.TreeSet; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.ICUData; @@ -40,6 +42,7 @@ import com.ibm.icu.text.UnicodeSetIterator; import com.ibm.icu.util.ULocale; import com.ibm.icu.util.UResourceBundle; +@RunWith(JUnit4.class) public class CollationMiscTest extends TestFmwk { //private static final int NORM_BUFFER_TEST_LEN_ = 32; private static final class Tester diff --git a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationMonkeyTest.java b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationMonkeyTest.java index ed6109ef143..e2bb9f4a2ca 100644 --- a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationMonkeyTest.java +++ b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationMonkeyTest.java @@ -7,7 +7,7 @@ ******************************************************************************* */ -/** +/** * Port From: ICU4C v2.1 : collate/CollationMonkeyTest * Source File: $ICU4CRoot/source/test/intltest/mnkytst.cpp **/ @@ -18,6 +18,8 @@ import java.util.Locale; import java.util.Random; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.CollationKey; @@ -25,16 +27,17 @@ import com.ibm.icu.text.Collator; import com.ibm.icu.text.RuleBasedCollator; /** - * CollationMonkeyTest is a third level test class. This tests the random - * substrings of the default test strings to verify if the compare and + * CollationMonkeyTest is a third level test class. This tests the random + * substrings of the default test strings to verify if the compare and * sort key algorithm works correctly. For example, any string is always * less than the string itself appended with any character. */ +@RunWith(JUnit4.class) public class CollationMonkeyTest extends TestFmwk { - + private String source = "-abcdefghijklmnopqrstuvwxyz#&^$@"; - + @Test public void TestCollationKey() { if(source.length() == 0) { @@ -48,7 +51,7 @@ public class CollationMonkeyTest extends TestFmwk { warnln("ERROR: in creation of collator of ENGLISH locale"); return; } - + Random rand = createRandom(); // use test framework's random seed int s = rand.nextInt(0x7fff) % source.length(); int t = rand.nextInt(0x7fff) % source.length(); @@ -56,33 +59,33 @@ public class CollationMonkeyTest extends TestFmwk { int tlen = Math.abs(rand.nextInt(0x7fff) % source.length() - source.length()) % source.length(); String subs = source.substring(Math.min(s, slen), Math.min(s + slen, source.length())); String subt = source.substring(Math.min(t, tlen), Math.min(t + tlen, source.length())); - + CollationKey collationKey1, collationKey2; - + myCollator.setStrength(Collator.TERTIARY); collationKey1 = myCollator.getCollationKey(subs); collationKey2 = myCollator.getCollationKey(subt); int result = collationKey1.compareTo(collationKey2); // Tertiary int revResult = collationKey2.compareTo(collationKey1); // Tertiary report( subs, subt, result, revResult); - + myCollator.setStrength(Collator.SECONDARY); collationKey1 = myCollator.getCollationKey(subs); collationKey2 = myCollator.getCollationKey(subt); result = collationKey1.compareTo(collationKey2); // Secondary revResult = collationKey2.compareTo(collationKey1); // Secondary report( subs, subt, result, revResult); - + myCollator.setStrength(Collator.PRIMARY); collationKey1 = myCollator.getCollationKey(subs); collationKey2 = myCollator.getCollationKey(subt); result = collationKey1.compareTo(collationKey2); // Primary revResult = collationKey2.compareTo(collationKey1); // Primary report(subs, subt, result, revResult); - + String msg = ""; String addOne = subs + String.valueOf(0xE000); - + collationKey1 = myCollator.getCollationKey(subs); collationKey2 = myCollator.getCollationKey(addOne); result = collationKey1.compareTo(collationKey2); @@ -94,7 +97,7 @@ public class CollationMonkeyTest extends TestFmwk { msg += ") Failed."; errln(msg); } - + msg = ""; result = collationKey2.compareTo(collationKey1); if (result != 1) { @@ -106,7 +109,7 @@ public class CollationMonkeyTest extends TestFmwk { errln(msg); } } - + // perform monkey tests using Collator.compare @Test public void TestCompare() { @@ -114,7 +117,7 @@ public class CollationMonkeyTest extends TestFmwk { errln("CollationMonkeyTest.TestCompare(): source is empty - ICU_DATA not set or data missing?"); return; } - + Collator myCollator; try { myCollator = Collator.getInstance(new Locale("en", "US")); @@ -122,11 +125,11 @@ public class CollationMonkeyTest extends TestFmwk { warnln("ERROR: in creation of collator of ENGLISH locale"); return; } - + /* Seed the random-number generator with current time so that * the numbers will be different every time we run. */ - + Random rand = createRandom(); // use test framework's random seed int s = rand.nextInt(0x7fff) % source.length(); int t = rand.nextInt(0x7fff) % source.length(); @@ -134,25 +137,25 @@ public class CollationMonkeyTest extends TestFmwk { int tlen = Math.abs(rand.nextInt(0x7fff) % source.length() - source.length()) % source.length(); String subs = source.substring(Math.min(s, slen), Math.min(s + slen, source.length())); String subt = source.substring(Math.min(t, tlen), Math.min(t + tlen, source.length())); - + myCollator.setStrength(Collator.TERTIARY); int result = myCollator.compare(subs, subt); // Tertiary int revResult = myCollator.compare(subt, subs); // Tertiary report(subs, subt, result, revResult); - + myCollator.setStrength(Collator.SECONDARY); result = myCollator.compare(subs, subt); // Secondary revResult = myCollator.compare(subt, subs); // Secondary report(subs, subt, result, revResult); - + myCollator.setStrength(Collator.PRIMARY); result = myCollator.compare(subs, subt); // Primary revResult = myCollator.compare(subt, subs); // Primary report(subs, subt, result, revResult); - + String msg = ""; String addOne = subs + String.valueOf(0xE000); - + result = myCollator.compare(subs, addOne); if (result != -1) { msg += "Test : "; @@ -162,7 +165,7 @@ public class CollationMonkeyTest extends TestFmwk { msg += " Failed."; errln(msg); } - + msg = ""; result = myCollator.compare(addOne, subs); if (result != 1) { @@ -174,31 +177,31 @@ public class CollationMonkeyTest extends TestFmwk { errln(msg); } } - + void report(String s, String t, int result, int revResult) { if (revResult != -result) { String msg = ""; - msg += s; + msg += s; msg += " and "; msg += t; msg += " round trip comparison failed"; - msg += " (result " + result + ", reverse Result " + revResult + ")"; + msg += " (result " + result + ", reverse Result " + revResult + ")"; errln(msg); } } - + @Test public void TestRules() { String testSourceCases[] = { - "\u0061\u0062\u007a", - "\u0061\u0062\u007a", + "\u0061\u0062\u007a", + "\u0061\u0062\u007a", }; - + String testTargetCases[] = { "\u0061\u0062\u00e4", "\u0061\u0062\u0061\u0308", }; - + int i=0; logln("Demo Test 1 : Create a new table collation with rules \"& z < 0x00e4\""); Collator col = Collator.getInstance(new Locale("en", "US")); @@ -212,7 +215,7 @@ public class CollationMonkeyTest extends TestFmwk { warnln( "Demo Test 1 Table Collation object creation failed."); return; } - + for(i=0; i<2; i++){ doTest(myCollation, testSourceCases[i], testTargetCases[i], -1); } @@ -229,11 +232,11 @@ public class CollationMonkeyTest extends TestFmwk { doTest(myCollation, testSourceCases[i], testTargetCases[i], -1); } } - + void doTest(RuleBasedCollator myCollation, String mysource, String target, int result) { int compareResult = myCollation.compare(source, target); CollationKey sortKey1, sortKey2; - + try { sortKey1 = myCollation.getCollationKey(source); sortKey2 = myCollation.getCollationKey(target); @@ -244,7 +247,7 @@ public class CollationMonkeyTest extends TestFmwk { int keyResult = sortKey1.compareTo(sortKey2); reportCResult( mysource, target, sortKey1, sortKey2, compareResult, keyResult, compareResult, result ); } - + public void reportCResult(String src, String target, CollationKey sourceKey, CollationKey targetKey, int compareResult, int keyResult, int incResult, int expectedResult ) { if (expectedResult < -1 || expectedResult > 1) { @@ -255,7 +258,7 @@ public class CollationMonkeyTest extends TestFmwk { boolean ok2 = (keyResult == expectedResult); boolean ok3 = (incResult == expectedResult); if (ok1 && ok2 && ok3 && !isVerbose()) { - return; + return; } else { String msg1 = ok1? "Ok: compare(\"" : "FAIL: compare(\""; String msg2 = "\", \""; @@ -290,7 +293,7 @@ public class CollationMonkeyTest extends TestFmwk { logln(msg1 + src + msg2 + target + msg3 + sResult); } else { errln(msg1 + src + msg2 + target + msg3 + sResult + msg4 + sExpect); - } + } } } } diff --git a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationRegressionTest.java b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationRegressionTest.java index bb2c48fd1cf..40250eb854f 100644 --- a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationRegressionTest.java +++ b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationRegressionTest.java @@ -7,11 +7,11 @@ ******************************************************************************* */ -/** +/** * Port From: ICU4C v2.1 : collate/CollationRegressionTest * Source File: $ICU4CRoot/source/test/intltest/regcoll.cpp **/ - + package com.ibm.icu.dev.test.collator; import java.text.ParseException; @@ -20,6 +20,8 @@ import java.util.List; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.CollationElementIterator; @@ -27,6 +29,7 @@ import com.ibm.icu.text.CollationKey; import com.ibm.icu.text.Collator; import com.ibm.icu.text.RuleBasedCollator; +@RunWith(JUnit4.class) public class CollationRegressionTest extends TestFmwk { // @bug 4048446 // @@ -39,31 +42,31 @@ public class CollationRegressionTest extends TestFmwk { RuleBasedCollator en_us = (RuleBasedCollator) Collator.getInstance(Locale.US); CollationElementIterator i1 = en_us.getCollationElementIterator(test1); CollationElementIterator i2 = en_us.getCollationElementIterator(test1); - + if (i1 == null || i2 == null) { errln("Could not create CollationElementIterator's"); return; } - + while (i1.next() != CollationElementIterator.NULLORDER) { // } - + i1.reset(); assertEqual(i1, i2); } - + void assertEqual(CollationElementIterator i1, CollationElementIterator i2) { int c1, c2, count = 0; - + do { c1 = i1.next(); c2 = i2.next(); - + if (c1 != c2) { String msg = ""; String msg1 = " "; - + msg += msg1 + count; msg += ": strength(0x" + Integer.toHexString(c1); msg += ") != strength(0x" + Integer.toHexString(c2); @@ -74,7 +77,7 @@ public class CollationRegressionTest extends TestFmwk { count += 1; } while (c1 != CollationElementIterator.NULLORDER); } - + // @bug 4051866 // // Collator -> rules -> Collator round-trip broken for expanding characters @@ -85,14 +88,14 @@ public class CollationRegressionTest extends TestFmwk { // Build a collator containing expanding characters RuleBasedCollator c1 = null; - + try { c1 = new RuleBasedCollator(rules); } catch (Exception e) { errln("Fail to create RuleBasedCollator with rules:" + rules); return; } - + // Build another using the rules from the first RuleBasedCollator c2 = null; try { @@ -101,14 +104,14 @@ public class CollationRegressionTest extends TestFmwk { errln("Fail to create RuleBasedCollator with rules:" + rules); return; } - + // Make sure they're the same if (!(c1.getRules().equals(c2.getRules()))) { errln("Rules are not equal"); } } - + // @bug 4053636 // // Collator thinks "black-bird" == "black" @@ -120,7 +123,7 @@ public class CollationRegressionTest extends TestFmwk { errln("black-bird == black"); } } - + // @bug 4054238 // // CollationElementIterator will not work correctly if the associated @@ -131,45 +134,45 @@ public class CollationRegressionTest extends TestFmwk { final char[] chars3 = {0x61, 0x00FC, 0x62, 0x65, 0x63, 0x6b, 0x20, 0x47, 0x72, 0x00F6, 0x00DF, 0x65, 0x20, 0x4c, 0x00FC, 0x62, 0x63, 0x6b, 0}; final String test3 = new String(chars3); RuleBasedCollator c = (RuleBasedCollator) Collator.getInstance(Locale.US); - + // NOTE: The Java code uses en_us to create the CollationElementIterators // but I'm pretty sure that's wrong, so I've changed this to use c. c.setDecomposition(Collator.NO_DECOMPOSITION); CollationElementIterator i1 = c.getCollationElementIterator(test3); logln("Offset:" + i1.getOffset()); } - + // @bug 4054734 // // Collator::IDENTICAL documented but not implemented // @Test public void Test4054734(/* char* par */) { - + //Here's the original Java: - + String[] decomp = { "\u0001", "<", "\u0002", "\u0001", "=", "\u0001", "A\u0001", ">", "~\u0002", // Ensure A and ~ are not compared bitwise "\u00C0", "=", "A\u0300", // Decomp should make these equal }; - + RuleBasedCollator c = (RuleBasedCollator) Collator.getInstance(Locale.US); c.setStrength(Collator.IDENTICAL); c.setDecomposition(Collator.CANONICAL_DECOMPOSITION); compareArray(c, decomp); } - + void compareArray(Collator c, String[] tests) { - + int expectedResult = 0; - + for (int i = 0; i < tests.length; i += 3) { String source = tests[i]; String comparison = tests[i + 1]; String target = tests[i + 2]; - + if (comparison.equals("<")) { expectedResult = -1; } else if (comparison.equals(">")) { @@ -179,9 +182,9 @@ public class CollationRegressionTest extends TestFmwk { } else { errln("Bogus comparison string \"" + comparison + "\""); } - + int compareResult = 0; - + logln("i = " + i); logln(source); logln(target); @@ -190,7 +193,7 @@ public class CollationRegressionTest extends TestFmwk { } catch (Exception e) { errln(e.toString()); } - + CollationKey sourceKey = null, targetKey = null; try { sourceKey = c.getCollationKey(source); @@ -198,19 +201,19 @@ public class CollationRegressionTest extends TestFmwk { errln("Couldn't get collationKey for source"); continue; } - + try { targetKey = c.getCollationKey(target); } catch (Exception e) { errln("Couldn't get collationKey for target"); continue; } - + int keyResult = sourceKey.compareTo(targetKey); reportCResult( source, target, sourceKey, targetKey, compareResult, keyResult, compareResult, expectedResult ); } } - + void reportCResult( String source, String target, CollationKey sourceKey, CollationKey targetKey, int compareResult, int keyResult, int incResult, int expectedResult ){ if (expectedResult < -1 || expectedResult > 1) @@ -224,13 +227,13 @@ public class CollationRegressionTest extends TestFmwk { boolean ok3 = (incResult == expectedResult); if (ok1 && ok2 && ok3 && !isVerbose()){ - return; + return; }else{ String msg1 = ok1? "Ok: compare(\"" : "FAIL: compare(\""; String msg2 = "\", \""; String msg3 = "\") returned "; String msg4 = "; expected "; - + String sExpect = new String(""); String sResult = new String(""); sResult = CollationTest.appendCompareResult(compareResult, sResult); @@ -240,7 +243,7 @@ public class CollationRegressionTest extends TestFmwk { } else { errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect); } - + msg1 = ok2 ? "Ok: key(\"" : "FAIL: key(\""; msg2 = "\").compareTo(key(\""; msg3 = "\")) returned "; @@ -253,7 +256,7 @@ public class CollationRegressionTest extends TestFmwk { msg2 = " vs. "; errln(msg1 + CollationTest.prettify(sourceKey) + msg2 + CollationTest.prettify(targetKey)); } - + msg1 = ok3 ? "Ok: incCompare(\"" : "FAIL: incCompare(\""; msg2 = "\", \""; msg3 = "\") returned "; @@ -264,7 +267,7 @@ public class CollationRegressionTest extends TestFmwk { logln(msg1 + source + msg2 + target + msg3 + sResult); } else { errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect); - } + } } } @@ -275,45 +278,45 @@ public class CollationRegressionTest extends TestFmwk { @Test public void Test4054736(/* char* par */) { RuleBasedCollator c = (RuleBasedCollator) Collator.getInstance(Locale.US); - + c.setStrength(Collator.SECONDARY); c.setDecomposition(Collator.NO_DECOMPOSITION); - + final String[] tests = { "\uFB4F", "\u003d", "\u05D0\u05DC" }; // Alef-Lamed vs. Alef, Lamed compareArray(c, tests); } - + // @bug 4058613 // - // Collator::createInstance() causes an ArrayIndexOutofBoundsException for Korean + // Collator::createInstance() causes an ArrayIndexOutofBoundsException for Korean // @Test public void Test4058613(/* char* par */) { // Creating a default collator doesn't work when Korean is the default // locale - + Locale oldDefault = Locale.getDefault(); Locale.setDefault(new Locale("ko", "")); - + Collator c = null; - + c = Collator.getInstance(new Locale("en", "US")); - + if (c == null) { errln("Could not create a Korean collator"); Locale.setDefault(oldDefault); return; } - + // Since the fix to this bug was to turn off decomposition for Korean collators, // ensure that's what we got if (c.getDecomposition() != Collator.NO_DECOMPOSITION) { errln("Decomposition is not set to NO_DECOMPOSITION for Korean collator"); } - + Locale.setDefault(oldDefault); } - + // @bug 4059820 // // RuleBasedCollator.getRules does not return the exact pattern as input @@ -329,13 +332,13 @@ public class CollationRegressionTest extends TestFmwk { errln("Failure building a collator."); return; } - + if ( c.getRules().indexOf("c/a") == -1) { errln("returned rules do not contain 'c/a'"); } } - + // @bug 4060154 // // MergeCollation::fixEntry broken for "& H < \u0131, \u0130, i, I" @@ -343,7 +346,7 @@ public class CollationRegressionTest extends TestFmwk { @Test public void Test4060154(/* char* par */) { String rules ="&f < g, G < h, H < i, I < j, J & H < \u0131, \u0130, i, I"; - + RuleBasedCollator c = null; try { c = new RuleBasedCollator(rules); @@ -352,9 +355,9 @@ public class CollationRegressionTest extends TestFmwk { errln("failure building collator:" + e); return; } - + c.setDecomposition(Collator.NO_DECOMPOSITION); - + String[] tertiary = { "A", "<", "B", "H", "<", "\u0131", @@ -363,19 +366,19 @@ public class CollationRegressionTest extends TestFmwk { "\u0130", "<", "i", "\u0130", ">", "H", }; - + c.setStrength(Collator.TERTIARY); compareArray(c, tertiary); - + String[] secondary = { "H", "<", "I", "\u0131", "=", "\u0130", }; - + c.setStrength(Collator.PRIMARY); compareArray(c, secondary); } - + // @bug 4062418 // // Secondary/Tertiary comparison incorrect in French Secondary @@ -390,14 +393,14 @@ public class CollationRegressionTest extends TestFmwk { return; } c.setStrength(Collator.SECONDARY); - + String[] tests = { "p\u00eache", "<", "p\u00e9ch\u00e9", // Comparing accents from end, p\u00e9ch\u00e9 is greater }; - + compareArray(c, tests); } - + // @bug 4065540 // // Collator::compare() method broken if either string contains spaces @@ -409,7 +412,7 @@ public class CollationRegressionTest extends TestFmwk { errln("'abcd e' == 'abcd f'"); } } - + // @bug 4066189 // // Unicode characters need to be recursively decomposed to get the @@ -420,21 +423,21 @@ public class CollationRegressionTest extends TestFmwk { public void Test4066189(/* char* par */) { final String test1 = "\u1EB1"; final String test2 = "\u0061\u0306\u0300"; - + // NOTE: The java code used en_us to create the // CollationElementIterator's. I'm pretty sure that // was wrong, so I've change the code to use c1 and c2 RuleBasedCollator c1 = (RuleBasedCollator) Collator.getInstance(Locale.US); c1.setDecomposition(Collator.CANONICAL_DECOMPOSITION); CollationElementIterator i1 = c1.getCollationElementIterator(test1); - + RuleBasedCollator c2 = (RuleBasedCollator) Collator.getInstance(Locale.US); c2.setDecomposition(Collator.NO_DECOMPOSITION); CollationElementIterator i2 = c2.getCollationElementIterator(test2); - + assertEqual(i1, i2); } - + // @bug 4066696 // // French secondary collation checking at the end of compare iteration fails @@ -449,13 +452,13 @@ public class CollationRegressionTest extends TestFmwk { return; } c.setStrength(Collator.SECONDARY); - + String[] tests = { "\u00e0", ">", "\u01fa", // a-grave < A-ring-acute - }; + }; compareArray(c, tests); } - + // @bug 4076676 // // Bad canonicalization of same-class combining characters @@ -466,10 +469,10 @@ public class CollationRegressionTest extends TestFmwk { // be reordered, and they should compare as unequal. final String s1 = "\u0041\u0301\u0302\u0300"; final String s2 = "\u0041\u0302\u0300\u0301"; - + RuleBasedCollator c = (RuleBasedCollator) Collator.getInstance(Locale.US); c.setStrength(Collator.TERTIARY); - + if (c.compare(s1,s2) == 0) { errln("Same-class combining chars were reordered"); } @@ -488,20 +491,20 @@ public class CollationRegressionTest extends TestFmwk { errln("Failed to create RuleBasedCollator."); return; } - + int result = rbc.compare("a","bb"); - + if (result >= 0) { errln("Compare(a,bb) returned " + result + "; expected -1"); } } - + // @bug 4079231 // // RuleBasedCollator::operator==(NULL) throws NullPointerException // @Test - public void Test4079231(/* char* par */) { + public void Test4079231(/* char* par */) { RuleBasedCollator en_us = (RuleBasedCollator) Collator.getInstance(Locale.US); try { if (en_us.equals(null)) { @@ -511,7 +514,7 @@ public class CollationRegressionTest extends TestFmwk { errln("en_us.equals(null) threw " + e.toString()); } } - + // @bug 4081866 // // Combining characters in different classes not reordered properly. @@ -522,10 +525,10 @@ public class CollationRegressionTest extends TestFmwk { // so they should be reordered and the strings should compare as equal. String s1 = "\u0041\u0300\u0316\u0327\u0315"; String s2 = "\u0041\u0327\u0316\u0315\u0300"; - + RuleBasedCollator c = (RuleBasedCollator) Collator.getInstance(Locale.US); c.setStrength(Collator.TERTIARY); - + // Now that the default collators are set to NO_DECOMPOSITION // (as a result of fixing bug 4114077), we must set it explicitly // when we're testing reordering behavior. -- lwerner, 5/5/98 @@ -534,7 +537,7 @@ public class CollationRegressionTest extends TestFmwk { errln("Combining chars were not reordered"); } } - + // @bug 4087241 // // string comparison errors in Scandinavian collators @@ -557,7 +560,7 @@ public class CollationRegressionTest extends TestFmwk { }; compareArray(c, tests); } - + // @bug 4087243 // // CollationKey takes ignorable strings into account when it shouldn't @@ -571,7 +574,7 @@ public class CollationRegressionTest extends TestFmwk { }; compareArray(c, tests); } - + // @bug 4092260 // // Mu/micro conflict @@ -594,7 +597,7 @@ public class CollationRegressionTest extends TestFmwk { }; compareArray(c, tests); } - + // @bug 4095316 // @Test @@ -616,7 +619,7 @@ public class CollationRegressionTest extends TestFmwk { }; compareArray(c, tests); } - + // @bug 4101940 // @Test @@ -636,7 +639,7 @@ public class CollationRegressionTest extends TestFmwk { errln("next did not return NULLORDER"); } } - + // @bug 4103436 // // Collator::compare not handling spaces properly @@ -651,7 +654,7 @@ public class CollationRegressionTest extends TestFmwk { }; compareArray(c, tests); } - + // @bug 4114076 // // Collation not Unicode conformant with Hangul syllables @@ -660,7 +663,7 @@ public class CollationRegressionTest extends TestFmwk { public void Test4114076(/* char* par */) { RuleBasedCollator c = (RuleBasedCollator) Collator.getInstance(Locale.US); c.setStrength(Collator.TERTIARY); - + // // With Canonical decomposition, Hangul syllables should get decomposed // into Jamo, but Jamo characters should not be decomposed into @@ -669,16 +672,16 @@ public class CollationRegressionTest extends TestFmwk { String test1[] = { "\ud4db", "\u003d", "\u1111\u1171\u11b6" }; - + c.setDecomposition(Collator.CANONICAL_DECOMPOSITION); compareArray(c, test1); - + // From UTR #15: // *In earlier versions of Unicode, jamo characters like ksf - // had compatibility mappings to kf + sf. These mappings were + // had compatibility mappings to kf + sf. These mappings were // removed in Unicode 2.1.9 to ensure that Hangul syllables are maintained.) // That is, the following test is obsolete as of 2.1.9 - + //obsolete- // With Full decomposition, it should go all the way down to //obsolete- // conjoining Jamo characters. //obsolete- // @@ -693,7 +696,7 @@ public class CollationRegressionTest extends TestFmwk { // @bug 4114077 // - // Collation with decomposition off doesn't work for Europe + // Collation with decomposition off doesn't work for Europe // @Test public void Test4114077(/* char* par */) { @@ -709,18 +712,18 @@ public class CollationRegressionTest extends TestFmwk { // -> a, ring, acute "\u0041\u0300\u0316", "\u003c", "\u0041\u0316\u0300" // No reordering --> unequal }; - + c.setDecomposition(Collator.NO_DECOMPOSITION); compareArray(c, test1); - + String test2[] = { "\u0041\u0300\u0316", "\u003d", "\u0041\u0316\u0300" // Reordering --> equal }; - + c.setDecomposition(Collator.CANONICAL_DECOMPOSITION); compareArray(c, test2); } - + // @bug 4124632 // // Collator::getCollationKey was hanging on certain character sequences @@ -743,7 +746,7 @@ public class CollationRegressionTest extends TestFmwk { errln("CollationKey creation failed."); } } - + // @bug 4132736 // // sort order of french words with multiple accents has errors @@ -757,14 +760,14 @@ public class CollationRegressionTest extends TestFmwk { } catch (Exception e) { errln("Failed to create a collator for Locale.CANADA_FRENCH"); } - + String test1[] = { "\u0065\u0300\u0065\u0301", "\u003c", "\u0065\u0301\u0065\u0300", "\u0065\u0300\u0301", "\u003c", "\u0065\u0301\u0300", }; compareArray(c, test1); } - + // @bug 4133509 // // The sorting using java.text.CollationKey is not in the exact order @@ -777,13 +780,13 @@ public class CollationRegressionTest extends TestFmwk { "\u0047\u0072\u0061\u0070\u0068\u0069\u0063\u0073", "\u003c", "\u0047\u0072\u0061\u0070\u0068\u0069\u0063\u0073\u0045\u006e\u0076\u0069\u0072\u006f\u006e\u006d\u0065\u006e\u0074", "\u0053\u0074\u0072\u0069\u006e\u0067", "\u003c", "\u0053\u0074\u0072\u0069\u006e\u0067\u0042\u0075\u0066\u0066\u0065\u0072", }; - + compareArray(en_us, test1); } - + // @bug 4139572 // - // getCollationKey throws exception for spanish text + // getCollationKey throws exception for spanish text // Cannot reproduce this bug on 1.2, however it DOES fail on 1.1.6 // @Test @@ -810,10 +813,10 @@ public class CollationRegressionTest extends TestFmwk { errln("Error creating CollationKey for \"Nombre De Ojbeto\""); } } - + // @bug 4141640 // - // Support for Swedish gone in 1.1.6 (Can't create Swedish collator) + // Support for Swedish gone in 1.1.6 (Can't create Swedish collator) // @Test public void Test4141640(/* char* par */) { @@ -823,7 +826,7 @@ public class CollationRegressionTest extends TestFmwk { // in order to prevent this sort of bug from cropping up in the future // Locale locales[] = Collator.getAvailableLocales(); - + for (int i = 0; i < locales.length; i += 1) { Collator c = null; @@ -838,7 +841,7 @@ public class CollationRegressionTest extends TestFmwk { } } } - + private void checkListOrder(String[] sortedList, Collator c) { // this function uses the specified Collator to make sure the // passed-in list is already sorted into ascending order @@ -1042,7 +1045,7 @@ public class CollationRegressionTest extends TestFmwk { } RuleBasedCollator collator = new RuleBasedCollator("&a<\u00e0=a\u0300"); - //commented by Kevin 2003/10/21 + //commented by Kevin 2003/10/21 //for "FULL_DECOMPOSITION is not supported here." in ICU4J DOC //collator.setDecomposition(Collator.FULL_DECOMPOSITION); collator.setStrength(Collator.IDENTICAL); @@ -1125,51 +1128,51 @@ public class CollationRegressionTest extends TestFmwk { RuleBasedCollator collator = (RuleBasedCollator)Collator.getInstance(Locale.US); java.text.StringCharacterIterator stringIter = new java.text.StringCharacterIterator("fox"); CollationElementIterator iter = collator.getCollationElementIterator(stringIter); - + int[] elements_next = new int[3]; logln("calling next:"); for (int i = 0; i < 3; ++i) { logln("[" + i + "] " + (elements_next[i] = iter.next())); } - + int[] elements_fwd = new int[3]; logln("calling set/next:"); for (int i = 0; i < 3; ++i) { iter.setOffset(i); logln("[" + i + "] " + (elements_fwd[i] = iter.next())); } - + for (int i = 0; i < 3; ++i) { if (elements_next[i] != elements_fwd[i]) { - errln("mismatch at position " + i + - ": " + elements_next[i] + + errln("mismatch at position " + i + + ": " + elements_next[i] + " != " + elements_fwd[i]); } } } - + // Fixing the infinite loop for surrogates @Test public void Test8484() { String s = "\u9FE1\uCEF3\u2798\uAAB6\uDA7C"; Collator coll = Collator.getInstance(); - CollationKey collKey = coll.getCollationKey(s); + CollationKey collKey = coll.getCollationKey(s); logln("Pass: " + collKey.toString() + " generated OK."); } - + @Test public void TestBengaliSortKey() throws Exception { - char rules[] = { 0x26, 0x9fa, 0x3c, 0x98c, 0x3c, 0x9e1, 0x3c, 0x98f, 0x3c, 0x990, 0x3c, 0x993, - 0x3c, 0x994, 0x3c, 0x9bc, 0x3c, 0x982, 0x3c, 0x983, 0x3c, 0x981, 0x3c, 0x9b0, 0x3c, - 0x9b8, 0x3c, 0x9b9, 0x3c, 0x9bd, 0x3c, 0x9be, 0x3c, 0x9bf, 0x3c, 0x9c8, 0x3c, 0x9cb, + char rules[] = { 0x26, 0x9fa, 0x3c, 0x98c, 0x3c, 0x9e1, 0x3c, 0x98f, 0x3c, 0x990, 0x3c, 0x993, + 0x3c, 0x994, 0x3c, 0x9bc, 0x3c, 0x982, 0x3c, 0x983, 0x3c, 0x981, 0x3c, 0x9b0, 0x3c, + 0x9b8, 0x3c, 0x9b9, 0x3c, 0x9bd, 0x3c, 0x9be, 0x3c, 0x9bf, 0x3c, 0x9c8, 0x3c, 0x9cb, 0x3d, 0x9cb }; - + Collator col = new RuleBasedCollator(String.copyValueOf(rules)); - + String str1 = "\u09be"; String str2 = "\u0b70"; - + int result = col.compare(str1, str2); System.out.flush(); @@ -1191,7 +1194,7 @@ public class CollationRegressionTest extends TestFmwk { } System.out.print(": "); for(int i=0;in1); assertTrue("unregister restores count", n3==n1); - + ncol = Collator.getInstance(fu_FU); if (!fucol.equals(ncol)) { errln("collator after unregister does not match original fu_FU"); @@ -321,12 +329,12 @@ public class CollationServiceTest extends TestFmwk { ULocale ulocs[] = Collator.getAvailableULocales(); if (!assertTrue("getAvailableULocales != null", ulocs!=null)) return -1; checkArray(msg, ulocs, null); - // This is not true because since ULocale objects with script code cannot be + // This is not true because since ULocale objects with script code cannot be // converted to Locale objects //assertTrue("getAvailableLocales().length == getAvailableULocales().length", locs.length == ulocs.length); return locs.length; } - + private static final String KW[] = { "collation" }; @@ -341,7 +349,7 @@ public class CollationServiceTest extends TestFmwk { String kw[] = Collator.getKeywords(); if (!assertTrue("getKeywords != null", kw!=null)) return; checkArray("getKeywords", kw, KW); - + String kwval[] = Collator.getKeywordValues(KW[0]); if (!assertTrue("getKeywordValues != null", kwval!=null)) return; checkArray("getKeywordValues", kwval, KWVAL); @@ -355,7 +363,7 @@ public class CollationServiceTest extends TestFmwk { } assertTrue("getFunctionalEquivalent(de).isAvailable==true", isAvailable[0] == true); - + equiv = Collator.getFunctionalEquivalent(KW[0], new ULocale("de_DE"), isAvailable); @@ -370,11 +378,11 @@ public class CollationServiceTest extends TestFmwk { assertEquals("getFunctionalEquivalent(zh_Hans)", "zh", equiv.toString()); } } - + @Test public void TestGetFunctionalEquivalent() { String kw[] = Collator.getKeywords(); - final String DATA[] = { + final String DATA[] = { "sv", "sv", "t", "sv@collation=direct", "sv", "t", "sv@collation=traditional", "sv", "t", @@ -406,7 +414,7 @@ public class CollationServiceTest extends TestFmwk { "en_US_VALLEYGIRL","root","f" }; final int DATA_COUNT=(DATA.length/3); - + for(int i=0;i 1) { @@ -115,13 +118,13 @@ import com.ibm.icu.text.Collator; boolean ok3 = (incResult == expectedResult); if (ok1 && ok2 && ok3 && !isVerbose()) { - return; + return; } else { String msg1 = ok1? "Ok: compare(\"" : "FAIL: compare(\""; String msg2 = "\", \""; String msg3 = "\") returned "; String msg4 = "; expected "; - + String sExpect = new String(""); String sResult = new String(""); sResult = CollationTest.appendCompareResult(compareResult, sResult); @@ -131,7 +134,7 @@ import com.ibm.icu.text.Collator; } else { errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect); } - + msg1 = ok2 ? "Ok: key(\"" : "FAIL: key(\""; msg2 = "\").compareTo(key(\""; msg3 = "\")) returned "; @@ -144,7 +147,7 @@ import com.ibm.icu.text.Collator; msg2 = " vs. "; errln(msg1 + CollationTest.prettify(sourceKey) + msg2 + CollationTest.prettify(targetKey)); } - + msg1 = ok3 ? "Ok: incCompare(\"" : "FAIL: incCompare(\""; msg2 = "\", \""; msg3 = "\") returned "; @@ -155,7 +158,7 @@ import com.ibm.icu.text.Collator; logln(msg1 + source + msg2 + target + msg3 + sResult); } else { errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect); - } + } } } } diff --git a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationTest.java b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationTest.java index 6189e7ad89c..5b2212a6da8 100644 --- a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationTest.java +++ b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationTest.java @@ -18,6 +18,8 @@ import java.util.HashSet; import java.util.Set; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.dev.test.TestUtil; @@ -50,6 +52,7 @@ import com.ibm.icu.util.IllformedLocaleException; import com.ibm.icu.util.Output; import com.ibm.icu.util.ULocale; +@RunWith(JUnit4.class) public class CollationTest extends TestFmwk { public CollationTest() { } @@ -62,14 +65,14 @@ public class CollationTest extends TestFmwk { String fileTestName; // package private methods ---------------------------------------------- - - static void doTest(TestFmwk test, RuleBasedCollator col, String source, + + static void doTest(TestFmwk test, RuleBasedCollator col, String source, String target, int result) { doTestVariant(test, col, source, target, result); if (result == -1) { doTestVariant(test, col, target, source, 1); - } + } else if (result == 1) { doTestVariant(test, col, target, source, -1); } @@ -82,17 +85,17 @@ public class CollationTest extends TestFmwk { iter.setText(target); backAndForth(test, iter); } - + /** * Return an integer array containing all of the collation orders * returned by calls to next on the specified iterator */ - static int[] getOrders(CollationElementIterator iter) + static int[] getOrders(CollationElementIterator iter) { int maxSize = 100; int size = 0; int[] orders = new int[maxSize]; - + int order; while ((order = iter.next()) != CollationElementIterator.NULLORDER) { if (size == maxSize) { @@ -103,7 +106,7 @@ public class CollationTest extends TestFmwk { } orders[size++] = order; } - + if (maxSize > size) { int[] temp = new int[size]; System.arraycopy(orders, 0, temp, 0, size); @@ -111,20 +114,20 @@ public class CollationTest extends TestFmwk { } return orders; } - - static void backAndForth(TestFmwk test, CollationElementIterator iter) + + static void backAndForth(TestFmwk test, CollationElementIterator iter) { // Run through the iterator forwards and stick it into an array iter.reset(); int[] orders = getOrders(iter); - + // Now go through it backwards and make sure we get the same values int index = orders.length; int o; - + // reset the iterator iter.reset(); - + while ((o = iter.previous()) != CollationElementIterator.NULLORDER) { if (o != orders[--index]) { if (o == 0) { @@ -132,24 +135,24 @@ public class CollationTest extends TestFmwk { } else { while (index > 0 && orders[index] == 0) { index --; - } + } if (o != orders[index]) { - TestFmwk.errln("Mismatch at index " + index + ": 0x" + TestFmwk.errln("Mismatch at index " + index + ": 0x" + Utility.hex(orders[index]) + " vs 0x" + Utility.hex(o)); break; } } } } - + while (index != 0 && orders[index - 1] == 0) { index --; } - + if (index != 0) { String msg = "Didn't get back to beginning - index is "; TestFmwk.errln(msg + index); - + iter.reset(); TestFmwk.err("next: "); while ((o = iter.next()) != CollationElementIterator.NULLORDER) { @@ -165,7 +168,7 @@ public class CollationTest extends TestFmwk { TestFmwk.errln(""); } } - + static final String appendCompareResult(int result, String target){ if (result == -1) { target += "LESS"; @@ -191,7 +194,7 @@ public class CollationTest extends TestFmwk { static final String prettify(byte[] skBytes, int length) { StringBuilder target = new StringBuilder(length * 3 + 2).append('['); - + for (int i = 0; i < length; i++) { String numStr = Integer.toHexString(skBytes[i] & 0xff); if (numStr.length() < 2) { @@ -203,17 +206,17 @@ public class CollationTest extends TestFmwk { return target.toString(); } - private static void doTestVariant(TestFmwk test, + private static void doTestVariant(TestFmwk test, RuleBasedCollator myCollation, String source, String target, int result) { int compareResult = myCollation.compare(source, target); if (compareResult != result) { - + // !!! if not mod build, error, else nothing. // warnln if not build, error, else always print warning. // do we need a 'quiet warning?' (err or log). Hmmm, - // would it work to have the 'verbose' flag let you + // would it work to have the 'verbose' flag let you // suppress warnings? Are there ever some warnings you // want to suppress, and others you don't? TestFmwk.errln("Comparing \"" + Utility.hex(source) + "\" with \"" @@ -224,9 +227,9 @@ public class CollationTest extends TestFmwk { CollationKey tsk = myCollation.getCollationKey(target); compareResult = ssk.compareTo(tsk); if (compareResult != result) { - TestFmwk.errln("Comparing CollationKeys of \"" + Utility.hex(source) - + "\" with \"" + Utility.hex(target) - + "\" expected " + result + " but got " + TestFmwk.errln("Comparing CollationKeys of \"" + Utility.hex(source) + + "\" with \"" + Utility.hex(target) + + "\" expected " + result + " but got " + compareResult); } RawCollationKey srsk = new RawCollationKey(); @@ -235,10 +238,10 @@ public class CollationTest extends TestFmwk { myCollation.getRawCollationKey(target, trsk); compareResult = ssk.compareTo(tsk); if (compareResult != result) { - TestFmwk.errln("Comparing RawCollationKeys of \"" - + Utility.hex(source) - + "\" with \"" + Utility.hex(target) - + "\" expected " + result + " but got " + TestFmwk.errln("Comparing RawCollationKeys of \"" + + Utility.hex(source) + + "\" with \"" + Utility.hex(target) + + "\" expected " + result + " but got " + compareResult); } } @@ -250,7 +253,7 @@ public class CollationTest extends TestFmwk { final String s = "\uFFFE\uFFFF"; long[] ces; - + ces = rbc.internalGetCEs(s); if (ces.length != 2) { errln("expected 2 CEs for , got " + ces.length); @@ -355,7 +358,7 @@ public class CollationTest extends TestFmwk { } } - + // ICU4C: TestIllegalUTF8 / not applicable to ICU4J @@ -1475,7 +1478,7 @@ public class CollationTest extends TestFmwk { if (b != bytes[i]) { break; } - if ((int)b == Collation.LEVEL_SEPARATOR_BYTE) { + if (b == Collation.LEVEL_SEPARATOR_BYTE) { ++level; if (level == Collation.CASE_LEVEL && !collHasCaseLevel) { ++level; diff --git a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationThaiTest.java b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationThaiTest.java index e7009af6b2a..07ad77bfdf1 100644 --- a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationThaiTest.java +++ b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationThaiTest.java @@ -7,11 +7,11 @@ ******************************************************************************* */ -/** +/** * Port From: ICU4C v2.1 : collate/CollationRegressionTest * Source File: $ICU4CRoot/source/test/intltest/regcoll.cpp **/ - + package com.ibm.icu.dev.test.collator; import java.io.BufferedReader; @@ -21,6 +21,8 @@ import java.util.Comparator; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.dev.test.TestUtil; @@ -29,10 +31,11 @@ import com.ibm.icu.text.CollationKey; import com.ibm.icu.text.Collator; import com.ibm.icu.text.RuleBasedCollator; +@RunWith(JUnit4.class) public class CollationThaiTest extends TestFmwk { - + final int MAX_FAILURES_TO_SHOW = -1; - + /** * Odd corner conditions taken from "How to Sort Thai Without Rewriting Sort", * by Doug Cooper, http://seasrc.th.net/paper/thaisort.zip @@ -42,41 +45,41 @@ public class CollationThaiTest extends TestFmwk { String TESTS[] = { // Shorter words precede longer "\u0e01", "<", "\u0e01\u0e01", - + // Tone marks are considered after letters (i.e. are primary ignorable) "\u0e01\u0e32", "<", "\u0e01\u0e49\u0e32", - + // ditto for other over-marks "\u0e01\u0e32", "<", "\u0e01\u0e32\u0e4c", - + // commonly used mark-in-context order. // In effect, marks are sorted after each syllable. "\u0e01\u0e32\u0e01\u0e49\u0e32", "<", "\u0e01\u0e48\u0e32\u0e01\u0e49\u0e32", - + // Hyphens and other punctuation follow whitespace but come before letters "\u0e01\u0e32", "=", "\u0e01\u0e32-", "\u0e01\u0e32-", "<", "\u0e01\u0e32\u0e01\u0e32", - + // Doubler follows an indentical word without the doubler "\u0e01\u0e32", "=", "\u0e01\u0e32\u0e46", "\u0e01\u0e32\u0e46", "<", "\u0e01\u0e32\u0e01\u0e32", - + // \u0e45 after either \u0e24 or \u0e26 is treated as a single // combining character, similar to "c < ch" in traditional spanish. // TODO: beef up this case "\u0e24\u0e29\u0e35", "<", "\u0e24\u0e45\u0e29\u0e35", "\u0e26\u0e29\u0e35", "<", "\u0e26\u0e45\u0e29\u0e35", - + // Vowels reorder, should compare \u0e2d and \u0e34 "\u0e40\u0e01\u0e2d", "<", "\u0e40\u0e01\u0e34", - + // Tones are compared after the rest of the word (e.g. primary ignorable) "\u0e01\u0e32\u0e01\u0e48\u0e32", "<", "\u0e01\u0e49\u0e32\u0e01\u0e32", - + // Periods are ignored entirely "\u0e01.\u0e01.", "<", "\u0e01\u0e32", }; - + RuleBasedCollator coll = null; try { coll = getThaiCollator(); @@ -84,9 +87,9 @@ public class CollationThaiTest extends TestFmwk { warnln("could not construct Thai collator"); return; } - compareArray(coll, TESTS); + compareArray(coll, TESTS); } - + void compareArray(RuleBasedCollator c, String[] tests) { for (int i = 0; i < tests.length; i += 3) { int expect = 0; @@ -106,13 +109,13 @@ public class CollationThaiTest extends TestFmwk { CollationTest.doTest(this, c, s1, s2, expect); } } - + int sign(int i ) { if (i < 0) return -1; if (i > 0) return 1; return 0; } - + /** * Read the external dictionary file, which is already in proper * sorted order, and confirm that the collator compares each line as @@ -204,12 +207,12 @@ public class CollationThaiTest extends TestFmwk { errln("Summary: " + failed + " of " + (line - 1) + " comparisons failed"); } - + logln("Words checked: " + wordCount); } - + @Test - public void TestInvalidThai() + public void TestInvalidThai() { String tests[] = { "\u0E44\u0E01\u0E44\u0E01", "\u0E44\u0E01\u0E01\u0E44", @@ -218,7 +221,7 @@ public class CollationThaiTest extends TestFmwk { "\u0E44\u0E44\u0E01\u0E01", "\u0E01\u0E44\u0E44\u0E01", }; - + RuleBasedCollator collator; StrCmp comparator; try { @@ -228,26 +231,26 @@ public class CollationThaiTest extends TestFmwk { warnln("could not construct Thai collator"); return; } - + Arrays.sort(tests, comparator); - + for (int i = 0; i < tests.length; i ++) { for (int j = i + 1; j < tests.length; j ++) { if (collator.compare(tests[i], tests[j]) > 0) { // inconsistency ordering found! - errln("Inconsistent ordering between strings " + i + errln("Inconsistent ordering between strings " + i + " and " + j); } } - CollationElementIterator iterator + CollationElementIterator iterator = collator.getCollationElementIterator(tests[i]); CollationTest.backAndForth(this, iterator); } } - + @Test - public void TestReordering() + public void TestReordering() { String tests[] = { "\u0E41c\u0301", "=", "\u0E41\u0107", // composition @@ -281,13 +284,13 @@ public class CollationThaiTest extends TestFmwk { RuleBasedCollator collator; try { - collator = (RuleBasedCollator)getThaiCollator(); + collator = getThaiCollator(); } catch (Exception e) { warnln("could not construct Thai collator"); return; } compareArray(collator, tests); - + String rule = "& c < ab"; String testcontraction[] = { "\u0E41ab", ">", "\u0E41c"}; try { @@ -300,28 +303,29 @@ public class CollationThaiTest extends TestFmwk { } // private inner class ------------------------------------------------- - - private static final class StrCmp implements Comparator + + private static final class StrCmp implements Comparator { - public int compare(String string1, String string2) + @Override + public int compare(String string1, String string2) { return collator.compare(string1, string2); } - + StrCmp() throws Exception { collator = getThaiCollator(); } - + Collator collator; } - + // private data members ------------------------------------------------ - + private static RuleBasedCollator m_collator_; - + // private methods ----------------------------------------------------- - + private static RuleBasedCollator getThaiCollator() throws Exception { if (m_collator_ == null) { diff --git a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationThreadTest.java b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationThreadTest.java index ef6a8bb5b23..27c04c792e8 100644 --- a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationThreadTest.java +++ b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationThreadTest.java @@ -13,9 +13,13 @@ import java.util.Arrays; import java.util.Locale; import java.util.Random; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.Collator; +@RunWith(JUnit4.class) public class CollationThreadTest extends TestFmwk { private static final String[] threadTestData; static { @@ -195,6 +199,7 @@ public class CollationThreadTest extends TestFmwk { this.r = r; } + @Override public void run() { try { synchronized (control) { diff --git a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationTurkishTest.java b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationTurkishTest.java index 98fe65b8778..aa39111913a 100644 --- a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationTurkishTest.java +++ b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationTurkishTest.java @@ -7,22 +7,25 @@ ******************************************************************************* */ -/** +/** * Port From: ICU4C v2.1 : Collate/CollationTurkishTest * Source File: $ICU4CRoot/source/test/intltest/trcoll.cpp **/ - + package com.ibm.icu.dev.test.collator; - + import java.util.Locale; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.CollationKey; import com.ibm.icu.text.Collator; - + +@RunWith(JUnit4.class) public class CollationTurkishTest extends TestFmwk{ private static char[][] testSourceCases = { {0x73, 0x0327}, @@ -66,18 +69,18 @@ public class CollationTurkishTest extends TestFmwk{ -1, 1 }; - + private Collator myCollation = null; - + public CollationTurkishTest() { } - + @Before public void init()throws Exception{ myCollation = Collator.getInstance(new Locale("tr", "")); } - + @Test public void TestTertiary() { int i = 0; @@ -86,7 +89,7 @@ public class CollationTurkishTest extends TestFmwk{ doTest(testSourceCases[i], testTargetCases[i], results[i]); } } - + @Test public void TestPrimary() { int i; @@ -95,8 +98,8 @@ public class CollationTurkishTest extends TestFmwk{ doTest(testSourceCases[i], testTargetCases[i], results[i]); } } - - + + // main test routine, tests rules specific to turkish locale private void doTest(char[] source, char[] target, int result) { String s = new String(source); @@ -107,9 +110,9 @@ public class CollationTurkishTest extends TestFmwk{ sortKey2 = myCollation.getCollationKey(t); int keyResult = sortKey1.compareTo(sortKey2); reportCResult(s, t, sortKey1, sortKey2, compareResult, keyResult, compareResult, result); - + } - + private void reportCResult( String source, String target, CollationKey sourceKey, CollationKey targetKey, int compareResult, int keyResult, int incResult, int expectedResult ) { if (expectedResult < -1 || expectedResult > 1) { @@ -122,13 +125,13 @@ public class CollationTurkishTest extends TestFmwk{ boolean ok3 = (incResult == expectedResult); if (ok1 && ok2 && ok3 && !isVerbose()) { - return; + return; } else { String msg1 = ok1? "Ok: compare(\"" : "FAIL: compare(\""; String msg2 = "\", \""; String msg3 = "\") returned "; String msg4 = "; expected "; - + String sExpect = new String(""); String sResult = new String(""); sResult = CollationTest.appendCompareResult(compareResult, sResult); @@ -138,7 +141,7 @@ public class CollationTurkishTest extends TestFmwk{ } else { errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect); } - + msg1 = ok2 ? "Ok: key(\"" : "FAIL: key(\""; msg2 = "\").compareTo(key(\""; msg3 = "\")) returned "; @@ -151,7 +154,7 @@ public class CollationTurkishTest extends TestFmwk{ msg2 = " vs. "; errln(msg1 + CollationTest.prettify(sourceKey) + msg2 + CollationTest.prettify(targetKey)); } - + msg1 = ok3 ? "Ok: incCompare(\"" : "FAIL: incCompare(\""; msg2 = "\", \""; msg3 = "\") returned "; @@ -162,7 +165,7 @@ public class CollationTurkishTest extends TestFmwk{ logln(msg1 + source + msg2 + target + msg3 + sResult); } else { errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect); - } + } } } } diff --git a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/G7CollationTest.java b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/G7CollationTest.java index 5c069db0d77..29770da5851 100644 --- a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/G7CollationTest.java +++ b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/G7CollationTest.java @@ -7,26 +7,29 @@ ******************************************************************************* */ -/** +/** * Port From: ICU4C v2.1 : Collate/G7CollationTest * Source File: $ICU4CRoot/source/test/intltest/g7coll.cpp **/ - + package com.ibm.icu.dev.test.collator; - + import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.CollationKey; import com.ibm.icu.text.Collator; import com.ibm.icu.text.RuleBasedCollator; - + +@RunWith(JUnit4.class) public class G7CollationTest extends TestFmwk{ private static String[] testCases = { - "blackbirds", "Pat", "p\u00E9ch\u00E9", "p\u00EAche", "p\u00E9cher", - "p\u00EAcher", "Tod", "T\u00F6ne", "Tofu", "blackbird", "Ton", + "blackbirds", "Pat", "p\u00E9ch\u00E9", "p\u00EAche", "p\u00E9cher", + "p\u00EAcher", "Tod", "T\u00F6ne", "Tofu", "blackbird", "Ton", "PAT", "black-bird", "black-birds", "pat", // 14 // Additional tests "czar", "churo", "cat", "darn", "?", /* 19 */ @@ -44,7 +47,7 @@ public class G7CollationTest extends TestFmwk{ { 12, 13, 9, 0, 14, 1, 11, 2, 3, 4, 5, 6, 8, 10, 7, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, /* it_IT */ { 12, 13, 9, 0, 14, 1, 11, 2, 3, 4, 5, 6, 8, 10, 7, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, /* ja_JP */ /* new table collation with rules "& Z < p, P" loop to FIXEDTESTSET */ - { 12, 13, 9, 0, 6, 8, 10, 7, 14, 1, 11, 2, 3, 4, 5, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, + { 12, 13, 9, 0, 6, 8, 10, 7, 14, 1, 11, 2, 3, 4, 5, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, /* new table collation with rules "& C < ch , cH, Ch, CH " loop to TOTALTESTSET */ { 19, 22, 21, 23, 24, 25, 12, 13, 9, 0, 17, 26, 28, 27, 15, 16, 18, 14, 1, 11, 2, 3, 4, 5, 20, 6, 8, 10, 7, 29 }, /* new table collation with rules "& Question-mark ; ? & Hash-mark ; # & Ampersand ; '&' " loop to TOTALTESTSET */ @@ -52,31 +55,31 @@ public class G7CollationTest extends TestFmwk{ /* analogous to Japanese rules " & aa ; a- & ee ; e- & ii ; i- & oo ; o- & uu ; u- " */ /* loop to TOTALTESTSET */ { 19, 22, 21, 24, 23, 25, 12, 13, 9, 0, 17, 16, 28, 26, 27, 15, 18, 14, 1, 11, 2, 3, 4, 5, 20, 6, 8, 10, 7, 29 } }; - + //private static final int MAX_TOKEN_LEN = 16; //private static final int TESTLOCALES = 12; private static final int FIXEDTESTSET = 15; private static final int TOTALTESTSET = 30; - + // perform test with added rules " & Z < p, P" @Test public void TestDemo1() { logln("Demo Test 1 : Create a new table collation with rules \"& Z < p, P\""); - - Collator col = Collator.getInstance(Locale.ENGLISH); - + Collator col = Collator.getInstance(Locale.ENGLISH); + + String baseRules = ((RuleBasedCollator)col).getRules(); String newRules = " & Z < p, P"; - newRules = baseRules + newRules; - RuleBasedCollator myCollation = null; + newRules = baseRules + newRules; + RuleBasedCollator myCollation = null; try { myCollation = new RuleBasedCollator(newRules); } catch(Exception e) { errln("Fail to create RuleBasedCollator with rules:" + newRules); return; } - + int j, n; for (j = 0; j < FIXEDTESTSET; j++) { for (n = j+1; n < FIXEDTESTSET; n++) { @@ -84,25 +87,25 @@ public class G7CollationTest extends TestFmwk{ } } } - + // perorm test with added rules "& C < ch , cH, Ch, CH" @Test public void TestDemo2() { logln("Demo Test 2 : Create a new table collation with rules \"& C < ch , cH, Ch, CH\""); - Collator col = Collator.getInstance(Locale.ENGLISH); + Collator col = Collator.getInstance(Locale.ENGLISH); String baseRules = ((RuleBasedCollator)col).getRules(); String newRules = "& C < ch , cH, Ch, CH"; - newRules = baseRules + newRules; - RuleBasedCollator myCollation = null; + newRules = baseRules + newRules; + RuleBasedCollator myCollation = null; try { myCollation = new RuleBasedCollator(newRules); }catch(Exception e){ errln("Fail to create RuleBasedCollator with rules:" + newRules); return; - } + } int j, n; for (j = 0; j < TOTALTESTSET; j++) { @@ -111,26 +114,26 @@ public class G7CollationTest extends TestFmwk{ } } } - - // perform test with added rules + + // perform test with added rules // "& Question'-'mark ; '?' & Hash'-'mark ; '#' & Ampersand ; '&'" @Test public void TestDemo3() { // logln("Demo Test 3 : Create a new table collation with rules \"& Question'-'mark ; '?' & Hash'-'mark ; '#' & Ampersand ; '&'\""); - Collator col = Collator.getInstance(Locale.ENGLISH); + Collator col = Collator.getInstance(Locale.ENGLISH); + - String baseRules = ((RuleBasedCollator)col).getRules(); String newRules = "& Question'-'mark ; '?' & Hash'-'mark ; '#' & Ampersand ; '&'"; newRules = baseRules + newRules; - RuleBasedCollator myCollation = null; + RuleBasedCollator myCollation = null; try { myCollation = new RuleBasedCollator(newRules); }catch(Exception e){ errln("Fail to create RuleBasedCollator with rules:" + newRules); return; - } + } int j, n; for (j = 0; j < TOTALTESTSET; j++) { @@ -139,25 +142,25 @@ public class G7CollationTest extends TestFmwk{ } } } - - // perform test with added rules + + // perform test with added rules // " & aa ; a'-' & ee ; e'-' & ii ; i'-' & oo ; o'-' & uu ; u'-' " @Test public void TestDemo4() { logln("Demo Test 4 : Create a new table collation with rules \" & aa ; a'-' & ee ; e'-' & ii ; i'-' & oo ; o'-' & uu ; u'-' \""); - Collator col = Collator.getInstance(Locale.ENGLISH); + Collator col = Collator.getInstance(Locale.ENGLISH); String baseRules = ((RuleBasedCollator)col).getRules(); String newRules = " & aa ; a'-' & ee ; e'-' & ii ; i'-' & oo ; o'-' & uu ; u'-' "; newRules = baseRules + newRules; - RuleBasedCollator myCollation = null; + RuleBasedCollator myCollation = null; try { myCollation = new RuleBasedCollator(newRules); }catch(Exception e){ errln("Fail to create RuleBasedCollator with rules:" + newRules); return; - } + } int j, n; for (j = 0; j < TOTALTESTSET; j++) { @@ -166,7 +169,7 @@ public class G7CollationTest extends TestFmwk{ } } } - + @Test public void TestG7Data() { Locale locales[] = { @@ -199,21 +202,21 @@ public class G7CollationTest extends TestFmwk{ myCollation = null; } } - - + + // main test routine, tests comparisons for a set of strings against sets of expected results - private void doTest(Collator myCollation, String source, String target, + private void doTest(Collator myCollation, String source, String target, int result){ - + int compareResult = myCollation.compare(source, target); CollationKey sortKey1, sortKey2; sortKey1 = myCollation.getCollationKey(source); sortKey2 = myCollation.getCollationKey(target); int keyResult = sortKey1.compareTo(sortKey2); - reportCResult(source, target, sortKey1, sortKey2, compareResult, + reportCResult(source, target, sortKey1, sortKey2, compareResult, keyResult, compareResult, result); } - + private void reportCResult( String source, String target, CollationKey sourceKey, CollationKey targetKey, int compareResult, int keyResult, int incResult, int expectedResult ){ if (expectedResult < -1 || expectedResult > 1) { @@ -226,13 +229,13 @@ public class G7CollationTest extends TestFmwk{ boolean ok3 = (incResult == expectedResult); if (ok1 && ok2 && ok3 && !isVerbose()){ - return; + return; } else { String msg1 = ok1? "Ok: compare(\"" : "FAIL: compare(\""; String msg2 = "\", \""; String msg3 = "\") returned "; String msg4 = "; expected "; - + String sExpect = new String(""); String sResult = new String(""); sResult = CollationTest.appendCompareResult(compareResult, sResult); @@ -242,7 +245,7 @@ public class G7CollationTest extends TestFmwk{ } else { errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect); } - + msg1 = ok2 ? "Ok: key(\"" : "FAIL: key(\""; msg2 = "\").compareTo(key(\""; msg3 = "\")) returned "; @@ -255,7 +258,7 @@ public class G7CollationTest extends TestFmwk{ msg2 = " vs. "; errln(msg1 + CollationTest.prettify(sourceKey) + msg2 + CollationTest.prettify(targetKey)); } - + msg1 = ok3 ? "Ok: incCompare(\"" : "FAIL: incCompare(\""; msg2 = "\", \""; msg3 = "\") returned "; @@ -266,7 +269,7 @@ public class G7CollationTest extends TestFmwk{ logln(msg1 + source + msg2 + target + msg3 + sResult); } else { errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect); - } + } } } } diff --git a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/LotusCollationKoreanTest.java b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/LotusCollationKoreanTest.java index 9112d3639f1..06280bb17d6 100644 --- a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/LotusCollationKoreanTest.java +++ b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/LotusCollationKoreanTest.java @@ -7,46 +7,49 @@ ******************************************************************************* */ -/** +/** * Port From: ICU4C v2.1 : Collate/LotusCollationKoreanTest * Source File: $ICU4CRoot/source/test/intltest/lcukocol.cpp **/ - + package com.ibm.icu.dev.test.collator; - + import java.util.Locale; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.CollationKey; import com.ibm.icu.text.Collator; - + +@RunWith(JUnit4.class) public class LotusCollationKoreanTest extends TestFmwk{ private static char[][] testSourceCases = { {0xac00} }; - + private static char[][] testTargetCases = { {0xac01} }; - + private static int[] results = { -1 }; - + private Collator myCollation; - + public LotusCollationKoreanTest() { } - + @Before public void init()throws Exception { myCollation = Collator.getInstance(Locale.KOREAN); myCollation.setDecomposition(Collator.CANONICAL_DECOMPOSITION); } - + // performs test with strength TERIARY @Test public void TestTertiary() { @@ -56,7 +59,7 @@ public class LotusCollationKoreanTest extends TestFmwk{ doTest(testSourceCases[i], testTargetCases[i], results[i]); } } - + // main test routine, tests rules specific to "Korean" locale private void doTest( char[] source, char[] target, int result) { String s = new String(source); @@ -66,7 +69,7 @@ public class LotusCollationKoreanTest extends TestFmwk{ sortKey1 = myCollation.getCollationKey(s); sortKey2 = myCollation.getCollationKey(t); int keyResult = sortKey1.compareTo(sortKey2); - reportCResult( s, t, sortKey1, sortKey2, compareResult, keyResult, compareResult, result ); + reportCResult( s, t, sortKey1, sortKey2, compareResult, keyResult, compareResult, result ); } private void reportCResult( String source, String target, CollationKey sourceKey, CollationKey targetKey, @@ -81,13 +84,13 @@ public class LotusCollationKoreanTest extends TestFmwk{ boolean ok3 = (incResult == expectedResult); if (ok1 && ok2 && ok3 && !isVerbose()) { - return; + return; } else { String msg1 = ok1? "Ok: compare(\"" : "FAIL: compare(\""; String msg2 = "\", \""; String msg3 = "\") returned "; String msg4 = "; expected "; - + String sExpect = new String(""); String sResult = new String(""); sResult = CollationTest.appendCompareResult(compareResult, sResult); @@ -97,7 +100,7 @@ public class LotusCollationKoreanTest extends TestFmwk{ } else { errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect); } - + msg1 = ok2 ? "Ok: key(\"" : "FAIL: key(\""; msg2 = "\").compareTo(key(\""; msg3 = "\")) returned "; @@ -110,7 +113,7 @@ public class LotusCollationKoreanTest extends TestFmwk{ msg2 = " vs. "; errln(msg1 + CollationTest.prettify(sourceKey) + msg2 + CollationTest.prettify(targetKey)); } - + msg1 = ok3 ? "Ok: incCompare(\"" : "FAIL: incCompare(\""; msg2 = "\", \""; msg3 = "\") returned "; @@ -121,7 +124,7 @@ public class LotusCollationKoreanTest extends TestFmwk{ logln(msg1 + source + msg2 + target + msg3 + sResult); } else { errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect); - } + } } } } diff --git a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/UCAConformanceTest.java b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/UCAConformanceTest.java index ec0c876d6e0..f2ea0247859 100644 --- a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/UCAConformanceTest.java +++ b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/collator/UCAConformanceTest.java @@ -18,6 +18,8 @@ import java.io.IOException; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.dev.test.TestUtil; @@ -29,6 +31,7 @@ import com.ibm.icu.text.UTF16; import com.ibm.icu.util.ULocale; import com.ibm.icu.util.VersionInfo; +@RunWith(JUnit4.class) public class UCAConformanceTest extends TestFmwk { public UCAConformanceTest() { diff --git a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/format/GlobalizationPreferencesTest.java b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/format/GlobalizationPreferencesTest.java index 68a085b0eeb..7bc21bc6365 100644 --- a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/format/GlobalizationPreferencesTest.java +++ b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/format/GlobalizationPreferencesTest.java @@ -15,6 +15,8 @@ import java.util.MissingResourceException; import java.util.ResourceBundle; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.BreakIterator; @@ -32,8 +34,7 @@ import com.ibm.icu.util.JapaneseCalendar; import com.ibm.icu.util.TimeZone; import com.ibm.icu.util.ULocale; - - +@RunWith(JUnit4.class) public class GlobalizationPreferencesTest extends TestFmwk { @Test public void TestDefault() { @@ -46,7 +47,7 @@ public class GlobalizationPreferencesTest extends TestFmwk { // If not, some test cases will fail... errln("FAIL: The default locale of the test environment must be en_US"); } - + logln("Default locale: " + defLocale.toString()); // First locale is en_US @@ -68,7 +69,7 @@ public class GlobalizationPreferencesTest extends TestFmwk { if (gpLocale2 != null) { errln("FAIL: Number of locales must be 2"); } - + // Calendar locale Calendar cal = gp.getCalendar(); ULocale calLocale = cal.getLocale(ULocale.VALID_LOCALE); @@ -118,7 +119,7 @@ public class GlobalizationPreferencesTest extends TestFmwk { GlobalizationPreferences gp = new GlobalizationPreferences(); if (gp.isFrozen()) { errln("FAIL: This object is not yet frozen"); - } + } logln("Call reset()"); boolean bSet = true; @@ -199,7 +200,7 @@ public class GlobalizationPreferencesTest extends TestFmwk { if (bSet) { errln("FAIL: setLocale(ULocale) must be blocked after frozen"); } - + // setTerritory(String) logln("Call setTerritory(String) after frozen"); bSet = true; @@ -214,11 +215,11 @@ public class GlobalizationPreferencesTest extends TestFmwk { // Modifiable clone logln("Create a modifiable clone"); - GlobalizationPreferences gp1 = (GlobalizationPreferences)gp.cloneAsThawed(); + GlobalizationPreferences gp1 = gp.cloneAsThawed(); if (gp1.isFrozen()) { errln("FAIL: The object returned by cloneAsThawed() must not be frozen yet"); - } + } // setLocale(ULocale) logln("Call setLocale(ULocale) of the modifiable clone"); @@ -230,7 +231,7 @@ public class GlobalizationPreferencesTest extends TestFmwk { } if (!bSet) { errln("FAIL: setLocales(ULocale) must not throw an exception before frozen"); - } + } } static String[][] INPUT_LOCALEIDS = { @@ -283,7 +284,7 @@ public class GlobalizationPreferencesTest extends TestFmwk { sb.append(localeStrings[j]); } logln("Input locales: " + sb.toString()); - + gp.reset(); gp.setLocales(locales); @@ -292,7 +293,7 @@ public class GlobalizationPreferencesTest extends TestFmwk { errln("FAIL: Number of locales mismatch - GP:" + resultLocales.size() + " Expected:" + RESULTS_LOCALEIDS[i].length); } else { - + for (int j = 0; j < RESULTS_LOCALEIDS[i].length; j++) { ULocale loc = gp.getLocale(j); logln("Locale[" + j + "]: " + loc.toString()); @@ -300,10 +301,10 @@ public class GlobalizationPreferencesTest extends TestFmwk { errln("FAIL: Locale index(" + j + ") does not match - GP:" + loc.toString() + " Expected:" + RESULTS_LOCALEIDS[i][j]); } - } + } } } - + // setLocales(ULocale[]) for (int i = 0; i < INPUT_LOCALEIDS.length; i++) { String[] localeStrings = INPUT_LOCALEIDS[i]; @@ -317,7 +318,7 @@ public class GlobalizationPreferencesTest extends TestFmwk { sb.append(localeStrings[j]); } logln("Input locales: " + sb.toString()); - + gp.reset(); gp.setLocales(localeArray); @@ -326,7 +327,7 @@ public class GlobalizationPreferencesTest extends TestFmwk { errln("FAIL: Number of locales mismatch - GP:" + resultLocales.size() + " Expected:" + RESULTS_LOCALEIDS[i].length); } else { - + for (int j = 0; j < RESULTS_LOCALEIDS[i].length; j++) { ULocale loc = gp.getLocale(j); logln("Locale[" + j + "]: " + loc.toString()); @@ -334,7 +335,7 @@ public class GlobalizationPreferencesTest extends TestFmwk { errln("FAIL: Locale index(" + j + ") does not match - GP:" + loc.toString() + " Expected:" + RESULTS_LOCALEIDS[i][j]); } - } + } } } @@ -342,7 +343,7 @@ public class GlobalizationPreferencesTest extends TestFmwk { for (int i = 0; i < ACCEPT_LANGUAGES.length; i++) { String acceptLanguage = ACCEPT_LANGUAGES[i]; logln("Accept language: " + acceptLanguage); - + gp.reset(); gp.setLocales(acceptLanguage); @@ -351,7 +352,7 @@ public class GlobalizationPreferencesTest extends TestFmwk { errln("FAIL: Number of locales mismatch - GP:" + resultLocales.size() + " Expected:" + RESULTS_LOCALEIDS[i].length); } else { - + for (int j = 0; j < RESULTS_LOCALEIDS[i].length; j++) { ULocale loc = gp.getLocale(j); logln("Locale[" + j + "]: " + loc.toString()); @@ -359,7 +360,7 @@ public class GlobalizationPreferencesTest extends TestFmwk { errln("FAIL: Locale index(" + j + ") does not match - GP:" + loc.toString() + " Expected:" + RESULTS_LOCALEIDS[i][j]); } - } + } } } @@ -370,7 +371,7 @@ public class GlobalizationPreferencesTest extends TestFmwk { if (!gp.getLocale(0).toString().equals("de_AT")) { errln("FAIL: getLocale(0) returns " + gp.getLocale(0).toString() + " Expected: de_AT"); } - + // Invalid accept-language logln("Set locale - ko_KR"); gp.setLocale(new ULocale("ko_KR")); @@ -395,7 +396,7 @@ public class GlobalizationPreferencesTest extends TestFmwk { String baseName = "com.ibm.icu.dev.data.resources.TestDataElements"; ResourceBundle rb; - logln("Get a resource bundle " + baseName + + logln("Get a resource bundle " + baseName + " using GlobalizationPreferences initialized by locales - en_GB, en_US"); GlobalizationPreferences gp = new GlobalizationPreferences(); ULocale[] locales = new ULocale[2]; @@ -415,14 +416,14 @@ public class GlobalizationPreferencesTest extends TestFmwk { gp.reset(); - logln("Get a resource bundle " + baseName + + logln("Get a resource bundle " + baseName + " using GlobalizationPreferences initialized by locales - ja, en_US_California"); locales = new ULocale[2]; locales[0] = new ULocale("ja"); locales[1] = new ULocale("en_US_California"); gp.setLocales(locales); - + try { rb = gp.getResourceBundle(baseName, Thread.currentThread().getContextClassLoader()); String str = rb.getString("from_en_US"); @@ -478,7 +479,7 @@ public class GlobalizationPreferencesTest extends TestFmwk { // Freeze logln("Freeze this object"); gp.freeze(); - + boolean bFrozen = false; try { gp.setTerritory("FR"); @@ -495,7 +496,7 @@ public class GlobalizationPreferencesTest extends TestFmwk { } // Safe clone - GlobalizationPreferences gp1 = (GlobalizationPreferences)gp.cloneAsThawed(); + GlobalizationPreferences gp1 = gp.cloneAsThawed(); territory = gp1.getTerritory(); if (!territory.equals("CA")) { errln("FAIL: Territory is " + territory + " - Expected: CA"); @@ -505,7 +506,7 @@ public class GlobalizationPreferencesTest extends TestFmwk { ULocale[] locales = new ULocale[2]; locales[0] = new ULocale("ja"); locales[1] = new ULocale("zh_Hant_TW"); - + logln("Set locales - ja, zh_Hant_TW"); gp1.setLocales(locales); @@ -594,7 +595,7 @@ public class GlobalizationPreferencesTest extends TestFmwk { // Safe clone logln("cloneAsThawed"); - GlobalizationPreferences gp1 = (GlobalizationPreferences)gp.cloneAsThawed(); + GlobalizationPreferences gp1 = gp.cloneAsThawed(); cur = gp.getCurrency(); code = cur.getCurrencyCode(); if (!code.equals("BRL")) { @@ -674,7 +675,7 @@ public class GlobalizationPreferencesTest extends TestFmwk { // Safe clone logln("cloneAsThawed"); - GlobalizationPreferences gp1 = (GlobalizationPreferences)gp.cloneAsThawed(); + GlobalizationPreferences gp1 = gp.cloneAsThawed(); cal = gp.getCalendar(); calType = cal.getType(); if (!calType.equals("japanese")) { @@ -694,7 +695,7 @@ public class GlobalizationPreferencesTest extends TestFmwk { public void TestTimeZone() { GlobalizationPreferences gp = new GlobalizationPreferences(); - // Set locale - zh_CN + // Set locale - zh_CN logln("Set locale - zh_CN"); gp.setLocale(new ULocale("zh_CN")); TimeZone tz = gp.getTimeZone(); @@ -757,7 +758,7 @@ public class GlobalizationPreferencesTest extends TestFmwk { // Modifiable clone logln("cloneAsThawed"); - GlobalizationPreferences gp1 = (GlobalizationPreferences)gp.cloneAsThawed(); + GlobalizationPreferences gp1 = gp.cloneAsThawed(); tz = gp1.getTimeZone(); tzid = tz.getID(); if (!tzid.equals(customJstId)) { @@ -770,7 +771,7 @@ public class GlobalizationPreferencesTest extends TestFmwk { tzid = tz.getID(); if (!tzid.equals(cst.getID())) { errln("FAIL: Time zone ID is " + tzid + " Expected: " + cst.getID()); - } + } } @Test @@ -840,7 +841,7 @@ public class GlobalizationPreferencesTest extends TestFmwk { // Modifiable clone logln("cloneAsThawed"); - GlobalizationPreferences gp1 = (GlobalizationPreferences)gp.cloneAsThawed(); + GlobalizationPreferences gp1 = gp.cloneAsThawed(); coll = gp1.getCollator(); locStr = coll.getLocale(ULocale.VALID_LOCALE).toString(); if (!locStr.equals("it")) { @@ -939,7 +940,7 @@ public class GlobalizationPreferencesTest extends TestFmwk { // Modifiable clone logln("cloneAsThawed"); - GlobalizationPreferences gp1 = (GlobalizationPreferences)gp.cloneAsThawed(); + GlobalizationPreferences gp1 = gp.cloneAsThawed(); brk = gp1.getBreakIterator(GlobalizationPreferences.BI_WORD); /* TODO: JB#5383 locStr = brk.getLocale(ULocale.VALID_LOCALE).toString(); @@ -1207,7 +1208,7 @@ public class GlobalizationPreferencesTest extends TestFmwk { // Set locale - en_GB logln("Set locale - en_GB"); gp.setLocale(new ULocale("en_GB")); - + // Date - full df = gp.getDateFormat(GlobalizationPreferences.DF_FULL, GlobalizationPreferences.DF_NONE); pattern = ((SimpleDateFormat)df).toPattern(); @@ -1354,9 +1355,9 @@ public class GlobalizationPreferencesTest extends TestFmwk { // Modifiable clone logln("cloneAsThawed"); - GlobalizationPreferences gp1 = (GlobalizationPreferences)gp.cloneAsThawed(); + GlobalizationPreferences gp1 = gp.cloneAsThawed(); gp1.setDateFormat(GlobalizationPreferences.DF_LONG, GlobalizationPreferences.DF_NONE, customLD); - + df = gp1.getDateFormat(GlobalizationPreferences.DF_SHORT, GlobalizationPreferences.DF_SHORT); dfCal = df.getCalendar(); if (!(dfCal instanceof JapaneseCalendar)) { @@ -1397,7 +1398,7 @@ public class GlobalizationPreferencesTest extends TestFmwk { if (!numStr.equals("\u20a9\u00a0123,457")) { errln("FAIL: Number string is " + numStr + " Expected: \u20a9\u00a0123,457"); } - + // Set locale - de_DE logln("Set locale - de_DE"); gp.setLocale(new ULocale("de_DE")); @@ -1464,7 +1465,7 @@ public class GlobalizationPreferencesTest extends TestFmwk { if (!illegalArg) { errln("FAIL: getNumberFormat must throw IllegalArgumentException for type -1"); } - + // Set explicit territory logln("Set territory - US"); gp.setTerritory("US"); @@ -1496,7 +1497,7 @@ public class GlobalizationPreferencesTest extends TestFmwk { NumberFormat customInt = NumberFormat.getIntegerInstance(new ULocale("pt_PT")); gp.setNumberFormat(GlobalizationPreferences.NF_INTEGER, customInt); - + nf = gp.getNumberFormat(GlobalizationPreferences.NF_NUMBER); if (!nf.getLocale(ULocale.VALID_LOCALE).toString().equals("he_IL")) { errln("FAIL: The NumberFormat instance must use locale he_IL"); @@ -1535,7 +1536,7 @@ public class GlobalizationPreferencesTest extends TestFmwk { } // Create a modifiable clone - GlobalizationPreferences gp1 = (GlobalizationPreferences)gp.cloneAsThawed(); + GlobalizationPreferences gp1 = gp.cloneAsThawed(); // Number type format's locale is still he_IL nf = gp1.getNumberFormat(GlobalizationPreferences.NF_NUMBER); diff --git a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/format/RbnfLenientScannerTest.java b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/format/RbnfLenientScannerTest.java index 84fcb6247fe..ad8dfa3e9c5 100644 --- a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/format/RbnfLenientScannerTest.java +++ b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/format/RbnfLenientScannerTest.java @@ -14,6 +14,8 @@ import java.util.Locale; import java.util.Random; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.text.RbnfScannerProviderImpl; @@ -21,6 +23,7 @@ import com.ibm.icu.text.RbnfLenientScannerProvider; import com.ibm.icu.text.RuleBasedNumberFormat; import com.ibm.icu.util.ULocale; +@RunWith(JUnit4.class) public class RbnfLenientScannerTest extends TestFmwk { private static final RbnfLenientScannerProvider provider = new RbnfScannerProviderImpl(); @@ -160,7 +163,7 @@ public class RbnfLenientScannerTest extends TestFmwk { if (r == null) { r = createRandom(); } - n = ((int)(r.nextInt(10000) - 3000)) / 16d; + n = (r.nextInt(10000) - 3000) / 16d; } String s = fmt.format(n); diff --git a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/search/SearchTest.java b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/search/SearchTest.java index a633265d616..7b1bab398c8 100644 --- a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/search/SearchTest.java +++ b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/search/SearchTest.java @@ -29,6 +29,8 @@ import java.util.Locale; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.BreakIterator; @@ -39,6 +41,7 @@ import com.ibm.icu.text.SearchIterator.ElementComparisonType; import com.ibm.icu.text.StringSearch; import com.ibm.icu.util.ULocale; +@RunWith(JUnit4.class) public class SearchTest extends TestFmwk { //inner class diff --git a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/util/ICUResourceBundleCollationTest.java b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/util/ICUResourceBundleCollationTest.java index 7b25d4518fe..009613adf45 100644 --- a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/util/ICUResourceBundleCollationTest.java +++ b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/util/ICUResourceBundleCollationTest.java @@ -11,6 +11,8 @@ package com.ibm.icu.dev.test.util; import java.util.MissingResourceException; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.ICUData; @@ -19,7 +21,7 @@ import com.ibm.icu.text.Collator; import com.ibm.icu.util.ULocale; import com.ibm.icu.util.UResourceBundle; - +@RunWith(JUnit4.class) public final class ICUResourceBundleCollationTest extends TestFmwk { private static final String COLLATION_RESNAME = "collations"; private static final String COLLATION_KEYWORD = "collation"; @@ -146,7 +148,7 @@ public final class ICUResourceBundleCollationTest extends TestFmwk { @Test public void TestOpen(){ - UResourceBundle bundle = (UResourceBundle)UResourceBundle.getBundleInstance(ICUData.ICU_COLLATION_BASE_NAME, "en_US_POSIX"); + UResourceBundle bundle = UResourceBundle.getBundleInstance(ICUData.ICU_COLLATION_BASE_NAME, "en_US_POSIX"); if(bundle==null){ errln("could not load the stream"); } diff --git a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/util/LocaleAliasCollationTest.java b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/util/LocaleAliasCollationTest.java index 43bfc2d42e7..ce1dafd2fbf 100644 --- a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/util/LocaleAliasCollationTest.java +++ b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/util/LocaleAliasCollationTest.java @@ -13,10 +13,13 @@ import java.util.HashMap; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.text.Collator; import com.ibm.icu.util.ULocale; +@RunWith(JUnit4.class) public class LocaleAliasCollationTest extends com.ibm.icu.dev.test.TestFmwk { private static final ULocale[][] _LOCALES = { {new ULocale("en", "RH"), new ULocale("en", "ZW")}, diff --git a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/util/ULocaleCollationTest.java b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/util/ULocaleCollationTest.java index b84408909ce..0562e1fed59 100644 --- a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/util/ULocaleCollationTest.java +++ b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/util/ULocaleCollationTest.java @@ -23,6 +23,8 @@ import java.util.Locale; import java.util.Set; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.Collator; @@ -33,17 +35,21 @@ import com.ibm.icu.text.LocaleDisplayNames.UiListItem; import com.ibm.icu.util.IllformedLocaleException; import com.ibm.icu.util.ULocale; +@RunWith(JUnit4.class) public class ULocaleCollationTest extends TestFmwk { @Test public void TestCollator() { checkService("ja_JP_YOKOHAMA", new ServiceFacade() { + @Override public Object create(ULocale req) { return Collator.getInstance(req); } }, null, new Registrar() { + @Override public Object register(ULocale loc, Object prototype) { return Collator.registerInstance((Collator) prototype, loc); } + @Override public boolean unregister(Object key) { return Collator.unregister(key); } @@ -233,99 +239,99 @@ public class ULocaleCollationTest extends TestFmwk { } @Test - public void TestNameList() { - String[][][] tests = { + public void TestNameList() { + String[][][] tests = { /* name in French, name in self, minimized, modified */ - {{"fr-Cyrl-BE", "fr-Cyrl-CA"}, - {"Français (cyrillique, Belgique)", "Français (cyrillique, Belgique)", "fr_Cyrl_BE", "fr_Cyrl_BE"}, - {"Français (cyrillique, Canada)", "Français (cyrillique, Canada)", "fr_Cyrl_CA", "fr_Cyrl_CA"}, - }, - {{"en", "de", "fr", "zh"}, - {"Allemand", "Deutsch", "de", "de"}, - {"Anglais", "English", "en", "en"}, - {"Chinois", "中文", "zh", "zh"}, - {"Français", "Français", "fr", "fr"}, - }, + {{"fr-Cyrl-BE", "fr-Cyrl-CA"}, + {"Français (cyrillique, Belgique)", "Français (cyrillique, Belgique)", "fr_Cyrl_BE", "fr_Cyrl_BE"}, + {"Français (cyrillique, Canada)", "Français (cyrillique, Canada)", "fr_Cyrl_CA", "fr_Cyrl_CA"}, + }, + {{"en", "de", "fr", "zh"}, + {"Allemand", "Deutsch", "de", "de"}, + {"Anglais", "English", "en", "en"}, + {"Chinois", "中文", "zh", "zh"}, + {"Français", "Français", "fr", "fr"}, + }, // some non-canonical names - {{"iw", "iw-US", "no", "no-Cyrl", "in", "in-YU"}, - {"Hébreu (États-Unis)", "עברית (ארצות הברית)", "iw_US", "iw_US"}, - {"Hébreu (Israël)", "עברית (ישראל)", "iw", "iw_IL"}, - {"Indonésien (Indonésie)", "Indonesia (Indonesia)", "in", "in_ID"}, - {"Indonésien (Serbie)", "Indonesia (Serbia)", "in_YU", "in_YU"}, - {"Norvégien (cyrillique)", "Norsk (kyrillisk)", "no_Cyrl", "no_Cyrl"}, - {"Norvégien (latin)", "Norsk (latinsk)", "no", "no_Latn"}, - }, - {{"zh-Hant-TW", "en", "en-gb", "fr", "zh-Hant", "de", "de-CH", "zh-TW"}, - {"Allemand (Allemagne)", "Deutsch (Deutschland)", "de", "de_DE"}, - {"Allemand (Suisse)", "Deutsch (Schweiz)", "de_CH", "de_CH"}, - {"Anglais (États-Unis)", "English (United States)", "en", "en_US"}, - {"Anglais (Royaume-Uni)", "English (United Kingdom)", "en_GB", "en_GB"}, - {"Chinois (traditionnel)", "中文(繁體)", "zh_Hant", "zh_Hant"}, - {"Français", "Français", "fr", "fr"}, - }, - {{"zh", "en-gb", "en-CA", "fr-Latn-FR"}, - {"Anglais (Canada)", "English (Canada)", "en_CA", "en_CA"}, - {"Anglais (Royaume-Uni)", "English (United Kingdom)", "en_GB", "en_GB"}, - {"Chinois", "中文", "zh", "zh"}, - {"Français", "Français", "fr", "fr"}, - }, - {{"en-gb", "fr", "zh-Hant", "zh-SG", "sr", "sr-Latn"}, - {"Anglais (Royaume-Uni)", "English (United Kingdom)", "en_GB", "en_GB"}, - {"Chinois (simplifié, Singapour)", "中文(简体,新加坡)", "zh_SG", "zh_Hans_SG"}, - {"Chinois (traditionnel, Taïwan)", "中文(繁體,台灣)", "zh_Hant", "zh_Hant_TW"}, - {"Français", "Français", "fr", "fr"}, - {"Serbe (cyrillique)", "Српски (ћирилица)", "sr", "sr_Cyrl"}, - {"Serbe (latin)", "Srpski (latinica)", "sr_Latn", "sr_Latn"}, - }, - {{"fr-Cyrl", "fr-Arab"}, - {"Français (arabe)", "Français (arabe)", "fr_Arab", "fr_Arab"}, - {"Français (cyrillique)", "Français (cyrillique)", "fr_Cyrl", "fr_Cyrl"}, - }, - {{"fr-Cyrl-BE", "fr-Arab-CA"}, - {"Français (arabe, Canada)", "Français (arabe, Canada)", "fr_Arab_CA", "fr_Arab_CA"}, - {"Français (cyrillique, Belgique)", "Français (cyrillique, Belgique)", "fr_Cyrl_BE", "fr_Cyrl_BE"}, - } - }; - ULocale french = ULocale.FRENCH; - LocaleDisplayNames names = LocaleDisplayNames.getInstance(french, - DisplayContext.CAPITALIZATION_FOR_UI_LIST_OR_MENU); - for (Type type : DisplayContext.Type.values()) { - logln("Contexts: " + names.getContext(type).toString()); - } - Collator collator = Collator.getInstance(french); + {{"iw", "iw-US", "no", "no-Cyrl", "in", "in-YU"}, + {"Hébreu (États-Unis)", "עברית (ארצות הברית)", "iw_US", "iw_US"}, + {"Hébreu (Israël)", "עברית (ישראל)", "iw", "iw_IL"}, + {"Indonésien (Indonésie)", "Indonesia (Indonesia)", "in", "in_ID"}, + {"Indonésien (Serbie)", "Indonesia (Serbia)", "in_YU", "in_YU"}, + {"Norvégien (cyrillique)", "Norsk (kyrillisk)", "no_Cyrl", "no_Cyrl"}, + {"Norvégien (latin)", "Norsk (latinsk)", "no", "no_Latn"}, + }, + {{"zh-Hant-TW", "en", "en-gb", "fr", "zh-Hant", "de", "de-CH", "zh-TW"}, + {"Allemand (Allemagne)", "Deutsch (Deutschland)", "de", "de_DE"}, + {"Allemand (Suisse)", "Deutsch (Schweiz)", "de_CH", "de_CH"}, + {"Anglais (États-Unis)", "English (United States)", "en", "en_US"}, + {"Anglais (Royaume-Uni)", "English (United Kingdom)", "en_GB", "en_GB"}, + {"Chinois (traditionnel)", "中文(繁體)", "zh_Hant", "zh_Hant"}, + {"Français", "Français", "fr", "fr"}, + }, + {{"zh", "en-gb", "en-CA", "fr-Latn-FR"}, + {"Anglais (Canada)", "English (Canada)", "en_CA", "en_CA"}, + {"Anglais (Royaume-Uni)", "English (United Kingdom)", "en_GB", "en_GB"}, + {"Chinois", "中文", "zh", "zh"}, + {"Français", "Français", "fr", "fr"}, + }, + {{"en-gb", "fr", "zh-Hant", "zh-SG", "sr", "sr-Latn"}, + {"Anglais (Royaume-Uni)", "English (United Kingdom)", "en_GB", "en_GB"}, + {"Chinois (simplifié, Singapour)", "中文(简体,新加坡)", "zh_SG", "zh_Hans_SG"}, + {"Chinois (traditionnel, Taïwan)", "中文(繁體,台灣)", "zh_Hant", "zh_Hant_TW"}, + {"Français", "Français", "fr", "fr"}, + {"Serbe (cyrillique)", "Српски (ћирилица)", "sr", "sr_Cyrl"}, + {"Serbe (latin)", "Srpski (latinica)", "sr_Latn", "sr_Latn"}, + }, + {{"fr-Cyrl", "fr-Arab"}, + {"Français (arabe)", "Français (arabe)", "fr_Arab", "fr_Arab"}, + {"Français (cyrillique)", "Français (cyrillique)", "fr_Cyrl", "fr_Cyrl"}, + }, + {{"fr-Cyrl-BE", "fr-Arab-CA"}, + {"Français (arabe, Canada)", "Français (arabe, Canada)", "fr_Arab_CA", "fr_Arab_CA"}, + {"Français (cyrillique, Belgique)", "Français (cyrillique, Belgique)", "fr_Cyrl_BE", "fr_Cyrl_BE"}, + } + }; + ULocale french = ULocale.FRENCH; + LocaleDisplayNames names = LocaleDisplayNames.getInstance(french, + DisplayContext.CAPITALIZATION_FOR_UI_LIST_OR_MENU); + for (Type type : DisplayContext.Type.values()) { + logln("Contexts: " + names.getContext(type).toString()); + } + Collator collator = Collator.getInstance(french); - for (String[][] test : tests) { - Set list = new LinkedHashSet(); - List expected = new ArrayList(); - for (String item : test[0]) { - list.add(new ULocale(item)); - } - for (int i = 1; i < test.length; ++i) { - String[] rawRow = test[i]; - expected.add(new UiListItem(new ULocale(rawRow[2]), new ULocale(rawRow[3]), rawRow[0], rawRow[1])); - } - List newList = names.getUiList(list, false, collator); - if (!expected.equals(newList)) { - if (expected.size() != newList.size()) { - errln(list.toString() + ": wrong size" + expected + ", " + newList); - } else { - errln(list.toString()); - for (int i = 0; i < expected.size(); ++i) { - assertEquals(i+"", expected.get(i), newList.get(i)); - } - } - } else { - assertEquals(list.toString(), expected, newList); - } - } - } + for (String[][] test : tests) { + Set list = new LinkedHashSet(); + List expected = new ArrayList(); + for (String item : test[0]) { + list.add(new ULocale(item)); + } + for (int i = 1; i < test.length; ++i) { + String[] rawRow = test[i]; + expected.add(new UiListItem(new ULocale(rawRow[2]), new ULocale(rawRow[3]), rawRow[0], rawRow[1])); + } + List newList = names.getUiList(list, false, collator); + if (!expected.equals(newList)) { + if (expected.size() != newList.size()) { + errln(list.toString() + ": wrong size" + expected + ", " + newList); + } else { + errln(list.toString()); + for (int i = 0; i < expected.size(); ++i) { + assertEquals(i+"", expected.get(i), newList.get(i)); + } + } + } else { + assertEquals(list.toString(), expected, newList); + } + } + } @Test public void TestIllformedLocale() { - ULocale french = ULocale.FRENCH; - Collator collator = Collator.getInstance(french); - LocaleDisplayNames names = LocaleDisplayNames.getInstance(french, - DisplayContext.CAPITALIZATION_FOR_UI_LIST_OR_MENU); + ULocale french = ULocale.FRENCH; + Collator collator = Collator.getInstance(french); + LocaleDisplayNames names = LocaleDisplayNames.getInstance(french, + DisplayContext.CAPITALIZATION_FOR_UI_LIST_OR_MENU); for (String malformed : Arrays.asList("en-a", "$", "ü--a", "en--US")) { try { Set supported = Collections.singleton(new ULocale(malformed)); @@ -333,7 +339,7 @@ public class ULocaleCollationTest extends TestFmwk { assertNull("Failed to detect bogus locale «" + malformed + "»", supported); } catch (IllformedLocaleException e) { logln("Successfully detected ill-formed locale «" + malformed + "»:" + e.getMessage()); - } + } } } } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/bidi/BiDiConformanceTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/bidi/BiDiConformanceTest.java index be2ea8e80f0..e0ce5aeb2e8 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/bidi/BiDiConformanceTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/bidi/BiDiConformanceTest.java @@ -12,6 +12,8 @@ import java.io.BufferedReader; import java.io.IOException; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.dev.test.TestUtil; @@ -24,6 +26,7 @@ import com.ibm.icu.text.BidiClassifier; * BiDi conformance test, using the Unicode BidiTest.txt and BidiCharacterTest.txt files. * Ported from ICU4C intltest/bidiconf.cpp . */ +@RunWith(JUnit4.class) public class BiDiConformanceTest extends TestFmwk { public BiDiConformanceTest() {} diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/bidi/TestBidiTransform.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/bidi/TestBidiTransform.java index a5800a97d62..1790c52d14b 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/bidi/TestBidiTransform.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/bidi/TestBidiTransform.java @@ -4,6 +4,8 @@ package com.ibm.icu.dev.test.bidi; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.lang.UCharacter; @@ -19,6 +21,7 @@ import com.ibm.icu.text.BidiTransform.Order; * @author Lina Kemmel * */ +@RunWith(JUnit4.class) public class TestBidiTransform extends TestFmwk { static final char LATN_ZERO = '\u0030'; diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/bigdec/DiagBigDecimalTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/bigdec/DiagBigDecimalTest.java index 8dd71f19275..46e57e366d5 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/bigdec/DiagBigDecimalTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/bigdec/DiagBigDecimalTest.java @@ -14,6 +14,8 @@ package com.ibm.icu.dev.test.bigdec; import java.math.BigInteger; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.dev.test.TestUtil; @@ -97,6 +99,7 @@ import com.ibm.icu.math.BigDecimal; * @author Mike Cowlishaw */ +@RunWith(JUnit4.class) public class DiagBigDecimalTest extends TestFmwk { private static final com.ibm.icu.math.BigDecimal zero = com.ibm.icu.math.BigDecimal.ZERO; private static final com.ibm.icu.math.BigDecimal one = com.ibm.icu.math.BigDecimal.ONE; diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/AstroTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/AstroTest.java index 9e4664fde14..7ae7c032057 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/AstroTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/AstroTest.java @@ -14,6 +14,8 @@ import java.util.Date; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.CalendarAstronomer; @@ -27,6 +29,7 @@ import com.ibm.icu.util.TimeZone; // TODO: try finding next new moon after 07/28/1984 16:00 GMT +@RunWith(JUnit4.class) public class AstroTest extends TestFmwk { static final double PI = Math.PI; @@ -350,7 +353,7 @@ public class AstroTest extends TestFmwk { // astro.setDate(cal3.getTime()); // astro.foo(); } - + @Test public void TestMoonAge(){ GregorianCalendar gc = new GregorianCalendar(new SimpleTimeZone(0,"GMT")); @@ -363,7 +366,7 @@ public class AstroTest extends TestFmwk { {2012, 5, 20, 14, 55, 59}, {2012, 5, 21, 7, 40, 40}, {2023, 9, 25, 10,00, 00}, - {2008, 7, 7, 15, 00, 33}, + {2008, 7, 7, 15, 00, 33}, {1832, 9, 24, 2, 33, 41 }, {2016, 1, 31, 23, 59, 59}, {2099, 5, 20, 14, 55, 59} diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/CalendarRegressionTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/CalendarRegressionTest.java index 71ed611ef11..e0ca7f7ffdd 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/CalendarRegressionTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/CalendarRegressionTest.java @@ -23,6 +23,8 @@ import java.util.Locale; import java.util.MissingResourceException; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.text.DateFormat; import com.ibm.icu.text.NumberFormat; @@ -43,6 +45,7 @@ import com.ibm.icu.util.ULocale; * 4145158 4145983 4147269 4149677 4162587 4165343 4166109 4167060 4173516 * 4174361 4177484 4197699 4209071 4288792 */ +@RunWith(JUnit4.class) public class CalendarRegressionTest extends com.ibm.icu.dev.test.TestFmwk { static final String[] FIELD_NAME = { "ERA", "YEAR", "MONTH", "WEEK_OF_YEAR", "WEEK_OF_MONTH", diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/CalendarTestFmwk.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/CalendarTestFmwk.java index 90d7bdef6ce..de43dc2656a 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/CalendarTestFmwk.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/CalendarTestFmwk.java @@ -27,7 +27,7 @@ import com.ibm.icu.util.SimpleTimeZone; * Defines various useful utility methods and constants */ public class CalendarTestFmwk extends TestFmwk { - + // Constants for use by subclasses, solely to save typing public final static int SUN = Calendar.SUNDAY; public final static int MON = Calendar.MONDAY; @@ -49,7 +49,7 @@ public class CalendarTestFmwk extends TestFmwk { public final static int WOM = Calendar.WEEK_OF_MONTH; public final static int DOW = Calendar.DAY_OF_WEEK; public final static int DOWM = Calendar.DAY_OF_WEEK_IN_MONTH; - + public final static SimpleTimeZone UTC = new SimpleTimeZone(0, "GMT"); private static final String[] FIELD_NAME = { @@ -75,14 +75,14 @@ public class CalendarTestFmwk extends TestFmwk { protected void doTestCases(TestCase[] cases, Calendar cal) { cal.setTimeZone(UTC); - + // Get a format to use for printing dates in the calendar system we're testing DateFormat format = DateFormat.getDateTimeInstance(cal, DateFormat.SHORT, -1, Locale.getDefault()); final String pattern = (cal instanceof ChineseCalendar) ? "E MMl/dd/y G HH:mm:ss.S z" : "E, MM/dd/yyyy G HH:mm:ss.S z"; - + ((SimpleDateFormat)format).applyPattern(pattern); // This format is used for printing Gregorian dates. @@ -93,13 +93,13 @@ public class CalendarTestFmwk extends TestFmwk { pureGreg.setGregorianChange(new Date(Long.MIN_VALUE)); DateFormat pureGregFmt = new SimpleDateFormat("E M/d/yyyy G"); pureGregFmt.setCalendar(pureGreg); - + // Now iterate through the test cases and see what happens for (int i = 0; i < cases.length; i++) { logln("\ntest case: " + i); TestCase test = cases[i]; - + // // First we want to make sure that the millis -> fields calculation works // test.applyTime will call setTime() on the calendar object, and @@ -116,7 +116,7 @@ public class CalendarTestFmwk extends TestFmwk { // // If that was OK, check the fields -> millis calculation - // test.applyFields will set all of the calendar's fields to + // test.applyFields will set all of the calendar's fields to // match those in the test case. // cal.clear(); @@ -128,10 +128,10 @@ public class CalendarTestFmwk extends TestFmwk { } } } - + static public final boolean ROLL = true; static public final boolean ADD = false; - + /** * Process test cases for add and roll methods. * Each test case is an array of integers, as follows: @@ -158,7 +158,7 @@ public class CalendarTestFmwk extends TestFmwk { protected void doRollAdd(boolean roll, Calendar cal, int[][] tests) { String name = roll ? "rolling" : "adding"; - + for (int i = 0; i < tests.length; i++) { int[] test = tests[i]; @@ -346,7 +346,7 @@ public class CalendarTestFmwk extends TestFmwk { int testTime = TestFmwk.getExhaustiveness() <= 5 ? -3 : -120; // in seconds doLimitsTest(cal, fieldsToTest, startDate, testTime); } - + /** * Test the functions getMaximum/getGeratestMinimum logically correct. * This method assumes day of week cycle is consistent. @@ -412,7 +412,7 @@ public class CalendarTestFmwk extends TestFmwk { errln("FAIL: Least maximum value of WEEK_OF_MONTH is incorrect: " + lmaxWOM + "/expected: " + expected); } } - + /** * Convert year,month,day values to the form "year/month/day". * On input the month value is zero-based, but in the result string it is one-based. diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/ChineseTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/ChineseTest.java index 62319fec949..44529e488f4 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/ChineseTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/ChineseTest.java @@ -10,6 +10,8 @@ import java.util.Date; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.text.ChineseDateFormat; import com.ibm.icu.text.DateFormat; @@ -63,6 +65,7 @@ import com.ibm.icu.util.ULocale; * Tue May 22 2096 = 4733-04*-01, Year 53, Cycle 79 * Sun Mar 22 2099 = 4736-02*-01, Year 56, Cycle 79 */ +@RunWith(JUnit4.class) public class ChineseTest extends CalendarTestFmwk { /** * Test basic mapping to and from Gregorian. @@ -79,7 +82,7 @@ public class ChineseTest extends CalendarTestFmwk { 1964, 9, 7, 4601, 8,0, 2, 1961, 12, 25, 4598, 11,0, 18, 1999, 6, 4, 4636, 4,0, 21, - + 1990, 5, 23, 4627, 4,0, 29, 1990, 5, 24, 4627, 5,0, 1, 1990, 6, 22, 4627, 5,0, 30, @@ -205,7 +208,7 @@ public class ChineseTest extends CalendarTestFmwk { // ** Millis->fields gives 0-based month -1 // These failures were fixed by changing the start search date // for the winter solstice from Dec 15 to Dec 1. - // + // // Julian Day Era Year Month Leap DOM WkDay new ChineseTestCase(1507231.5, 35, 11, 6, false, 12, SUN), new ChineseTestCase(1660037.5, 42, 9, 10, false, 27, WED), @@ -222,7 +225,7 @@ public class ChineseTest extends CalendarTestFmwk { new ChineseTestCase(2195261.5, 66, 35, 3, false, 9, SUN), //* new ChineseTestCase(2229274.5, 68, 8, 5, false, 2, SUN), //* new ChineseTestCase(2245580.5, 68, 53, 1, false, 8, WED), //** - new ChineseTestCase(2266100.5, 69, 49, 3, false, 4, SAT), + new ChineseTestCase(2266100.5, 69, 49, 3, false, 4, SAT), new ChineseTestCase(2288542.5, 70, 50, 8, false, 2, SAT), //* new ChineseTestCase(2290901.5, 70, 57, 1, false, 29, SAT), //* new ChineseTestCase(2323140.5, 72, 25, 4, true, 20, WED), //* @@ -268,14 +271,14 @@ public class ChineseTest extends CalendarTestFmwk { java.util.Calendar tempcal = java.util.Calendar.getInstance(); tempcal.clear(); - + Date[] DATA = new Date[2]; tempcal.set(2001, Calendar.MAY, 22); DATA[0] = tempcal.getTime(); tempcal.set(2001, Calendar.MAY, 23); DATA[1] = tempcal.getTime(); // Wed May 23 2001 = Month 4(leap), Day 1, Year 18, Cycle 78 - + for (int i=0; iCopticCalendar class. */ -public class CopticTest extends CalendarTestFmwk +@RunWith(JUnit4.class) +public class CopticTest extends CalendarTestFmwk { /** Constants to save typing. */ public static final int TOUT = CopticCalendar.TOUT; @@ -45,49 +48,49 @@ public class CopticTest extends CalendarTestFmwk /* Test dates from: * "The Amharic Letters of Emperor Theodore of Ethiopia to Queen Victoria and - * Her Special Envoy", David Appleyard, Girma Selasse Asfaw, Oxford University Press, + * Her Special Envoy", David Appleyard, Girma Selasse Asfaw, Oxford University Press, * June 1 1979, ISBN: 0856726605, Longwood Pr Ltd - * + * * Coptic Gregorian JD - * 20/02/1579 29/10/1862 2401443 + * 20/02/1579 29/10/1862 2401443 * 29/10/1581 05/07/1865 2402423 * 22/05/1582 29/01/1866 2402631 * 10/08/1582 17/04/1866 2402709 * 28/04/1583 05/01/1867 2402972 * 05/05/1584 13/01/1868 2403345 - * + * * -------------------------------------------------- - * + * * From the Calendrica applet: http://emr.cs.iit.edu/home/reingold/calendar-book/Calendrica.html - * + * * Coptic Gregorian JD * 07/05/-284 01/01/0000 1721060 * 08/05/-283 01/01/0001 1721426 * 06/13/-1 29/08/0283 1824664 - * + * * 01/01/0000 30/08/0283 1824665 * 01/01/0001 29/08/0284 1825030 * 01/01/0002 29/08/0285 1825395 * 01/01/0003 29/08/0286 1825760 * 01/01/0004 30/08/0287 1826126 - * 05/13/0000 28/08/0284 1825029 + * 05/13/0000 28/08/0284 1825029 * 05/13/0001 28/08/0285 1825394 * 05/13/0002 28/08/0286 1825759 * 05/13/0003 28/08/0287 1826124 * 06/13/0003 29/08/0287 1826125 first coptic leap year * 05/13/0004 28/08/0288 1826490 - * + * * 06/02/1299 13/10/1582 2299159 * 07/02/1299 14/10/1582 2299160 Julian 04/10/1582 * 08/02/1299 15/10/1582 2299161 * 09/02/1299 16/10/1582 2299162 - * + * * 23/04/1616 01/01/1900 2415021 - * 23/04/1721 01/01/2005 2453372 + * 23/04/1721 01/01/2005 2453372 * 05/13/2000 12/09/2284 2555529 */ - + /** A huge list of test cases to make sure that computeTime and computeFields * work properly for a wide range of data in the civil calendar. */ @@ -134,7 +137,7 @@ public class CopticTest extends CalendarTestFmwk new TestCase(2453371.5, 1, 1721, 4, 23, SAT, 0, 0, 0), // Gregorian: 01/01/2005 new TestCase(2555528.5, 1, 2000, 13, 5, FRI, 0, 0, 0), // Gregorian: 12/09/2284 }; - + CopticCalendar testCalendar = new CopticCalendar(); testCalendar.setLenient(true); doTestCases(tests, testCalendar); @@ -157,8 +160,8 @@ public class CopticTest extends CalendarTestFmwk m == month && d == day)) { errln("y: " + y + - " m: " + m + - " d: " + d + + " m: " + m + + " d: " + d + " --> jd: " + jd + " --> y: " + eyear + " m: " + month + @@ -194,13 +197,13 @@ public class CopticTest extends CalendarTestFmwk cal.set(1000, 0, 30); logln("1000/0/30-> " + cal.get(YEAR) + "/" + - cal.get(MONTH) + "/" + + cal.get(MONTH) + "/" + cal.get(DATE)); cal.clear(); cal.set(1, 0, 30); logln("1/0/30 -> " + cal.get(YEAR) + "/" + - cal.get(MONTH) + "/" + + cal.get(MONTH) + "/" + cal.get(DATE)); } @@ -238,19 +241,19 @@ public class CopticTest extends CalendarTestFmwk int expected = (month != maxMonth) ? 30 : (isLeap ? 6 : 5); if (maxDayOfMonth != expected) { - errln("FAIL: Expected maximum " + expected + " days for month #" - + (month + 1) + " - returned:" + maxDayOfMonth); + errln("FAIL: Expected maximum " + expected + " days for month #" + + (month + 1) + " - returned:" + maxDayOfMonth); } } } - } + } @Test public void TestCoverage() { { // new CopticCalendar(TimeZone) - CopticCalendar cal = new CopticCalendar(TimeZone.getDefault()); + CopticCalendar cal = new CopticCalendar(TimeZone.getDefault()); if(cal == null){ errln("could not create CopticCalendar with TimeZone"); } @@ -263,7 +266,7 @@ public class CopticTest extends CalendarTestFmwk errln("could not create CopticCalendar with ULocale"); } } - + { // new CopticCalendar(Locale) CopticCalendar cal = new CopticCalendar(Locale.getDefault()); @@ -271,23 +274,23 @@ public class CopticTest extends CalendarTestFmwk errln("could not create CopticCalendar with Locale"); } } - - { - // new CopticCalendar(TimeZone, Locale) - CopticCalendar cal = new CopticCalendar(TimeZone.getDefault(),Locale.getDefault()); - if(cal == null){ - errln("could not create CopticCalendar with TimeZone, Locale"); - } - } - - { - // new CopticCalendar(TimeZone, ULocale) + + { + // new CopticCalendar(TimeZone, Locale) + CopticCalendar cal = new CopticCalendar(TimeZone.getDefault(),Locale.getDefault()); + if(cal == null){ + errln("could not create CopticCalendar with TimeZone, Locale"); + } + } + + { + // new CopticCalendar(TimeZone, ULocale) CopticCalendar cal = new CopticCalendar(TimeZone.getDefault(),ULocale.getDefault()); - if(cal == null){ - errln("could not create CopticCalendar with TimeZone, ULocale"); - } - } - + if(cal == null){ + errln("could not create CopticCalendar with TimeZone, ULocale"); + } + } + { // new CopticCalendar(Date) CopticCalendar cal = new CopticCalendar(new Date()); @@ -311,7 +314,7 @@ public class CopticTest extends CalendarTestFmwk errln("could not create CopticCalendar with year,month,date,hour,minute,second"); } } - + { // data CopticCalendar cal = new CopticCalendar(1997, CopticCalendar.TOUT, 1); @@ -420,7 +423,7 @@ public class CopticTest extends CalendarTestFmwk int endMonth = testCalendar.get(Calendar.MONTH); int endDay = testCalendar.get(Calendar.DATE); if ( endYear != item.getEndYear() || endMonth != item.getEndMonth() || endDay != item.getEndDay() ) { - errln("CToJD FAILS: field " + item.getField() + " delta " + item.getDelta() + + errln("CToJD FAILS: field " + item.getField() + " delta " + item.getDelta() + " expected yr " + item.getEndYear() + " mo " + item.getEndMonth() + " da " + item.getEndDay() + " got yr " + endYear + " mo " + endMonth + " da " + endDay); } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/DangiTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/DangiTest.java index 2941dc7aa8a..3b696e0b51d 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/DangiTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/DangiTest.java @@ -10,6 +10,8 @@ package com.ibm.icu.dev.test.calendar; import java.util.Date; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.text.DateFormat; import com.ibm.icu.util.Calendar; @@ -18,6 +20,7 @@ import com.ibm.icu.util.GregorianCalendar; import com.ibm.icu.util.TimeZone; import com.ibm.icu.util.ULocale; +@RunWith(JUnit4.class) public class DangiTest extends CalendarTestFmwk { /** * Test basic mapping to and from Gregorian. @@ -33,7 +36,7 @@ public class DangiTest extends CalendarTestFmwk { 1964, 9, 7, 4297, 8,0, 2, 1961, 12, 25, 4294, 11,0, 18, 1999, 6, 4, 4332, 4,0, 21, - + 1990, 5, 23, 4323, 4,0, 29, 1990, 5, 24, 4323, 5,0, 1, 1990, 6, 22, 4323, 5,0, 30, @@ -190,14 +193,14 @@ public class DangiTest extends CalendarTestFmwk { Calendar.DAY_OF_YEAR, 1, END, 1,0,1, // Expect 1-1 - + // If we set MONTH only, that should be used Calendar.IS_LEAP_MONTH, 1, Calendar.DAY_OF_MONTH, 1, Calendar.MONTH, 3, END, 4,1,1, // Expect 4*-1 - + // If we set the DOY last, that should take precedence Calendar.MONTH, 1, // Should ignore Calendar.IS_LEAP_MONTH, 1, // Should ignore @@ -205,7 +208,7 @@ public class DangiTest extends CalendarTestFmwk { Calendar.DAY_OF_YEAR, 121, END, 4,1,2, // Expect 4*-2 - + // If we set IS_LEAP_MONTH last, that should take precedence Calendar.MONTH, 3, Calendar.DAY_OF_MONTH, 1, @@ -309,7 +312,7 @@ public class DangiTest extends CalendarTestFmwk { { 4334, 3,0, 30, MONTH, 3, 4334, 5,0, 30 }, // no dom pin { 4334, 3,0, 30, MONTH, 4, 4334, 6,0, 29 }, // dom should pin }; - + Calendar cal = Calendar.getInstance(new ULocale("ko_KR@calendar=dangi")); doRollAddDangi(ADD, cal, tests); } @@ -341,11 +344,11 @@ public class DangiTest extends CalendarTestFmwk { { 4334, 3,0, 30, MONTH, 16, 4334, 5,0, 30 }, // no dom pin { 4334, 3,0, 30, MONTH, -9, 4334, 6,0, 29 }, // dom should pin }; - + Calendar cal = Calendar.getInstance(new ULocale("ko_KR@calendar=dangi")); doRollAddDangi(ROLL, cal, tests); } - + void doRollAddDangi(boolean roll, Calendar cal, int[][] tests) { String name = roll ? "rolling" : "adding"; @@ -410,7 +413,7 @@ public class DangiTest extends CalendarTestFmwk { // If the chinese calendar current millis isn't called, the default year is wrong. // this test is assuming the 'year' is the current cycle // so when we cross a cycle boundary, the target will need to change - // that shouldn't be for awhile yet... + // that shouldn't be for awhile yet... Calendar cc = Calendar.getInstance(new ULocale("ko_KR@calendar=dangi")); cc.set(Calendar.EXTENDED_YEAR, 4338); @@ -425,7 +428,7 @@ public class DangiTest extends CalendarTestFmwk { cc.set(Calendar.MILLISECOND, 0); cc.add(Calendar.DATE, 1); - + Calendar cal = new GregorianCalendar(2005, Calendar.FEBRUARY, 28); Date target = cal.getTime(); Date result = cc.getTime(); diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/EthiopicTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/EthiopicTest.java index ecdb9e36f5f..2544a496280 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/EthiopicTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/EthiopicTest.java @@ -12,6 +12,8 @@ import java.util.Date; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.impl.LocaleUtility; import com.ibm.icu.text.DateFormat; @@ -25,7 +27,8 @@ import com.ibm.icu.util.ULocale; /** * Tests for the EthiopicCalendar class. */ -public class EthiopicTest extends CalendarTestFmwk +@RunWith(JUnit4.class) +public class EthiopicTest extends CalendarTestFmwk { /** Constants to save typing. */ public static final int MESKEREM = EthiopicCalendar.MESKEREM; @@ -42,13 +45,13 @@ public class EthiopicTest extends CalendarTestFmwk public static final int NEHASSE = EthiopicCalendar.NEHASSE; public static final int PAGUMEN = EthiopicCalendar.PAGUMEN; - /* DY[20050507] I don't know what this is for yet: + /* DY[20050507] I don't know what this is for yet: @Test public void TestRoll() { int[][] tests = new int[][] { // input roll by output // year month day field amount year month day - + { 0001, QIDAH, 2, MONTH, 1, 0001, HIJJAH, 2 }, // non-leap years { 0001, QIDAH, 2, MONTH, 2, 0001, MUHARRAM, 2 }, { 0001, QIDAH, 2, MONTH, -1, 0001, SHAWWAL, 2 }, @@ -62,7 +65,7 @@ public class EthiopicTest extends CalendarTestFmwk { 0001, MUHARRAM, 30, MONTH, 1, 0001, SAFAR, 29 }, { 0002, HIJJAH, 30, YEAR, -1, 0001, HIJJAH, 29 }, }; - + EthiopicCalendar cal = newCivil(); doRollAdd(ROLL, cal, tests); @@ -71,9 +74,9 @@ public class EthiopicTest extends CalendarTestFmwk /* Test dates from: * "The Amharic Letters of Emperor Theodore of Ethiopia to Queen Victoria and - * Her Special Envoy", David Appleyard, Girma Selasse Asfaw, Oxford University Press, + * Her Special Envoy", David Appleyard, Girma Selasse Asfaw, Oxford University Press, * June 1 1979, ISBN: 0856726605, Longwood Pr Ltd - * + * * Ethiopic Gregorian JD * 20/02/1855 29/10/1862 2401443 * 29/10/1857 05/07/1865 2402423 @@ -81,16 +84,16 @@ public class EthiopicTest extends CalendarTestFmwk * 10/08/1858 17/04/1866 2402709 * 28/04/1859 05/01/1867 2402972 * 05/05/1860 13/01/1868 2403345 - * + * * -------------------------------------------------- - * + * * From the Calendrica applet: http://emr.cs.iit.edu/home/reingold/calendar-book/Calendrica.html - * + * * Ethiopic Gregorian JD * 07/05/-8 01/01/0000 1721060 * 08/05/-7 01/01/0001 1721426 * 06/13/-1 27/08/0007 1723855 - * + * * 01/01/0000 28/08/0007 1723856 * 01/01/0001 27/08/0008 1724221 * 01/01/0002 27/08/0009 1724586 @@ -102,17 +105,17 @@ public class EthiopicTest extends CalendarTestFmwk * 05/13/0003 26/08/0011 1725315 * 06/13/0003 27/08/0011 1725316 first ethiopian leap year * 05/13/0004 26/08/0012 1725561 - * + * * 06/02/1575 13/10/1582 2299159 * 07/02/1575 14/10/1582 2299160 Julian 04/10/1582 * 08/02/1575 15/10/1582 2299161 * 09/02/1575 16/10/1582 2299162 - * + * * 23/04/1892 01/01/1900 2415021 * 23/04/1997 01/01/2005 2453372 * 05/13/2000 10/09/2008 2454720 */ - + /** A huge list of test cases to make sure that computeTime and computeFields * work properly for a wide range of data in the civil calendar. */ @@ -134,7 +137,7 @@ public class EthiopicTest extends CalendarTestFmwk new TestCase(2402708.5, 1, 1858, 8, 10, TUE, 0, 0, 0), // Gregorian: 17/04/1866 new TestCase(2402971.5, 1, 1859, 4, 28, SAT, 0, 0, 0), // Gregorian: 05/01/1867 new TestCase(2403344.5, 1, 1860, 5, 5, MON, 0, 0, 0), // Gregorian: 13/01/1868 - + // Miscellaneous: /* Skip these tests until JD bug fixed in the Gregorian calendar: * http://www.jtcsv.com/cgibin/icu-bugs/incoming?id=4406;page=2;user=guest @@ -157,7 +160,7 @@ public class EthiopicTest extends CalendarTestFmwk new TestCase(1725315.5, 1, 3, 13, 6, SAT, 0, 0, 0), // Gregorian: 27/08/0011 - first ethiopic leap year // new TestCase(1725560.5, 1, 4, 13, 5, SUN, 0, 0, 0), // Gregorian: 26/08/0012 - dlf new TestCase(1725680.5, 1, 4, 13, 5, SUN, 0, 0, 0), // Gregorian: 26/08/0012 - new TestCase(2299158.5, 1, 1575, 2, 6, WED, 0, 0, 0), // Gregorian: 13/10/1582 + new TestCase(2299158.5, 1, 1575, 2, 6, WED, 0, 0, 0), // Gregorian: 13/10/1582 new TestCase(2299159.5, 1, 1575, 2, 7, THU, 0, 0, 0), // Gregorian: 14/10/1582 Julian 04/10/1582 new TestCase(2299160.5, 1, 1575, 2, 8, FRI, 0, 0, 0), // Gregorian: 15/10/1582 @@ -183,7 +186,7 @@ public class EthiopicTest extends CalendarTestFmwk new TestCase(2402708.5, 0, 7358, 8, 10, TUE, 0, 0, 0), // Gregorian: 17/04/1866 new TestCase(2402971.5, 0, 7359, 4, 28, SAT, 0, 0, 0), // Gregorian: 05/01/1867 new TestCase(2403344.5, 0, 7360, 5, 5, MON, 0, 0, 0), // Gregorian: 13/01/1868 - + // Miscellaneous: /* Skip these tests until JD bug fixed in the Gregorian calendar: * http://www.jtcsv.com/cgibin/icu-bugs/incoming?id=4406;page=2;user=guest @@ -206,7 +209,7 @@ public class EthiopicTest extends CalendarTestFmwk new TestCase(1725315.5, 0, 5503, 13, 6, SAT, 0, 0, 0), // Gregorian: 27/08/0011 - first ethiopic leap year // new TestCase(1725560.5, 0, 5504, 13, 5, SUN, 0, 0, 0), // Gregorian: 26/08/0012 - dlf new TestCase(1725680.5, 0, 5504, 13, 5, SUN, 0, 0, 0), // Gregorian: 26/08/0012 - new TestCase(2299158.5, 0, 7075, 2, 6, WED, 0, 0, 0), // Gregorian: 13/10/1582 + new TestCase(2299158.5, 0, 7075, 2, 6, WED, 0, 0, 0), // Gregorian: 13/10/1582 new TestCase(2299159.5, 0, 7075, 2, 7, THU, 0, 0, 0), // Gregorian: 14/10/1582 Julian 04/10/1582 new TestCase(2299160.5, 0, 7075, 2, 8, FRI, 0, 0, 0), // Gregorian: 15/10/1582 @@ -244,11 +247,11 @@ public class EthiopicTest extends CalendarTestFmwk assertEquals("Ethiopic Date", "Tue Jan 01, 5500 BC", fmt.format(cal)); // The gregorian calendar gets off by two days when - // the date gets low, unless the gregorian changeover is set to + // the date gets low, unless the gregorian changeover is set to // very early. The funny thing is, it's ok for dates in the year // 283, but not in the year 7, and it claims to be ok until the year 4. // should track down when the dates start to differ... - + GregorianCalendar gc = new GregorianCalendar(); gc.setGregorianChange(new Date(Long.MIN_VALUE)); // act like proleptic Gregorian gc.setTime(cal.getTime()); @@ -263,16 +266,16 @@ public class EthiopicTest extends CalendarTestFmwk cal.set(1000, 0, 30); logln("1000/0/30-> " + cal.get(YEAR) + "/" + - cal.get(MONTH) + "/" + + cal.get(MONTH) + "/" + cal.get(DATE)); cal.clear(); cal.set(1, 0, 30); logln("1/0/30 -> " + cal.get(YEAR) + "/" + - cal.get(MONTH) + "/" + + cal.get(MONTH) + "/" + cal.get(DATE)); } - + @Test public void TestJD(){ int jd = EthiopicCalendar.EthiopicToJD(1567,8,9); @@ -300,13 +303,13 @@ public class EthiopicTest extends CalendarTestFmwk doTheoreticalLimitsTest(ethiopic, true); } - + @Test public void TestCoverage() { { // new EthiopicCalendar(TimeZone) - EthiopicCalendar cal = new EthiopicCalendar(TimeZone.getDefault()); + EthiopicCalendar cal = new EthiopicCalendar(TimeZone.getDefault()); if(cal == null){ errln("could not create EthiopicCalendar with TimeZone"); } @@ -319,7 +322,7 @@ public class EthiopicTest extends CalendarTestFmwk errln("could not create EthiopicCalendar with ULocale"); } } - + { // new EthiopicCalendar(Locale) EthiopicCalendar cal = new EthiopicCalendar(Locale.getDefault()); @@ -343,7 +346,7 @@ public class EthiopicTest extends CalendarTestFmwk errln("could not create EthiopicCalendar with TimeZone,ULocale"); } } - + { // new EthiopicCalendar(Date) EthiopicCalendar cal = new EthiopicCalendar(new Date()); @@ -393,7 +396,7 @@ public class EthiopicTest extends CalendarTestFmwk logln(cal.getTime().toString()); } - + { // data EthiopicCalendar cal = new EthiopicCalendar(1997, EthiopicCalendar.MESKEREM, 1); @@ -420,7 +423,7 @@ public class EthiopicTest extends CalendarTestFmwk } } } - + private static EthiopicCalendar newAmeteAlemEraCalendar() { EthiopicCalendar alemawiCalendar = new EthiopicCalendar(); alemawiCalendar.setAmeteAlemEra(true); @@ -477,7 +480,7 @@ public class EthiopicTest extends CalendarTestFmwk int endMonth = testCalendar.get(Calendar.MONTH); int endDay = testCalendar.get(Calendar.DATE); if ( endYear != item.getEndYear() || endMonth != item.getEndMonth() || endDay != item.getEndDay() ) { - errln("EToJD FAILS: field " + item.getField() + " delta " + item.getDelta() + + errln("EToJD FAILS: field " + item.getField() + " delta " + item.getDelta() + " expected yr " + item.getEndYear() + " mo " + item.getEndMonth() + " da " + item.getEndDay() + " got yr " + endYear + " mo " + endMonth + " da " + endDay); } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/HebrewTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/HebrewTest.java index 2febd3aa98c..6507fa27ca3 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/HebrewTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/HebrewTest.java @@ -13,6 +13,8 @@ import java.util.Locale; import java.util.MissingResourceException; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.impl.LocaleUtility; import com.ibm.icu.text.DateFormat; @@ -24,6 +26,7 @@ import com.ibm.icu.util.ULocale; /** * Tests for the HebrewCalendar class. */ +@RunWith(JUnit4.class) public class HebrewTest extends CalendarTestFmwk { // Constants to save typing. public static final int TISHRI = HebrewCalendar.TISHRI; @@ -50,7 +53,7 @@ public class HebrewTest extends CalendarTestFmwk { int[][] tests = new int[][] { // input roll by output // year month day field amount year month day - + { 5759, HESHVAN, 2, MONTH, 1, 5759, KISLEV, 2 }, // non-leap years { 5759, SHEVAT, 2, MONTH, 1, 5759, ADAR, 2 }, { 5759, SHEVAT, 2, MONTH, 2, 5759, NISAN, 2 }, @@ -64,13 +67,13 @@ public class HebrewTest extends CalendarTestFmwk { { 5757, SHEVAT, 2, MONTH, 12, 5757, TEVET, 2 }, { 5757, SHEVAT, 2, MONTH, 13, 5757, SHEVAT, 2 }, { 5757, AV, 1, MONTH, 12, 5757, TAMUZ, 1 }, // Alan - + { 5757, KISLEV, 1, DATE, 30, 5757, KISLEV, 2 }, // 29-day month { 5758, KISLEV, 1, DATE, 31, 5758, KISLEV, 2 }, // 30-day month - + // Try some other fields too { 5757, TISHRI, 1, YEAR, 1, 5758, TISHRI, 1 }, - + // Try some rolls that require other fields to be adjusted { 5757, TISHRI, 30, MONTH, 1, 5757, HESHVAN, 29 }, @@ -78,13 +81,13 @@ public class HebrewTest extends CalendarTestFmwk { }; // try{ HebrewCalendar cal = new HebrewCalendar(UTC, Locale.getDefault()); - + doRollAdd(ROLL, cal, tests); // }catch(MissingResourceException ex){ // warnln("Got Exception: "+ ex.getMessage()); // } } - + /** * Test the behavior of HebrewCalendar.roll * The only real nastiness with roll is the MONTH field, since a year can @@ -106,18 +109,18 @@ public class HebrewTest extends CalendarTestFmwk { { 5757, SHEVAT, 2, MONTH, 3, 5757, NISAN, 2 }, { 5757, SHEVAT, 2, MONTH, 12, 5758, TEVET, 2 }, { 5757, SHEVAT, 2, MONTH, 13, 5758, SHEVAT, 2 }, - + { 5762, AV, 1, MONTH, 1, 5762, ELUL, 1 }, // JB#2327 { 5762, AV, 30, DATE, 1, 5762, ELUL, 1 }, // JB#2327 { 5762, ELUL, 1, DATE, -1, 5762, AV, 30 }, // JB#2327 { 5762, ELUL, 1, MONTH, -1, 5762, AV, 1 }, // JB#2327 - + { 5757, KISLEV, 1, DATE, 30, 5757, TEVET, 2 }, // 29-day month { 5758, KISLEV, 1, DATE, 31, 5758, TEVET, 2 }, // 30-day month }; try{ HebrewCalendar cal = new HebrewCalendar(UTC, Locale.getDefault()); - + doRollAdd(ADD, cal, tests); }catch( MissingResourceException ex){ warnln("Could not load the locale data"); @@ -208,8 +211,8 @@ public class HebrewTest extends CalendarTestFmwk { new TestCase(2459464.5, 0, 5782, 1, 1, TUE, 0, 0, 0), new TestCase(2467142.5, 0, 5803, 1, 1, MON, 0, 0, 0), new TestCase(2455448.5, 0, 5771, 1, 1, THU, 0, 0, 0), - - // Test cases for JB#2327 + + // Test cases for JB#2327 // http://www.fourmilab.com/documents/calendar/ // http://www.calendarhome.com/converter/ // 2452465.5, 2002, JULY, 10, 5762, AV, 1, @@ -225,7 +228,7 @@ public class HebrewTest extends CalendarTestFmwk { new TestCase(2452524.5, 0, 5763,TISHRI+1, 1, SAT, 0, 0, 0), }; doTestCases(testCases, new HebrewCalendar()); - + }catch(MissingResourceException ex){ warnln("Got Exception: "+ ex.getMessage()); } @@ -265,14 +268,14 @@ public class HebrewTest extends CalendarTestFmwk { // I hope that year = 0 does not exists // because the test fails for it ! cal.clear(); - + cal.set(Calendar.YEAR, year); cal.set(Calendar.MONTH, ELUL); cal.set(Calendar.DAY_OF_MONTH, 1); - + int yact = cal.get(Calendar.YEAR); int mact = cal.get(Calendar.MONTH); - + if (year != yact || ELUL != mact) { errln("Fail: " + ELUL + "/" + year + " -> " + @@ -281,9 +284,9 @@ public class HebrewTest extends CalendarTestFmwk { } }catch(MissingResourceException ex){ warnln("Got Exception: "+ ex.getMessage()); - } + } } - + /** * Test of the behavior of the month field. This requires special * handling in the Hebrew calendar because of the pattern of leap @@ -298,7 +301,7 @@ public class HebrewTest extends CalendarTestFmwk { // We can't test complete() on some lines below because of ADAR_1 -- if // the calendar is set to ADAR_1 on a non-leap year, the result is undefined. int[] DATA = { - // m1/y1 - month/year before (month is 1-based) + // m1/y1 - month/year before (month is 1-based) // delta - amount to add to month field // m2/y2 - month/year after add(MONTH, delta) // m3/y3 - month/year after set(MONTH, m1+delta) @@ -319,7 +322,7 @@ public class HebrewTest extends CalendarTestFmwk { int m2 = DATA[i++], y2 = DATA[i++]; int m3 = DATA[i++], y3 = DATA[i++]; int mact, yact; - + cal.clear(); cal.set(Calendar.YEAR, y); cal.set(Calendar.MONTH, m-1); @@ -341,7 +344,7 @@ public class HebrewTest extends CalendarTestFmwk { (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.YEAR)); } } - + cal.clear(); cal.set(Calendar.YEAR, y); cal.set(Calendar.MONTH, m + monthDelta - 1); @@ -415,7 +418,7 @@ public class HebrewTest extends CalendarTestFmwk { errln("could not create HebrewCalendar with TimeZone"); } } - + { // new HebrewCalendar(ULocale) HebrewCalendar cal = new HebrewCalendar(ULocale.getDefault()); @@ -423,7 +426,7 @@ public class HebrewTest extends CalendarTestFmwk { errln("could not create HebrewCalendar with ULocale"); } } - + { // new HebrewCalendar(Locale) HebrewCalendar cal = new HebrewCalendar(Locale.getDefault()); @@ -431,7 +434,7 @@ public class HebrewTest extends CalendarTestFmwk { errln("could not create HebrewCalendar with locale"); } } - + { // new HebrewCalendar(Date) HebrewCalendar cal = new HebrewCalendar(new Date()); @@ -439,16 +442,16 @@ public class HebrewTest extends CalendarTestFmwk { errln("could not create HebrewCalendar with date"); } } - + { // data HebrewCalendar cal = new HebrewCalendar(2800, HebrewCalendar.SHEVAT, 1); Date time = cal.getTime(); - + String[] calendarLocales = { "iw_IL" }; - + String[] formatLocales = { "en", "fi", "fr", "hu", "iw", "nl" }; @@ -456,7 +459,7 @@ public class HebrewTest extends CalendarTestFmwk { String calLocName = calendarLocales[i]; Locale calLocale = LocaleUtility.getLocaleFromName(calLocName); cal = new HebrewCalendar(calLocale); - + for (int j = 0; j < formatLocales.length; ++j) { String locName = formatLocales[j]; Locale formatLocale = LocaleUtility.getLocaleFromName(locName); @@ -476,7 +479,7 @@ public class HebrewTest extends CalendarTestFmwk { HebrewCalendar hc = new HebrewCalendar (5742, HebrewCalendar.AV, 22); DateFormat df = hc.getDateTimeFormat(DateFormat.FULL, DateFormat.FULL, Locale.getDefault()); String dateString = df.format(hc.getTime()); - + for (int year = 5600; year < 5800; year ++) { boolean leapYear = HebrewCalendar.isLeapYear (year); for (int month = HebrewCalendar.TISHRI; month <= HebrewCalendar.ELUL;month++) { @@ -506,7 +509,7 @@ public class HebrewTest extends CalendarTestFmwk { break; } } - } + } } // Test case for Ticket#10313. HebrewCalendar requires diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/HolidayTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/HolidayTest.java index f8db0fe3292..ac1425eaead 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/HolidayTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/HolidayTest.java @@ -13,6 +13,8 @@ import java.util.Locale; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.LocaleUtility; @@ -29,6 +31,7 @@ import com.ibm.icu.util.ULocale; /** * Tests for the Holiday class. */ +@RunWith(JUnit4.class) public class HolidayTest extends TestFmwk { @Before public void init() throws Exception { @@ -38,7 +41,7 @@ public class HolidayTest extends TestFmwk { now = new Date(); } } - + private Calendar cal; private Date longTimeAgo; private Date now; @@ -135,8 +138,8 @@ public class HolidayTest extends TestFmwk { // logln("rule: " + h.getRule().toString()); // h.setRule(h.getRule()); - - + + logln("HolidayCalendarDemo test"); { final Calendar c = Calendar.getInstance(TimeZone.GMT_ZONE); // Temporary copy @@ -253,7 +256,7 @@ public class HolidayTest extends TestFmwk { logln("first between " + abd + " and " + xbd + " is " + rdr.firstBetween(abd, xbd)); logln("first between " + abd + " and " + null + " is " + rdr.firstBetween(abd, null)); logln("first between " + xbd + " and " + null + " is " + rdr.firstBetween(xbd, null)); - + //getRule, setRule logln("The rule in the holiday: " + h[1].getRule()); exerciseHoliday(h[1], Locale.getDefault()); @@ -264,16 +267,16 @@ public class HolidayTest extends TestFmwk { } exerciseHoliday(h[1], Locale.getDefault()); } - + @Test - public void TestEaster(){ + public void TestEaster(){ // Verify that Easter is working. Should be April 20, 2014 final Holiday h = new EasterHoliday("Easter Sunday"); final Date beginApril = getDate(2014, Calendar.APRIL, 1); final Date endApril = getDate(2014, Calendar.APRIL, 30); final Date expect = getDate(2014, Calendar.APRIL, 20); final Date actual = h.firstBetween(beginApril, endApril); - + if(actual == null) { errln("Error: Easter 2014 should be on " + expect + " but got null."); } else { @@ -289,13 +292,13 @@ public class HolidayTest extends TestFmwk { public void TestIsOn() { // jb 1901 SimpleHoliday sh = new SimpleHoliday(Calendar.AUGUST, 15, "Doug's Day", 1958, 2058); - + Calendar gcal = new GregorianCalendar(); gcal.clear(); gcal.set(Calendar.YEAR, 2000); gcal.set(Calendar.MONTH, Calendar.AUGUST); gcal.set(Calendar.DAY_OF_MONTH, 15); - + Date d0 = gcal.getTime(); gcal.add(Calendar.SECOND, 1); Date d1 = gcal.getTime(); @@ -329,7 +332,7 @@ public class HolidayTest extends TestFmwk { logln("firstAfter: " + h); } } - + @Test public void TestDisplayName() { Holiday[] holidays = Holiday.getHolidays(ULocale.US); diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/IBMCalendarTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/IBMCalendarTest.java index c2a839c22bc..5b13c49473d 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/IBMCalendarTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/IBMCalendarTest.java @@ -15,6 +15,8 @@ import java.util.Locale; import java.util.Set; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.impl.CalendarAstronomer; import com.ibm.icu.impl.LocaleUtility; @@ -35,6 +37,7 @@ import com.ibm.icu.util.ULocale; /** * @summary Tests of new functionality in IBMCalendar */ +@RunWith(JUnit4.class) public class IBMCalendarTest extends CalendarTestFmwk { /** * Test weekend support in IBMCalendar. diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/IndianTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/IndianTest.java index 707a5c4f84f..8854f8b0d58 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/IndianTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/IndianTest.java @@ -12,6 +12,8 @@ import java.util.Date; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.impl.LocaleUtility; import com.ibm.icu.text.DateFormat; @@ -25,10 +27,11 @@ import com.ibm.icu.util.ULocale; /** * Tests for the IndianCalendar class. */ -public class IndianTest extends CalendarTestFmwk +@RunWith(JUnit4.class) +public class IndianTest extends CalendarTestFmwk { // Months in indian calendar are 0-based. Here taking 1-based names: - public static final int CHAITRA = IndianCalendar.CHAITRA + 1; + public static final int CHAITRA = IndianCalendar.CHAITRA + 1; public static final int VAISAKHA = IndianCalendar.VAISAKHA + 1; public static final int JYAISTHA = IndianCalendar.JYAISTHA + 1; public static final int ASADHA = IndianCalendar.ASADHA + 1; @@ -43,8 +46,8 @@ public class IndianTest extends CalendarTestFmwk /** Constants to save typing. */ /* Test dates generated from: - * http://www.fourmilab.ch/documents/calendar/ - + * http://www.fourmilab.ch/documents/calendar/ + /** A huge list of test cases to make sure that computeTime and computeFields * work properly for a wide range of data in the Indian civil calendar. */ @@ -100,7 +103,7 @@ public class IndianTest extends CalendarTestFmwk new TestCase(2465737.5, 0, 1960, KARTIKA, 19, WED, 0, 0, 0), new TestCase(2486076.5, 0, 2016, ASADHA, 27, SUN, 0, 0, 0), }; - + IndianCalendar testCalendar = new IndianCalendar(); testCalendar.setLenient(true); doTestCases(tests, testCalendar); @@ -113,13 +116,13 @@ public class IndianTest extends CalendarTestFmwk cal.set(1000, 0, 30); logln("1000/0/30-> " + cal.get(YEAR) + "/" + - cal.get(MONTH) + "/" + + cal.get(MONTH) + "/" + cal.get(DATE)); cal.clear(); cal.set(1, 0, 30); logln("1/0/30 -> " + cal.get(YEAR) + "/" + - cal.get(MONTH) + "/" + + cal.get(MONTH) + "/" + cal.get(DATE)); } @@ -127,7 +130,7 @@ public class IndianTest extends CalendarTestFmwk public void TestCoverage() { { // new IndianCalendar(TimeZone) - IndianCalendar cal = new IndianCalendar(TimeZone.getDefault()); + IndianCalendar cal = new IndianCalendar(TimeZone.getDefault()); if(cal == null){ errln("could not create IndianCalendar with TimeZone"); } @@ -140,7 +143,7 @@ public class IndianTest extends CalendarTestFmwk errln("could not create IndianCalendar with ULocale"); } } - + { // new IndianCalendar(Locale) IndianCalendar cal = new IndianCalendar(Locale.getDefault()); @@ -148,23 +151,23 @@ public class IndianTest extends CalendarTestFmwk errln("could not create IndianCalendar with Locale"); } } - - { - // new IndianCalendar(TimeZone, Locale) - IndianCalendar cal = new IndianCalendar(TimeZone.getDefault(),Locale.getDefault()); - if(cal == null){ - errln("could not create IndianCalendar with TimeZone, Locale"); - } - } - - { - // new IndianCalendar(TimeZone, ULocale) + + { + // new IndianCalendar(TimeZone, Locale) + IndianCalendar cal = new IndianCalendar(TimeZone.getDefault(),Locale.getDefault()); + if(cal == null){ + errln("could not create IndianCalendar with TimeZone, Locale"); + } + } + + { + // new IndianCalendar(TimeZone, ULocale) IndianCalendar cal = new IndianCalendar(TimeZone.getDefault(),ULocale.getDefault()); - if(cal == null){ - errln("could not create IndianCalendar with TimeZone, ULocale"); - } - } - + if(cal == null){ + errln("could not create IndianCalendar with TimeZone, ULocale"); + } + } + { // new IndianCalendar(Date) IndianCalendar cal = new IndianCalendar(new Date()); @@ -186,7 +189,7 @@ public class IndianTest extends CalendarTestFmwk errln("could not create IndianCalendar with year,month,date,hour,minute,second"); } } - + { // data String[] calendarLocales = { @@ -246,7 +249,7 @@ public class IndianTest extends CalendarTestFmwk doLimitsTest(indian, null, cal.getTime()); doTheoreticalLimitsTest(indian, true); } - + /** * Problem reported by Bruno Haible * -- see ticket 8419 -- http://bugs.icu-project.org/trac/ticket/8419 @@ -282,14 +285,14 @@ public class IndianTest extends CalendarTestFmwk @Test public void TestCoverage12424() { - class StubCalendar extends IndianCalendar { + class StubCalendar extends IndianCalendar { private static final long serialVersionUID = 1L; public StubCalendar() { assertEquals("Indian month 0 length", 30, handleGetMonthLength(1000, 0)); assertEquals("Indian month 2 length", 31, handleGetMonthLength(1000, 2)); } } - + new StubCalendar(); } } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/IslamicTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/IslamicTest.java index 504c6fee692..ef0ddaf6495 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/IslamicTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/IslamicTest.java @@ -17,6 +17,8 @@ import java.util.Date; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.LocaleUtility; @@ -32,6 +34,7 @@ import com.ibm.icu.util.ULocale; /** * Tests for the IslamicCalendar class. */ +@RunWith(JUnit4.class) public class IslamicTest extends CalendarTestFmwk { /** Constants to save typing. */ public static final int MUHARRAM = IslamicCalendar.MUHARRAM; @@ -52,7 +55,7 @@ public class IslamicTest extends CalendarTestFmwk { int[][] tests = new int[][] { // input roll by output // year month day field amount year month day - + { 0001, QIDAH, 2, MONTH, 1, 0001, HIJJAH, 2 }, // non-leap years { 0001, QIDAH, 2, MONTH, 2, 0001, MUHARRAM, 2 }, { 0001, QIDAH, 2, MONTH, -1, 0001, SHAWWAL, 2 }, @@ -66,10 +69,10 @@ public class IslamicTest extends CalendarTestFmwk { { 0001, MUHARRAM, 30, MONTH, 1, 0001, SAFAR, 29 }, { 0002, HIJJAH, 30, YEAR, -1, 0001, HIJJAH, 29 }, }; - + IslamicCalendar cal = newCivil(); doRollAdd(ROLL, cal, tests); - + cal = newIslamicUmalqura(); doRollAdd(ROLL, cal, tests); } @@ -125,7 +128,7 @@ public class IslamicTest extends CalendarTestFmwk { new TestCase(2465737.5, 0, 1460, 10, 12, WED, 0, 0, 0), new TestCase(2486076.5, 0, 1518, 3, 5, SUN, 0, 0, 0), }; - + IslamicCalendar civilCalendar = newCivil(); civilCalendar.setLenient(true); doTestCases(tests, civilCalendar); @@ -138,13 +141,13 @@ public class IslamicTest extends CalendarTestFmwk { cal.set(1000, 0, 30); logln("1000/0/30 -> " + cal.get(YEAR) + "/" + - cal.get(MONTH) + "/" + + cal.get(MONTH) + "/" + cal.get(DATE)); cal.clear(); cal.set(1, 0, 30); logln("1/0/30 -> " + cal.get(YEAR) + "/" + - cal.get(MONTH) + "/" + + cal.get(MONTH) + "/" + cal.get(DATE)); } @@ -160,7 +163,7 @@ public class IslamicTest extends CalendarTestFmwk { doTheoreticalLimitsTest(islamic, true); - // number of days to test - Islamic calendar starts to exhibit + // number of days to test - Islamic calendar starts to exhibit // rounding errors after year AH3954 - about 2500 years out. IslamicCalendar islamic2 = new IslamicCalendar(); @@ -180,11 +183,11 @@ public class IslamicTest extends CalendarTestFmwk { cal.add(IslamicCalendar.MONTH,1); if ( cal.get(IslamicCalendar.MONTH) != IslamicCalendar.MUHARRAM || ( cal.get(IslamicCalendar.YEAR) != 1432 )) { - errln("Error incrementing month at the end of a leap year. Expected Month:0 Year:1432 - Got Month:" + + errln("Error incrementing month at the end of a leap year. Expected Month:0 Year:1432 - Got Month:" + cal.get(IslamicCalendar.MONTH) + " Year:" + cal.get(IslamicCalendar.YEAR)); } } - + @Test public void TestCoverage() { { @@ -202,7 +205,7 @@ public class IslamicTest extends CalendarTestFmwk { errln("could not create IslamicCalendar with ULocale"); } } - + { // new IslamicCalendar(Locale) IslamicCalendar cal = new IslamicCalendar(Locale.getDefault()); @@ -251,7 +254,7 @@ public class IslamicTest extends CalendarTestFmwk { if (cal.isCivil()) { errln("islamic calendar is civil"); } - + // ensure calculation type getter returns correct object and value cal.setCalculationType(CalculationType.ISLAMIC_UMALQURA); Object ctObj = cal.getCalculationType(); @@ -263,7 +266,7 @@ public class IslamicTest extends CalendarTestFmwk { } else { errln("wrong object type returned from getCalculationType"); } - + Date now = new Date(); cal.setTime(now); @@ -281,14 +284,14 @@ public class IslamicTest extends CalendarTestFmwk { logln(cal.getTime().toString()); } - + { // data IslamicCalendar cal = new IslamicCalendar(800, IslamicCalendar.RAMADAN, 1); Date time = cal.getTime(); String[] calendarLocales = { - "ar_AE", "ar_BH", "ar_DZ", "ar_EG", "ar_JO", "ar_KW", "ar_OM", + "ar_AE", "ar_BH", "ar_DZ", "ar_EG", "ar_JO", "ar_KW", "ar_OM", "ar_QA", "ar_SA", "ar_SY", "ar_YE", "ms_MY" }; @@ -320,7 +323,7 @@ public class IslamicTest extends CalendarTestFmwk { civilCalendar.setCalculationType(CalculationType.ISLAMIC); return civilCalendar; } - + private static IslamicCalendar newIslamicUmalqura() { IslamicCalendar civilCalendar = new IslamicCalendar(); civilCalendar.setCalculationType(CalculationType.ISLAMIC_UMALQURA); @@ -339,8 +342,8 @@ public class IslamicTest extends CalendarTestFmwk { verifyType(newIslamic(),"islamic"); verifyType(newCivil(),"islamic-civil"); verifyType(newIslamicUmalqura(), "islamic-umalqura"); - } - + } + private void setAndTestCalendar(IslamicCalendar cal, int initMonth, int initDay, int initYear) { cal.clear(); cal.setLenient(false); @@ -357,18 +360,18 @@ public class IslamicTest extends CalendarTestFmwk { private void setAndTestWholeYear(IslamicCalendar cal, int startYear) { for(int startMonth = 0; startMonth < 12; startMonth++) { - for(int startDay = 1; startDay < 31; startDay++ ) { + for(int startDay = 1; startDay < 31; startDay++ ) { try { setAndTestCalendar(cal, startMonth, startDay, startYear); } catch(IllegalArgumentException iae) { if(startDay != 30) { errln("unexpected exception that wasn't for trying to set a date to '30'. errmsg - " + iae.getLocalizedMessage()); - } - } + } + } } } } - + @Test public void TestIslamicUmAlQura() { @@ -804,15 +807,15 @@ public class IslamicTest extends CalendarTestFmwk { /*/ int lastYear = 1480; // the whole shootin' match //*/ - - ULocale umalquraLoc = new ULocale("ar_SA@calendar=islamic-umalqura"); - ULocale gregoLoc = new ULocale("ar_SA@calendar=gregorian"); + + ULocale umalquraLoc = new ULocale("ar_SA@calendar=islamic-umalqura"); + ULocale gregoLoc = new ULocale("ar_SA@calendar=gregorian"); TimeZone tzSA = TimeZone.getTimeZone("Asia/Riyadh"); IslamicCalendar tstCal = new IslamicCalendar(tzSA, umalquraLoc); GregorianCalendar gregCal = new GregorianCalendar(tzSA, gregoLoc); tstCal.clear(); tstCal.setLenient(false); - + int day=0, month=0, year=0, initDay = 27, initMonth = IslamicCalendar.RAJAB, initYear = 1434; try { @@ -840,7 +843,7 @@ public class IslamicTest extends CalendarTestFmwk { } catch(IllegalArgumentException iae) { errln("unexpected exception received!!!"); } - + try { tstCal.clear(); initMonth = 2; @@ -850,7 +853,7 @@ public class IslamicTest extends CalendarTestFmwk { } catch(IllegalArgumentException iae) { // expected this } - + try { tstCal.clear(); initMonth = 3; @@ -859,9 +862,9 @@ public class IslamicTest extends CalendarTestFmwk { } catch(IllegalArgumentException iae) { errln("unexpected exception received!!!"); } - + try { - SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); Date date = formatter.parse("1975-05-06"); IslamicCalendar is_cal = new IslamicCalendar(); is_cal.setCalculationType(CalculationType.ISLAMIC_UMALQURA); @@ -880,11 +883,11 @@ public class IslamicTest extends CalendarTestFmwk { String expectedFormatResult = "\u0661\u0663\u0669\u0665-\u0631\u0628\u064A\u0639 \u0627\u0644\u0622\u062E\u0631-\u0662\u0664"; if(!str.equals(expectedFormatResult)) errln("unexpected formatted result: "+str); - + }catch(Exception e){ errln(e.getLocalizedMessage()); } - + // check against data gregCal.clear(); tstCal.clear(); @@ -902,18 +905,18 @@ public class IslamicTest extends CalendarTestFmwk { } } } - + @Test public void TestSerialization8449() { try { ByteArrayOutputStream icuStream = new ByteArrayOutputStream(); - + IslamicCalendar tstCalendar = new IslamicCalendar(); tstCalendar.setCivil(false); - + long expectMillis = 1187912520931L; // with seconds (not ms) cleared. tstCalendar.setTimeInMillis(expectMillis); - + logln("instantiated: "+tstCalendar); logln("getMillis: "+tstCalendar.getTimeInMillis()); tstCalendar.set(IslamicCalendar.SECOND, 0); @@ -930,11 +933,11 @@ public class IslamicTest extends CalendarTestFmwk { icuOut.writeObject(tstCalendar); icuOut.flush(); icuOut.close(); - + ObjectInputStream icuIn = new ObjectInputStream(new ByteArrayInputStream(icuStream.toByteArray())); tstCalendar = null; tstCalendar = (IslamicCalendar)icuIn.readObject(); - + logln("serialized back in: "+tstCalendar); { long gotMillis = tstCalendar.getTimeInMillis(); @@ -944,9 +947,9 @@ public class IslamicTest extends CalendarTestFmwk { logln("getMillis: "+gotMillis); } } - + tstCalendar.set(IslamicCalendar.SECOND, 0); - + logln("setSecond=0: "+tstCalendar); { long gotMillis = tstCalendar.getTimeInMillis(); @@ -964,7 +967,7 @@ public class IslamicTest extends CalendarTestFmwk { cnf.printStackTrace(); } } - + @Test public void TestIslamicTabularDates() { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); @@ -988,7 +991,7 @@ public class IslamicTest extends CalendarTestFmwk { int is_year2 = is_cal2.get(Calendar.YEAR); if( (is_month != is_month2) || (is_year != is_year2)) errln("unexpected difference between islamic and tbla month "+is_month+" : "+is_month2+" and/or year "+is_year+" : "+is_year2); - + int is_day = is_cal.get(Calendar.DAY_OF_MONTH); int is_day2 = is_cal2.get(Calendar.DAY_OF_MONTH); if(is_day2 - is_day != 1) @@ -998,30 +1001,30 @@ public class IslamicTest extends CalendarTestFmwk { @Test public void TestCreationByLocale() { - ULocale islamicLoc = new ULocale("ar_SA@calendar=islamic-umalqura"); + ULocale islamicLoc = new ULocale("ar_SA@calendar=islamic-umalqura"); IslamicCalendar is_cal = new IslamicCalendar(islamicLoc); - String thisCalcType = is_cal.getType(); + String thisCalcType = is_cal.getType(); if(!"islamic-umalqura".equalsIgnoreCase(thisCalcType)) { errln("non umalqura calc type generated - " + thisCalcType); } - islamicLoc = new ULocale("ar_SA@calendar=islamic-civil"); + islamicLoc = new ULocale("ar_SA@calendar=islamic-civil"); is_cal = new IslamicCalendar(islamicLoc); - thisCalcType = is_cal.getType(); + thisCalcType = is_cal.getType(); if(!"islamic-civil".equalsIgnoreCase(thisCalcType)) { errln("non civil calc type generated - " + thisCalcType); } - islamicLoc = new ULocale("ar_SA@calendar=islamic-tbla"); + islamicLoc = new ULocale("ar_SA@calendar=islamic-tbla"); is_cal = new IslamicCalendar(islamicLoc); - thisCalcType = is_cal.getType(); + thisCalcType = is_cal.getType(); if(!"islamic-tbla".equalsIgnoreCase(thisCalcType)) { errln("non tbla calc type generated - " + thisCalcType); } - islamicLoc = new ULocale("ar_SA@calendar=islamic-xyzzy"); + islamicLoc = new ULocale("ar_SA@calendar=islamic-xyzzy"); is_cal = new IslamicCalendar(islamicLoc); - thisCalcType = is_cal.getType(); + thisCalcType = is_cal.getType(); if(!"islamic".equalsIgnoreCase(thisCalcType)) { errln("incorrect default calc type generated - " + thisCalcType); } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/JapaneseTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/JapaneseTest.java index 34f959564e5..6ec96f48c3b 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/JapaneseTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/JapaneseTest.java @@ -14,6 +14,8 @@ import java.util.Date; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.impl.LocaleUtility; import com.ibm.icu.text.DateFormat; @@ -26,8 +28,9 @@ import com.ibm.icu.util.ULocale; /** * Tests for the JapaneseCalendar class. */ +@RunWith(JUnit4.class) public class JapaneseTest extends CalendarTestFmwk { - + @Test public void TestCoverage() { { @@ -143,7 +146,7 @@ public class JapaneseTest extends CalendarTestFmwk { } } } - + @Test public void Test3860() { @@ -160,10 +163,10 @@ public class JapaneseTest extends CalendarTestFmwk { cal.setTime(aDate); int gotYear = cal.get(Calendar.YEAR); int gotEra = cal.get(Calendar.ERA); - + int expectYear = 1; int expectEra = JapaneseCalendar.CURRENT_ERA; - + if((gotYear != expectYear) || (gotEra != expectEra)) { errln("Expected year " + expectYear + ", era " + expectEra +", but got year " + gotYear + " and era " + gotEra + ", == " + inEn); } else { @@ -196,9 +199,9 @@ public class JapaneseTest extends CalendarTestFmwk { expectYear = 1; expectEra = JapaneseCalendar.CURRENT_ERA; if((gotYear != 1) || (gotEra != expectEra)) { - errln("parse "+ samplestr + " of 'y' as Japanese Calendar, expected year " + expectYear + + errln("parse "+ samplestr + " of 'y' as Japanese Calendar, expected year " + expectYear + " and era " + expectEra + ", but got year " + gotYear + " and era " + gotEra + " (Gregorian:" + str +")"); - } else { + } else { logln(" year: " + gotYear + ", era: " + gotEra); } } @@ -231,14 +234,14 @@ public class JapaneseTest extends CalendarTestFmwk { Date otherDate; try { otherDate = fmt.parse(expected); - if(!otherDate.equals(aDate)) { + if(!otherDate.equals(aDate)) { String str3; // ParsePosition pp; Date dd = fmt.parse(expected); str3 = fmt.format(otherDate); long oLong = otherDate.getTime(); long aLong = otherDate.getTime(); - + errln("FAIL: Parse incorrect of " + expected + ": wanted " + aDate + " ("+aLong+"), but got " + " " + otherDate + " ("+oLong+") = " + str3 + " not " + dd.toString() ); @@ -267,7 +270,7 @@ public class JapaneseTest extends CalendarTestFmwk { int fieldNum = expected[i+0]; int expectedVal = expected[i+1]; int actualVal = c.get(fieldNum); - + if(expectedVal == actualVal) { logln(FIELD_NAME[fieldNum]+": "+ actualVal); } else { @@ -275,7 +278,7 @@ public class JapaneseTest extends CalendarTestFmwk { } } } - + @Test public void Test5345calendar() { logln("** testIncompleteCalendar()"); @@ -283,7 +286,7 @@ public class JapaneseTest extends CalendarTestFmwk { JapaneseCalendar c = new JapaneseCalendar(TimeZone.getDefault()); logln("test clear"); c.clear(); - + // Showa 45 = Gregorian 1970 int expected0[] = { Calendar.ERA, 234, Calendar.YEAR, 45 }; @@ -292,8 +295,8 @@ public class JapaneseTest extends CalendarTestFmwk { logln("test setting era"); c.clear(); c.set(Calendar.ERA, JapaneseCalendar.MEIJI); - - + + int expectedA[] = { Calendar.ERA, JapaneseCalendar.MEIJI }; checkExpected(c, expectedA); @@ -316,11 +319,11 @@ public class JapaneseTest extends CalendarTestFmwk { c.set(Calendar.MONTH, Calendar.JANUARY); c.set(Calendar.DATE, 1); c.set(Calendar.ERA, JapaneseCalendar.MEIJI); - - + + checkExpected(c, expectedC); - - + + logln("test setting era and year"); c.clear(); c.set(Calendar.YEAR, 1); diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/PersianTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/PersianTest.java index 2957e73f50a..7a51f1d3509 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/PersianTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/PersianTest.java @@ -10,11 +10,14 @@ package com.ibm.icu.dev.test.calendar; import java.util.Date; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.util.Calendar; import com.ibm.icu.util.PersianCalendar; import com.ibm.icu.util.ULocale; +@RunWith(JUnit4.class) public class PersianTest extends CalendarTestFmwk { /** * Test basic mapping to and from Gregorian. @@ -24,7 +27,7 @@ public class PersianTest extends CalendarTestFmwk { final int[] DATA = { // (Note: months are 1-based) 2011, 1, 11, 1389, 10, 21, - 1986, 2, 25, 1364, 12, 6, + 1986, 2, 25, 1364, 12, 6, 1934, 3, 14, 1312, 12, 23, 2090, 3, 19, 1468, 12, 29, @@ -127,17 +130,17 @@ public class PersianTest extends CalendarTestFmwk { @Test public void TestCoverage12424() { - class StubCalendar extends PersianCalendar { + class StubCalendar extends PersianCalendar { private static final long serialVersionUID = 1L; public StubCalendar() { assertEquals("Persian month 0 length", 31, handleGetMonthLength(1000, 0)); assertEquals("Persian month 7 length", 30, handleGetMonthLength(1000, 7)); - + int leastWeeks = handleGetLimit(Calendar.WEEK_OF_YEAR, Calendar.LEAST_MAXIMUM); - assertEquals("Persian Week of Year least maximum", 52, leastWeeks); + assertEquals("Persian Week of Year least maximum", 52, leastWeeks); } } - + new StubCalendar(); } } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/charsetdet/TestCharsetDetector.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/charsetdet/TestCharsetDetector.java index 6056a4b2c6e..765c31abc42 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/charsetdet/TestCharsetDetector.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/charsetdet/TestCharsetDetector.java @@ -21,6 +21,8 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; @@ -38,6 +40,7 @@ import com.ibm.icu.text.CharsetMatch; /** * @author andy */ +@RunWith(JUnit4.class) public class TestCharsetDetector extends TestFmwk { public TestCharsetDetector() @@ -57,27 +60,27 @@ public class TestCharsetDetector extends TestFmwk } errln(msg); } - + } - + private String stringFromReader(Reader reader) { StringBuffer sb = new StringBuffer(); char[] buffer = new char[1024]; int bytesRead = 0; - + try { while ((bytesRead = reader.read(buffer, 0, 1024)) >= 0) { sb.append(buffer, 0, bytesRead); } - + return sb.toString(); } catch (Exception e) { errln("stringFromReader() failed: " + e.toString()); return null; } } - + @Test public void TestConstruction() { int i; @@ -88,7 +91,7 @@ public class TestCharsetDetector extends TestFmwk String [] charsetNames = CharsetDetector.getAllDetectableCharsets(); CheckAssert(charsetNames.length != 0); for (i=0; i " + m.getName()); } } - + @Test public void TestBufferOverflow() { @@ -279,7 +282,7 @@ public class TestCharsetDetector extends TestFmwk {(byte) 0x74, (byte) 0x68, (byte) 0xa1}, /* Could be a single byte shift-jis at the end */ {(byte) 0x74, (byte) 0x68, (byte) 0x65, (byte) 0xa1} /* Could be a single byte shift-jis at the end, but now we have English creeping in. */ }; - + String testResults[] = { "windows-1252", "windows-1252", @@ -290,7 +293,7 @@ public class TestCharsetDetector extends TestFmwk null, "ISO-8859-1" }; - + CharsetDetector det = new CharsetDetector(); CharsetMatch match; @@ -325,7 +328,7 @@ public class TestCharsetDetector extends TestFmwk // Open and read the test data file. // //InputStreamReader isr = null; - + try { InputStream is = TestCharsetDetector.class.getResourceAsStream("CharsetDetectionTests.xml"); if (is == null) { @@ -335,11 +338,11 @@ public class TestCharsetDetector extends TestFmwk // Set up an xml parser. DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - + factory.setIgnoringComments(true); - + DocumentBuilder builder = factory.newDocumentBuilder(); - + // Parse the xml content from the test case file. Document doc; try { @@ -348,9 +351,9 @@ public class TestCharsetDetector extends TestFmwk is.close(); } Element root = doc.getDocumentElement(); - + NodeList testCases = root.getElementsByTagName("test-case"); - + // Process each test case Map encToBytes = new TreeMap(); for (int n = 0; n < testCases.getLength(); n += 1) { @@ -408,7 +411,7 @@ public class TestCharsetDetector extends TestFmwk } encToBytes.clear(); } - + } catch (Exception e) { errln("exception while processing test cases: " + e.toString()); } @@ -421,7 +424,7 @@ public class TestCharsetDetector extends TestFmwk errln(id + ": encoding detection failure - expected " + encoding + ", got " + m.getName()); return; } - + String charsetMatchLanguage = m.getLanguage(); if ((language != null && !charsetMatchLanguage.equals(language)) || (language == null && charsetMatchLanguage != null) @@ -439,20 +442,20 @@ public class TestCharsetDetector extends TestFmwk logln("Skipping roundtrip check on IBM Java 8: " + id + ", " + encoding); return; } - + String decoded = m.getString(); - + if (! testString.equals(decoded)) { errln(id + ", " + encoding + ": getString() didn't return the original string!"); } - + decoded = stringFromReader(m.getReader()); - + if (! testString.equals(decoded)) { errln(id + ", " + encoding + ": getReader() didn't yield the original string!"); } } - + private void checkEncoding(String testString, String encoding, String language, boolean checkRoundtrip, byte[] bytes, String id) { @@ -485,25 +488,25 @@ public class TestCharsetDetector extends TestFmwk e.printStackTrace(); } } - + @Test public void TestJapanese() throws Exception { - String s = "\u3000\u3001\u3002\u3003\u3005\u3006\u3007\u3008\u3009\u300A\u300B\u300C\u300D\u300E\u300F\u3010\u3011\u3012\u3013\u3014" + - "\u3015\u301C\u3041\u3042\u3043\u3044\u3045\u3046\u3047\u3048\u3049\u304A\u304B\u304C\u304D\u304E\u304F\u3050\u3051\u3052" + - "\u3053\u3054\u3055\u3056\u3057\u3058\u3059\u305A\u305B\u305C\u305D\u305E\u305F\u3060\u3061\u3062\u3063\u3064\u3065\u3066" + - "\u3067\u3068\u3069\u306A\u306B\u306C\u306D\u306E\u306F\u3070\u3071\u3072\u3073\u3074\u3075\u3076\u3077\u3078\u3079\u307A" + - "\u307B\u307C\u307D\u307E\u307F\u3080\u3081\u3082\u3083\u3084\u3085\u3086\u3087\u3088\u3089\u308A\u308B\u308C\u308D\u308E" + - "\u308F\u3090\u3091\u3092\u3093\u309B\u309C\u309D\u309E\u30A1\u30A2\u30A3\u30A4\u30A5\u30A6\u30A7\u30A8\u30A9\u30AA\u30AB" + - "\u30AC\u30AD\u30AE\u30AF\u30B0\u30B1\u30B2\u30B3\u30B4\u30B5\u30B6\u30B7\u30B8\u30B9\u30BA\u30BB\u30BC\u30BD\u30BE\u30BF" + - "\u30C0\u30C1\u30C2\u30C3\u30C4\u30C5\u30C6\u30C7\u30C8\u30C9\u30CA\u30CB\u30CC\u30CD\u30CE\u30CF\u30D0\u30D1\u30D2\u30D3" + - "\u30D4\u30D5\u30D6\u30D7\u30D8\u30D9\u30DA\u30DB\u30DC\u30DD\u30DE\u30DF\u30E0\u30E1\u30E2\u30E3\u30E4\u30E5\u30E6\u30E7" + - "\u30E8\u30E9\u30EA\u30EB\u30EC\u30ED\u30EE\u30EF\u30F0\u30F1\u30F2\u30F3\u30F4\u30F5\u30F6\u30FB\u30FC\u30FD\u30FE\u4E00" + - "\u4E01\u4E02\u4E03\u4E04\u4E05\u4E07\u4E08\u4E09\u4E0A\u4E0B\u4E0C\u4E0D\u4E0E\u4E10\u4E11\u4E12\u4E14\u4E15\u4E16\u4E17" + - "\u4E18\u4E19\u4E1E\u4E1F\u4E21\u4E23\u4E24\u4E26\u4E28\u4E2A\u4E2B\u4E2D\u4E2E\u4E2F\u4E30\u4E31\u4E32\u4E35\u4E36\u4E38" + - "\u4E39\u4E3B\u4E3C\u4E3F\u4E40\u4E41\u4E42\u4E43\u4E44\u4E45\u4E47\u4E4B\u4E4D\u4E4E\u4E4F\u4E51\u4E55\u4E56\u4E57\u4E58" + - "\u4E59\u4E5A\u4E5C\u4E5D\u4E5E\u4E5F\u4E62\u4E63\u4E68\u4E69\u4E71\u4E73\u4E74\u4E75\u4E79\u4E7E\u4E7F\u4E80\u4E82\u4E85" + + String s = "\u3000\u3001\u3002\u3003\u3005\u3006\u3007\u3008\u3009\u300A\u300B\u300C\u300D\u300E\u300F\u3010\u3011\u3012\u3013\u3014" + + "\u3015\u301C\u3041\u3042\u3043\u3044\u3045\u3046\u3047\u3048\u3049\u304A\u304B\u304C\u304D\u304E\u304F\u3050\u3051\u3052" + + "\u3053\u3054\u3055\u3056\u3057\u3058\u3059\u305A\u305B\u305C\u305D\u305E\u305F\u3060\u3061\u3062\u3063\u3064\u3065\u3066" + + "\u3067\u3068\u3069\u306A\u306B\u306C\u306D\u306E\u306F\u3070\u3071\u3072\u3073\u3074\u3075\u3076\u3077\u3078\u3079\u307A" + + "\u307B\u307C\u307D\u307E\u307F\u3080\u3081\u3082\u3083\u3084\u3085\u3086\u3087\u3088\u3089\u308A\u308B\u308C\u308D\u308E" + + "\u308F\u3090\u3091\u3092\u3093\u309B\u309C\u309D\u309E\u30A1\u30A2\u30A3\u30A4\u30A5\u30A6\u30A7\u30A8\u30A9\u30AA\u30AB" + + "\u30AC\u30AD\u30AE\u30AF\u30B0\u30B1\u30B2\u30B3\u30B4\u30B5\u30B6\u30B7\u30B8\u30B9\u30BA\u30BB\u30BC\u30BD\u30BE\u30BF" + + "\u30C0\u30C1\u30C2\u30C3\u30C4\u30C5\u30C6\u30C7\u30C8\u30C9\u30CA\u30CB\u30CC\u30CD\u30CE\u30CF\u30D0\u30D1\u30D2\u30D3" + + "\u30D4\u30D5\u30D6\u30D7\u30D8\u30D9\u30DA\u30DB\u30DC\u30DD\u30DE\u30DF\u30E0\u30E1\u30E2\u30E3\u30E4\u30E5\u30E6\u30E7" + + "\u30E8\u30E9\u30EA\u30EB\u30EC\u30ED\u30EE\u30EF\u30F0\u30F1\u30F2\u30F3\u30F4\u30F5\u30F6\u30FB\u30FC\u30FD\u30FE\u4E00" + + "\u4E01\u4E02\u4E03\u4E04\u4E05\u4E07\u4E08\u4E09\u4E0A\u4E0B\u4E0C\u4E0D\u4E0E\u4E10\u4E11\u4E12\u4E14\u4E15\u4E16\u4E17" + + "\u4E18\u4E19\u4E1E\u4E1F\u4E21\u4E23\u4E24\u4E26\u4E28\u4E2A\u4E2B\u4E2D\u4E2E\u4E2F\u4E30\u4E31\u4E32\u4E35\u4E36\u4E38" + + "\u4E39\u4E3B\u4E3C\u4E3F\u4E40\u4E41\u4E42\u4E43\u4E44\u4E45\u4E47\u4E4B\u4E4D\u4E4E\u4E4F\u4E51\u4E55\u4E56\u4E57\u4E58" + + "\u4E59\u4E5A\u4E5C\u4E5D\u4E5E\u4E5F\u4E62\u4E63\u4E68\u4E69\u4E71\u4E73\u4E74\u4E75\u4E79\u4E7E\u4E7F\u4E80\u4E82\u4E85" + "\u4E86\u4E88\u4E89\u4E8A\u4E8B\u4E8C"; - + CharsetDetector det = new CharsetDetector(); CharsetMatch m; String charsetMatch; @@ -514,7 +517,7 @@ public class TestCharsetDetector extends TestFmwk m = det.detect(); charsetMatch = m.getName(); CheckAssert(charsetMatch.equals("EUC-JP")); - + // Tests "public String getLanguage()" CheckAssert(m.getLanguage().equals("ja")); } @@ -523,17 +526,17 @@ public class TestCharsetDetector extends TestFmwk @Test public void TestArabic() throws Exception { String s = "\u0648\u0636\u0639\u062A \u0648\u0646\u0641\u0630\u062A \u0628\u0631\u0627" + - "\u0645\u062C \u062A\u0623\u0645\u064A\u0646 \u0639\u062F\u064A\u062F\u0629 \u0641\u064A " + - "\u0645\u0624\u0633\u0633\u0629 \u0627\u0644\u062A\u0623\u0645\u064A\u0646 \u0627\u0644" + - "\u0648\u0637\u0646\u064A, \u0645\u0639 \u0645\u0644\u0627\u0626\u0645\u062A\u0647\u0627 " + - "\u062F\u0627\u0626\u0645\u0627 \u0644\u0644\u0627\u062D\u062A\u064A\u0627\u062C" + - "\u0627\u062A \u0627\u0644\u0645\u062A\u063A\u064A\u0631\u0629 \u0644\u0644\u0645\u062C" + - "\u062A\u0645\u0639 \u0648\u0644\u0644\u062F\u0648\u0644\u0629. \u062A\u0648\u0633\u0639" + - "\u062A \u0648\u062A\u0637\u0648\u0631\u062A \u0627\u0644\u0645\u0624\u0633\u0633\u0629 " + - "\u0628\u0647\u062F\u0641 \u0636\u0645\u0627\u0646 \u0634\u0628\u0643\u0629 \u0623\u0645" + - "\u0627\u0646 \u0644\u0633\u0643\u0627\u0646 \u062F\u0648\u0644\u0629 \u0627\u0633\u0631" + - "\u0627\u0626\u064A\u0644 \u0628\u0648\u062C\u0647 \u0627\u0644\u0645\u062E\u0627\u0637" + - "\u0631 \u0627\u0644\u0627\u0642\u062A\u0635\u0627\u062F\u064A\u0629 \u0648\u0627\u0644" + + "\u0645\u062C \u062A\u0623\u0645\u064A\u0646 \u0639\u062F\u064A\u062F\u0629 \u0641\u064A " + + "\u0645\u0624\u0633\u0633\u0629 \u0627\u0644\u062A\u0623\u0645\u064A\u0646 \u0627\u0644" + + "\u0648\u0637\u0646\u064A, \u0645\u0639 \u0645\u0644\u0627\u0626\u0645\u062A\u0647\u0627 " + + "\u062F\u0627\u0626\u0645\u0627 \u0644\u0644\u0627\u062D\u062A\u064A\u0627\u062C" + + "\u0627\u062A \u0627\u0644\u0645\u062A\u063A\u064A\u0631\u0629 \u0644\u0644\u0645\u062C" + + "\u062A\u0645\u0639 \u0648\u0644\u0644\u062F\u0648\u0644\u0629. \u062A\u0648\u0633\u0639" + + "\u062A \u0648\u062A\u0637\u0648\u0631\u062A \u0627\u0644\u0645\u0624\u0633\u0633\u0629 " + + "\u0628\u0647\u062F\u0641 \u0636\u0645\u0627\u0646 \u0634\u0628\u0643\u0629 \u0623\u0645" + + "\u0627\u0646 \u0644\u0633\u0643\u0627\u0646 \u062F\u0648\u0644\u0629 \u0627\u0633\u0631" + + "\u0627\u0626\u064A\u0644 \u0628\u0648\u062C\u0647 \u0627\u0644\u0645\u062E\u0627\u0637" + + "\u0631 \u0627\u0644\u0627\u0642\u062A\u0635\u0627\u062F\u064A\u0629 \u0648\u0627\u0644" + "\u0627\u062C\u062A\u0645\u0627\u0639\u064A\u0629."; CharsetDetector det = new CharsetDetector(); @@ -550,7 +553,7 @@ public class TestCharsetDetector extends TestFmwk m = det.detect(); charsetMatch = m.getName(); CheckAssert(charsetMatch.equals("windows-1256")); - + // Tests "public String getLanguage()" CheckAssert(m.getLanguage().endsWith("ar")); } @@ -592,7 +595,7 @@ public class TestCharsetDetector extends TestFmwk m = det.detect(); charsetMatch = m.getName(); CheckAssert(charsetMatch.equals("IBM420_rtl")); - + // Tests "public String getLanguage()" CheckAssert(m.getLanguage().endsWith("ar")); } @@ -643,32 +646,32 @@ public class TestCharsetDetector extends TestFmwk @Test public void TestHebrew() throws Exception { String s = "\u05D4\u05E4\u05E8\u05E7\u05DC\u05D9\u05D8 \u05D4\u05E6\u05D1\u05D0\u05D9 \u05D4" + - "\u05E8\u05D0\u05E9\u05D9, \u05EA\u05EA \u05D0\u05DC\u05D5\u05E3 \u05D0\u05D1\u05D9" + - "\u05D7\u05D9 \u05DE\u05E0\u05D3\u05DC\u05D1\u05DC\u05D9\u05D8, \u05D4\u05D5\u05E8" + - "\u05D4 \u05E2\u05DC \u05E4\u05EA\u05D9\u05D7\u05EA \u05D7\u05E7\u05D9\u05E8\u05EA " + - "\u05DE\u05E6\"\u05D7 \u05D1\u05E2\u05E7\u05D1\u05D5\u05EA \u05E2\u05D3\u05D5\u05D9" + - "\u05D5\u05EA \u05D7\u05D9\u05D9\u05DC\u05D9 \u05E6\u05D4\"\u05DC \u05DE\u05DE\u05D1" + + "\u05E8\u05D0\u05E9\u05D9, \u05EA\u05EA \u05D0\u05DC\u05D5\u05E3 \u05D0\u05D1\u05D9" + + "\u05D7\u05D9 \u05DE\u05E0\u05D3\u05DC\u05D1\u05DC\u05D9\u05D8, \u05D4\u05D5\u05E8" + + "\u05D4 \u05E2\u05DC \u05E4\u05EA\u05D9\u05D7\u05EA \u05D7\u05E7\u05D9\u05E8\u05EA " + + "\u05DE\u05E6\"\u05D7 \u05D1\u05E2\u05E7\u05D1\u05D5\u05EA \u05E2\u05D3\u05D5\u05D9" + + "\u05D5\u05EA \u05D7\u05D9\u05D9\u05DC\u05D9 \u05E6\u05D4\"\u05DC \u05DE\u05DE\u05D1" + "\u05E6\u05E2 \u05E2\u05D5\u05E4\u05E8\u05EA \u05D9\u05E6\u05D5\u05E7\u05D4 \u05D1+ " + - "\u05E8\u05E6\u05D5\u05E2\u05EA \u05E2\u05D6\u05D4. \u05DC\u05D3\u05D1\u05E8\u05D9 " + + "\u05E8\u05E6\u05D5\u05E2\u05EA \u05E2\u05D6\u05D4. \u05DC\u05D3\u05D1\u05E8\u05D9 " + "\u05D4\u05E4\u05E6\"\u05E8, \u05DE\u05D4\u05E2\u05D3\u05D5\u05D9\u05D5\u05EA \u05E2" + - "\u05D5\u05DC\u05D4 \u05EA\u05DE\u05D5\u05E0\u05D4 \u05E9\u05DC \"\u05D4\u05EA\u05E0" + - "\u05D4\u05D2\u05D5\u05EA \u05E4\u05E1\u05D5\u05DC\u05D4 \u05DC\u05DB\u05D0\u05D5\u05E8" + - "\u05D4 \u05E9\u05DC \u05D7\u05D9\u05D9\u05DC\u05D9\u05DD \u05D1\u05DE\u05D4\u05DC\u05DA" + - " \u05DE\u05D1\u05E6\u05E2 \u05E2\u05D5\u05E4\u05E8\u05EA \u05D9\u05E6\u05D5\u05E7\u05D4\"." + + "\u05D5\u05DC\u05D4 \u05EA\u05DE\u05D5\u05E0\u05D4 \u05E9\u05DC \"\u05D4\u05EA\u05E0" + + "\u05D4\u05D2\u05D5\u05EA \u05E4\u05E1\u05D5\u05DC\u05D4 \u05DC\u05DB\u05D0\u05D5\u05E8" + + "\u05D4 \u05E9\u05DC \u05D7\u05D9\u05D9\u05DC\u05D9\u05DD \u05D1\u05DE\u05D4\u05DC\u05DA" + + " \u05DE\u05D1\u05E6\u05E2 \u05E2\u05D5\u05E4\u05E8\u05EA \u05D9\u05E6\u05D5\u05E7\u05D4\"." + " \u05DE\u05E0\u05D3\u05DC\u05D1\u05DC\u05D9\u05D8 \u05E7\u05D9\u05D1\u05DC \u05D0\u05EA" + " \u05D4\u05D7\u05DC\u05D8\u05EA\u05D5 \u05DC\u05D0\u05D7\u05E8 \u05E9\u05E2\u05D9\u05D9" + "\u05DF \u05D1\u05EA\u05DE\u05DC\u05D9\u05DC \u05D4\u05E2\u05D3\u05D5\u05D9\u05D5\u05EA"; - + CharsetMatch m = _test1255(s); String charsetMatch = m.getName(); CheckAssert(charsetMatch.equals("ISO-8859-8-I")); CheckAssert(m.getLanguage().equals("he")); - + m = _test1255_reverse(s); charsetMatch = m.getName(); CheckAssert(charsetMatch.equals("ISO-8859-8")); CheckAssert(m.getLanguage().equals("he")); - + m = _testIBM424_he_rtl(s); charsetMatch = m.getName(); CheckAssert(charsetMatch.equals("IBM424_rtl")); @@ -678,7 +681,7 @@ public class TestCharsetDetector extends TestFmwk } catch (Exception ex) { errln("Error getting string for charsetMatch: " + charsetMatch); } - + m = _testIBM424_he_ltr(s); charsetMatch = m.getName(); CheckAssert(charsetMatch.equals("IBM424_ltr")); @@ -689,7 +692,7 @@ public class TestCharsetDetector extends TestFmwk errln("Error getting string for charsetMatch: " + charsetMatch); } } - + private CharsetMatch _test1255(String s) throws Exception { byte [] bytes = s.getBytes("ISO-8859-8"); CharsetDetector det = new CharsetDetector(); @@ -697,18 +700,18 @@ public class TestCharsetDetector extends TestFmwk CharsetMatch m = det.detect(); return m; } - + private CharsetMatch _test1255_reverse(String s) throws Exception { StringBuffer reverseStrBuf = new StringBuffer(s); reverseStrBuf = reverseStrBuf.reverse(); byte [] bytes = reverseStrBuf.toString().getBytes("ISO-8859-8"); - + CharsetDetector det = new CharsetDetector(); det.setText(bytes); CharsetMatch m = det.detect(); return m; } - + private CharsetMatch _testIBM424_he_rtl(String s) throws Exception { byte [] bytes = s.getBytes("IBM424"); CharsetDetector det = new CharsetDetector(); @@ -720,16 +723,16 @@ public class TestCharsetDetector extends TestFmwk CharsetMatch m = det.detect(); return m; } - + private CharsetMatch _testIBM424_he_ltr(String s) throws Exception { /** * transformation of input string to CP420 left to right requires reversing the string - */ - + */ + StringBuffer ltrStrBuf = new StringBuffer(s); ltrStrBuf = ltrStrBuf.reverse(); byte [] bytes = ltrStrBuf.toString().getBytes("IBM424"); - + CharsetDetector det = new CharsetDetector(); det.setDetectableCharset("IBM424_rtl", true); det.setDetectableCharset("IBM424_ltr", true); @@ -739,7 +742,7 @@ public class TestCharsetDetector extends TestFmwk CharsetMatch m = det.detect(); return m; } - + /* * Test the method int match(CharsetDetector det) in CharsetRecog_UTF_16_LE */ @@ -767,7 +770,7 @@ public class TestCharsetDetector extends TestFmwk detector1.setText(data1); CharsetMatch match1 = detector1.detect(); assertEquals("Expected GB18030", "GB18030", match1.getName()); - + CharsetDetector detector2 = new CharsetDetector(); byte[] data2 = createData2(); detector2.setText(data2); @@ -775,12 +778,12 @@ public class TestCharsetDetector extends TestFmwk // It is actually GB18030 but the sample size is way too small to be reliable. assertEquals("Expected ISO-8859-1, even though that isn't strictly correct", "ISO-8859-1", match2.getName()); } - + @Test public void TestReusingDetector() throws Exception { CharsetDetector detector = new CharsetDetector(); - + byte[] data1 = createData1(); detector.setText(data1); CharsetMatch match1 = detector.detect(); @@ -793,7 +796,7 @@ public class TestCharsetDetector extends TestFmwk CharsetMatch match2a = detector.detect(); assertEquals("[second]Expected ISO-8859-1, even though that isn't strictly correct", "ISO-8859-1", match2a.getName()); } - + private static byte[] createData1() { return bytesFromString("3B 3B 3B 20 2D 2A 2D 20 4D 6F 64 65 3A 20 4C 49 53 50 3B 20 53 79 6E 74 61 78 " + @@ -1084,15 +1087,15 @@ public class TestCharsetDetector extends TestFmwk "23 27 6D 61 74 63 68 69 6E 67 2D 73 75 62 73 74 72 69 6E 67 3F 29 29 0D 0A 09 " + "20 20 0D 0A"); } - + private static byte[] createData2() { return bytesFromString("0A D0 A1 CA B1 20 3B 3B 20 48 6F 75 72 28 73 29 0A D0 C7 C6 DA 20 3B 3B 20 57 " + "65 65 6B 28 73 29 0A B5 B1 B5 D8 20 CA B1 BC E4 20 3B 3B 20 6C 6F 63 61 6C 20 " + "74 69 6D 65 0A"); } - - + + /** * Creates a byte array by decoding the hex string passed in. * @@ -1117,7 +1120,7 @@ public class TestCharsetDetector extends TestFmwk out.write(Integer.parseInt(new String(number), 16)); } } - + return out.toByteArray(); } // @@ -1129,7 +1132,7 @@ public class TestCharsetDetector extends TestFmwk public void TestBug9267() { // Test a long input of Lam Alef characters for CharsetRecog_IBM420_ar. // Bug 9267 was an array out of bounds problem in the unshaping code for these. - byte [] input = new byte [7700]; + byte [] input = new byte [7700]; int i; for (i=0; i detectedEncodings = new HashSet(); for (CharsetMatch m: matches) { assertTrue("Charset " + m.getName() + " encountered before", detectedEncodings.add(m.getName())); - } + } } - + @Test public void TestMultithreaded() { String s = "This is some random plain text to run charset detection on."; @@ -1210,16 +1213,17 @@ public class TestCharsetDetector extends TestFmwk fail("Unexpected exception " + e.toString()); return; } - + class WorkerThread extends Thread { WorkerThread(int num) { n = num; - } - private int n; + } + private int n; + @Override public void run() { // System.out.println("Thread " + n + " is running."); CharsetDetector det = new CharsetDetector(); - det.setText(bytes); + det.setText(bytes); for (int i=0; i<10000; i++) { CharsetMatch matches[] = det.detectAll(); for (CharsetMatch m: matches) { @@ -1229,7 +1233,7 @@ public class TestCharsetDetector extends TestFmwk // System.out.println("Thread " + n + " is finished."); } } - + Thread threads[] = new Thread[10]; for (int i=0; i<10; i++) { threads[i] = new WorkerThread(i); @@ -1245,5 +1249,5 @@ public class TestCharsetDetector extends TestFmwk } } - + } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/compression/DecompressionTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/compression/DecompressionTest.java index 1e30e67f6c1..05ecb4b7103 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/compression/DecompressionTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/compression/DecompressionTest.java @@ -9,10 +9,13 @@ package com.ibm.icu.dev.test.compression; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.UnicodeDecompressor; +@RunWith(JUnit4.class) public class DecompressionTest extends TestFmwk { /** Print out a segment of a character array, if in verbose mode */ private void log(char [] chars, int start, int count) { @@ -42,7 +45,7 @@ public class DecompressionTest extends TestFmwk { count1 = myDecompressor.decompress(segment1, 0, segment1.length, bytesRead, charBuffer, 0, charBuffer.length); - + logln("Segment 1 (" + segment1.length + " bytes) " + "decompressed into " + count1 + " chars"); logln("Bytes consumed: " + bytesRead[0]); @@ -53,16 +56,16 @@ public class DecompressionTest extends TestFmwk { count2 = myDecompressor.decompress(segment2, 0, segment2.length, bytesRead, - charBuffer, count1, + charBuffer, count1, charBuffer.length); - + logln("Segment 2 (" + segment2.length + " bytes) " + "decompressed into " + count2 + " chars"); logln("Bytes consumed: " + bytesRead[0]); logln("Got chars: "); logln(charBuffer, count1, count2); - + s.append(charBuffer, count1, count2); logln("Result: "); @@ -84,7 +87,7 @@ public class DecompressionTest extends TestFmwk { // continuation /* IDX , S . */ byte [] segment2 = { 0x01, 0x2c, 0x20, 0x53, 0x2e }; - + result = decompressTest(segment1, segment2); if(! result.equals("Booth, S.")) { errln("Decompression test failed"); @@ -120,16 +123,16 @@ public class DecompressionTest extends TestFmwk { return; } } - + /* Testing the method - * public int decompress(*** + * public int decompress(*** */ @Test public void TestDecompress(){ char[] charBufferBlank = {}; char[] charBuffer1 = {'a'}; char[] charValid = {'d','u','m','m','y'}; - + // Test when "if(charBuffer.length < 2 || (charBufferLimit - charBufferStart) < 2)" is true // The following tests when "charBuffer.length < 2" UnicodeDecompressor ud = new UnicodeDecompressor(); @@ -137,42 +140,42 @@ public class DecompressionTest extends TestFmwk { ud.decompress(null, 0, 0, null, null, 4, 0); errln("UnicodeDecompressor.decompress was suppose to return an exception."); } catch(Exception e){} - + try{ ud.decompress(null, 0, 0, null, charBufferBlank, 4, 0); errln("UnicodeDecompressor.decompress was suppose to return an exception."); } catch(Exception e){} - + try{ ud.decompress(null, 0, 0, null, charBuffer1, 4, 0); errln("UnicodeDecompressor.decompress was suppose to return an exception."); } catch(Exception e){} - + // The following tests when "(charBufferLimit - charBufferStart) < 2" try{ ud.decompress(null, 0, 0, null, charValid, 0, 0); errln("UnicodeDecompressor.decompress was suppose to return an exception."); } catch(Exception e){} - + try{ ud.decompress(null, 0, 0, null, charValid, 1, 0); errln("UnicodeDecompressor.decompress was suppose to return an exception."); } catch(Exception e){} - + try{ ud.decompress(null, 0, 0, null, charValid, 1, 1); errln("UnicodeDecompressor.decompress was suppose to return an exception."); } catch(Exception e){} - + try{ ud.decompress(null, 0, 0, null, charValid, 0, 1); errln("UnicodeDecompressor.decompress was suppose to return an exception."); } catch(Exception e){} - + try{ ud = new UnicodeDecompressor(); byte[] b = { - (byte) 0x80, (byte) 0x81, (byte) 0x82, (byte) 0x83, (byte) 0x84, + (byte) 0x80, (byte) 0x81, (byte) 0x82, (byte) 0x83, (byte) 0x84, (byte) 0x85, (byte) 0x86, (byte) 0x87, (byte) 0x88, (byte) 0x89, (byte) 0x8A, (byte) 0x8B, (byte) 0x8C, (byte) 0x8D, (byte) 0x8E, (byte) 0x8F, (byte) 0x90, (byte) 0x91, (byte) 0x92, (byte) 0x93, @@ -220,7 +223,7 @@ public class DecompressionTest extends TestFmwk { (byte) 0x7A, (byte) 0x7B, (byte) 0x7C, (byte) 0x7D, (byte) 0x7E, (byte) 0x7F, (byte) UnicodeDecompressor.SQUOTEU, - (byte) UnicodeDecompressor.SCHANGEU, + (byte) UnicodeDecompressor.SCHANGEU, (byte) UnicodeDecompressor.SQUOTE0, (byte) UnicodeDecompressor.SQUOTE1, (byte) UnicodeDecompressor.SQUOTE2, (byte) UnicodeDecompressor.SQUOTE3, (byte) UnicodeDecompressor.SQUOTE4, (byte) UnicodeDecompressor.SQUOTE5, (byte) UnicodeDecompressor.SQUOTE6, (byte) UnicodeDecompressor.SQUOTE7, (byte) UnicodeDecompressor.SCHANGE0, (byte) UnicodeDecompressor.SCHANGE1, (byte) UnicodeDecompressor.SCHANGE2, (byte) UnicodeDecompressor.SCHANGE3, diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/compression/ExhaustiveTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/compression/ExhaustiveTest.java index a29a57b3bb3..c21d7866e15 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/compression/ExhaustiveTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/compression/ExhaustiveTest.java @@ -9,11 +9,14 @@ package com.ibm.icu.dev.test.compression; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.UnicodeCompressor; import com.ibm.icu.text.UnicodeDecompressor; +@RunWith(JUnit4.class) public class ExhaustiveTest extends TestFmwk { /** Test simple compress/decompress API, returning # of errors */ @Test @@ -25,10 +28,10 @@ public class ExhaustiveTest extends TestFmwk { private void simpleTest(String s) throws Exception { byte [] compressed = UnicodeCompressor.compress(s); String res = UnicodeDecompressor.decompress(compressed); - if (logDiffs(s.toCharArray(), s.length(), + if (logDiffs(s.toCharArray(), s.length(), res.toCharArray(), res.length()) == false) { - logln(s.length() + " chars ===> " - + compressed.length + " bytes ===> " + logln(s.length() + " chars ===> " + + compressed.length + " bytes ===> " + res.length() + " chars"); } else { logln("Compressed:"); @@ -47,7 +50,7 @@ public class ExhaustiveTest extends TestFmwk { private void myTest(char[] chars, int len) { UnicodeCompressor myCompressor = new UnicodeCompressor(); UnicodeDecompressor myDecompressor = new UnicodeDecompressor(); - + // variables for my compressor int myByteCount = 0; int myCharCount = 0; @@ -57,7 +60,7 @@ public class ExhaustiveTest extends TestFmwk { char[] myDecompressed = new char[myDecompressedSize]; int[] unicharsRead = new int[1]; int[] bytesRead = new int[1]; - + myByteCount = myCompressor.compress(chars, 0, len, unicharsRead, myCompressed, 0, myCompressedSize); @@ -65,8 +68,8 @@ public class ExhaustiveTest extends TestFmwk { bytesRead, myDecompressed, 0, myDecompressedSize); if (logDiffs(chars, len, myDecompressed, myCharCount) == false) { - logln(len + " chars ===> " - + myByteCount + " bytes ===> " + logln(len + " chars ===> " + + myByteCount + " bytes ===> " + myCharCount + " chars"); } else { logln("Compressed:"); @@ -85,9 +88,9 @@ public class ExhaustiveTest extends TestFmwk { private void myMultipassTest(char [] chars, int len) throws Exception { UnicodeCompressor myCompressor = new UnicodeCompressor(); UnicodeDecompressor myDecompressor = new UnicodeDecompressor(); - + // variables for my compressor - + // for looping int byteBufferSize = 4;//Math.max(4, len / 4); byte[] byteBuffer = new byte [byteBufferSize]; @@ -107,7 +110,7 @@ public class ExhaustiveTest extends TestFmwk { int[] unicharsRead = new int[1]; int[] bytesRead = new int[1]; - + int totalCharsCompressed = 0; int totalBytesWritten = 0; @@ -119,21 +122,21 @@ public class ExhaustiveTest extends TestFmwk { // perform the compression in a loop do { - + // do the compression - bytesWritten = myCompressor.compress(chars, totalCharsCompressed, + bytesWritten = myCompressor.compress(chars, totalCharsCompressed, len, unicharsRead, byteBuffer, 0, byteBufferSize); // copy the current set of bytes into the target buffer - System.arraycopy(byteBuffer, 0, compressed, + System.arraycopy(byteBuffer, 0, compressed, totalBytesWritten, bytesWritten); - + // update the no. of characters compressed totalCharsCompressed += unicharsRead[0]; - + // update the no. of bytes written totalBytesWritten += bytesWritten; - + /*System.out.logln("Compression pass complete. Compressed " + unicharsRead[0] + " chars into " + bytesWritten + " bytes.");*/ @@ -145,40 +148,40 @@ public class ExhaustiveTest extends TestFmwk { } else { logln("MP: " + len + " chars ===> " + totalBytesWritten + " bytes."); } - + // perform the decompression in a loop do { - + // do the decompression - unicharsWritten = myDecompressor.decompress(compressed, - totalBytesDecompressed, totalBytesWritten, + unicharsWritten = myDecompressor.decompress(compressed, + totalBytesDecompressed, totalBytesWritten, bytesRead, unicharBuffer, 0, unicharBufferSize); // copy the current set of chars into the target buffer - System.arraycopy(unicharBuffer, 0, decompressed, + System.arraycopy(unicharBuffer, 0, decompressed, totalCharsWritten, unicharsWritten); - + // update the no. of bytes decompressed totalBytesDecompressed += bytesRead[0]; - + // update the no. of chars written totalCharsWritten += unicharsWritten; - + /*System.out.logln("Decompression pass complete. Decompressed " + bytesRead[0] + " bytes into " + unicharsWritten + " chars.");*/ } while (totalBytesDecompressed < totalBytesWritten); if (totalBytesDecompressed != totalBytesWritten) { - errln("ERROR: Number of bytes decompressed(" - + totalBytesDecompressed - + ") != totalBytesWritten(" + errln("ERROR: Number of bytes decompressed(" + + totalBytesDecompressed + + ") != totalBytesWritten(" + totalBytesWritten + ")"); } else { logln("MP: " + totalBytesWritten + " bytes ===> " + totalCharsWritten + " chars."); } - + if (logDiffs(chars, len, decompressed, totalCharsWritten)) { errln("ERROR: buffer contents incorrect"); } @@ -187,7 +190,7 @@ public class ExhaustiveTest extends TestFmwk { /** Print differences between two character buffers */ private boolean logDiffs(char[] s1, int s1len, char[] s2, int s2len) { boolean result = false; - + if(s1len != s2len) { logln("===================="); logln("Length doesn't match: expected " + s1len @@ -198,7 +201,7 @@ public class ExhaustiveTest extends TestFmwk { printChars(s2, s2len); result = true; } - + int len = Math.min(s1len, s2len); for(int i = 0; i < len; ++i) { if(s1[i] != s2[i]) { @@ -216,7 +219,7 @@ public class ExhaustiveTest extends TestFmwk { break; } } - + return result; } @@ -225,7 +228,7 @@ public class ExhaustiveTest extends TestFmwk { char[] result = new char [len]; int runLen = 0; int used = 0; - + while(used < len) { runLen = (int) (30 * random.nextDouble()); if(used + runLen >= len) { @@ -234,7 +237,7 @@ public class ExhaustiveTest extends TestFmwk { randomRun(result, used, runLen, random); used += runLen; } - + return result; }*/ @@ -287,7 +290,7 @@ public class ExhaustiveTest extends TestFmwk { "\ud800\udc00", // smallest surrogate "\ud8ff\udcff", // largest surrogate pair - + // regression tests "\u6441\ub413\ua733\uf8fe\ueedb\u587f\u195f\u4899\uf23d\u49fd\u0aac\u5792\ufc22\ufc3c\ufc46\u00aa", "\u30f9\u8321\u05e5\u181c\ud72b\u2019\u99c9\u2f2f\uc10c\u82e1\u2c4d\u1ebc\u6013\u66dc\ubbde\u94a5\u4726\u74af\u3083\u55b9\u000c", @@ -303,7 +306,7 @@ public class ExhaustiveTest extends TestFmwk { //========================== private final static int SINGLEBYTEMODE = 0; private final static int UNICODEMODE = 1; - + //========================== // Single-byte mode tags //========================== @@ -364,11 +367,11 @@ public class ExhaustiveTest extends TestFmwk { private final static int UDEFINEX = 0xF1; //private final static int URESERVED = 0xF2; // this is a reserved value - /* Print out an array of characters, with non-printables (for me) + /* Print out an array of characters, with non-printables (for me) displayed as hex values */ private void printChars(char[] chars, int len) { for(int i = 0; i < len; i++) { - int c = (int)chars[i]; + int c = chars[i]; if(c < 0x0020 || c >= 0x7f) { log("[0x"); log(Integer.toHexString(c)); @@ -385,137 +388,137 @@ public class ExhaustiveTest extends TestFmwk { int byteBufferLimit = len; int mode = SINGLEBYTEMODE; int aByte = 0x00; - + if(len > byteBuffer.length) { logln("Warning: printBytes called with length too large. Truncating"); byteBufferLimit = byteBuffer.length; } - + while(curByteIndex < byteBufferLimit) { - switch(mode) { + switch(mode) { case SINGLEBYTEMODE: - while(curByteIndex < byteBufferLimit + while(curByteIndex < byteBufferLimit && mode == SINGLEBYTEMODE) { - aByte = ((int)byteBuffer[curByteIndex++]) & 0xFF; + aByte = (byteBuffer[curByteIndex++]) & 0xFF; switch(aByte) { default: - log(Integer.toHexString(((int) aByte) & 0xFF) + " "); + log(Integer.toHexString((aByte) & 0xFF) + " "); break; // quote unicode case SQUOTEU: log("SQUOTEU "); if (curByteIndex < byteBufferLimit) { - log(Integer.toHexString(((int) byteBuffer[curByteIndex++]) & 0xFF) + " "); + log(Integer.toHexString((byteBuffer[curByteIndex++]) & 0xFF) + " "); } if (curByteIndex < byteBufferLimit) { - log(Integer.toHexString(((int) byteBuffer[curByteIndex++]) & 0xFF) + " "); + log(Integer.toHexString((byteBuffer[curByteIndex++]) & 0xFF) + " "); } break; - + // switch to Unicode mode case SSWITCHU: log("SSWITCHU "); mode = UNICODEMODE; break; - + // handle all quote tags case SQUOTE0: case SQUOTE1: case SQUOTE2: case SQUOTE3: case SQUOTE4: case SQUOTE5: case SQUOTE6: case SQUOTE7: log("SQUOTE" + (aByte - SQUOTE0) + " "); if(curByteIndex < byteBufferLimit) { - log(Integer.toHexString(((int) byteBuffer[curByteIndex++]) & 0xFF) + " "); + log(Integer.toHexString((byteBuffer[curByteIndex++]) & 0xFF) + " "); } break; - + // handle all switch tags case SSWITCH0: case SSWITCH1: case SSWITCH2: case SSWITCH3: case SSWITCH4: case SSWITCH5: case SSWITCH6: case SSWITCH7: log("SSWITCH" + (aByte - SSWITCH0) + " "); break; - + // handle all define tags case SDEFINE0: case SDEFINE1: case SDEFINE2: case SDEFINE3: case SDEFINE4: case SDEFINE5: case SDEFINE6: case SDEFINE7: log("SDEFINE" + (aByte - SDEFINE0) + " "); if (curByteIndex < byteBufferLimit) { - log(Integer.toHexString(((int) byteBuffer[curByteIndex++]) & 0xFF) + " "); + log(Integer.toHexString((byteBuffer[curByteIndex++]) & 0xFF) + " "); } break; - + // handle define extended tag case SDEFINEX: log("SDEFINEX "); if (curByteIndex < byteBufferLimit) { - log(Integer.toHexString(((int) byteBuffer[curByteIndex++]) & 0xFF) + " "); + log(Integer.toHexString((byteBuffer[curByteIndex++]) & 0xFF) + " "); } if (curByteIndex < byteBufferLimit) { - log(Integer.toHexString(((int) byteBuffer[curByteIndex++]) & 0xFF) + " "); + log(Integer.toHexString((byteBuffer[curByteIndex++]) & 0xFF) + " "); } break; - + } // end switch } // end while break; - + case UNICODEMODE: while(curByteIndex < byteBufferLimit && mode == UNICODEMODE) { - aByte = ((int)byteBuffer[curByteIndex++]) & 0xFF; + aByte = (byteBuffer[curByteIndex++]) & 0xFF; switch(aByte) { // handle all define tags case UDEFINE0: case UDEFINE1: case UDEFINE2: case UDEFINE3: case UDEFINE4: case UDEFINE5: case UDEFINE6: case UDEFINE7: log("UDEFINE" + (aByte - UDEFINE0) + " "); if (curByteIndex < byteBufferLimit) { - log(Integer.toHexString(((int) byteBuffer[curByteIndex++]) & 0xFF) + " "); + log(Integer.toHexString((byteBuffer[curByteIndex++]) & 0xFF) + " "); } mode = SINGLEBYTEMODE; break; - + // handle define extended tag case UDEFINEX: log("UDEFINEX "); if (curByteIndex < byteBufferLimit) { - log(Integer.toHexString(((int) byteBuffer[curByteIndex++]) & 0xFF) + " "); + log(Integer.toHexString((byteBuffer[curByteIndex++]) & 0xFF) + " "); } if (curByteIndex < byteBufferLimit) { - log(Integer.toHexString(((int) byteBuffer[curByteIndex++]) & 0xFF) + " "); + log(Integer.toHexString((byteBuffer[curByteIndex++]) & 0xFF) + " "); } break; - + // handle all switch tags case USWITCH0: case USWITCH1: case USWITCH2: case USWITCH3: case USWITCH4: case USWITCH5: case USWITCH6: case USWITCH7: log("USWITCH" + (aByte - USWITCH0) + " "); mode = SINGLEBYTEMODE; break; - + // quote unicode case UQUOTEU: log("UQUOTEU "); if (curByteIndex < byteBufferLimit) { - log(Integer.toHexString(((int) byteBuffer[curByteIndex++]) & 0xFF) + " "); + log(Integer.toHexString((byteBuffer[curByteIndex++]) & 0xFF) + " "); } if (curByteIndex < byteBufferLimit) { - log(Integer.toHexString(((int) byteBuffer[curByteIndex++]) & 0xFF) + " "); + log(Integer.toHexString((byteBuffer[curByteIndex++]) & 0xFF) + " "); } break; - + default: - log(Integer.toHexString(((int) aByte) & 0xFF) + " "); + log(Integer.toHexString((aByte) & 0xFF) + " "); if (curByteIndex < byteBufferLimit) { - log(Integer.toHexString(((int) byteBuffer[curByteIndex++]) & 0xFF) + " "); + log(Integer.toHexString((byteBuffer[curByteIndex++]) & 0xFF) + " "); } break; - + } // end switch } // end while break; - + } // end switch( mode ) } // end while - + logln(""); - } + } } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/duration/DataReadWriteTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/duration/DataReadWriteTest.java index 89ffaf32055..762028e55c8 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/duration/DataReadWriteTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/duration/DataReadWriteTest.java @@ -15,11 +15,14 @@ import java.io.StringReader; import java.io.StringWriter; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.duration.impl.XMLRecordReader; import com.ibm.icu.impl.duration.impl.XMLRecordWriter; +@RunWith(JUnit4.class) public class DataReadWriteTest extends TestFmwk { // strip line ends and trailing spaces private String normalize(String str) { @@ -80,7 +83,7 @@ public class DataReadWriteTest extends TestFmwk { { true, false }, { true, false, true }, }; - + String[] targets = { "", "true", @@ -255,7 +258,7 @@ public class DataReadWriteTest extends TestFmwk { String s4 = " It is\n only a test\t "; String s4x = " It is only a test "; - String[][] datas = { + String[][] datas = { {}, { s1 }, { s2, s1 }, @@ -268,11 +271,11 @@ public class DataReadWriteTest extends TestFmwk { "", "" + s1 + "", "" + s2 + "" + s1 + "", - "" + s3 + "" + s2 + + "" + s3 + "" + s2 + "" + s1 + "", - "" + s3 + "Null" + s1 + + "" + s3 + "Null" + s1 + "Null", - "" + s4x + "" + s1 + + "" + s4x + "" + s1 + "" + s3 + "" + s2 + "", }; @@ -311,7 +314,7 @@ public class DataReadWriteTest extends TestFmwk { String s3 = "This is a test"; String s4 = "It is only a test"; - String[][] table = { + String[][] table = { {}, { s1 }, { s2, s1 }, @@ -324,7 +327,7 @@ public class DataReadWriteTest extends TestFmwk { "" + "" + " " + - "This is a test " + + "This is a test " + "" + "Null" + "It is only a test" + diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/duration/ICUDurationTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/duration/ICUDurationTest.java index 4d9d762d147..b3cf867f926 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/duration/ICUDurationTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/duration/ICUDurationTest.java @@ -20,6 +20,8 @@ import javax.xml.datatype.DatatypeConstants.Field; import javax.xml.datatype.Duration; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.DurationFormat; @@ -30,6 +32,7 @@ import com.ibm.icu.util.ULocale; * @author srl * */ +@RunWith(JUnit4.class) public class ICUDurationTest extends TestFmwk { /** * Allows us to not depend on javax.xml.datatype.DatatypeFactory. @@ -161,7 +164,7 @@ public class ICUDurationTest extends TestFmwk { } /** - * + * */ public ICUDurationTest() { } @@ -174,7 +177,7 @@ public class ICUDurationTest extends TestFmwk { DurationFormat df; String expect; String formatted; - + df = DurationFormat.getInstance(new ULocale("it")); formatted = df.formatDurationFromNow(4096); expect = "fra quattro secondi"; @@ -183,7 +186,7 @@ public class ICUDurationTest extends TestFmwk { } else { logln("format duration -> " + formatted); } - + formatted = df.formatDurationFromNowTo(new Date(0)); Calendar cal = Calendar.getInstance(); int years = cal.get(Calendar.YEAR) - 1970; // year of Date(0) @@ -193,7 +196,7 @@ public class ICUDurationTest extends TestFmwk { } else { logln("format date -> " + formatted); } - + formatted = df.formatDurationFrom(1000*3600*24, new Date(0).getTime()); expect = "fra un giorno"; if(!expect.equals(formatted)) { @@ -218,7 +221,7 @@ public class ICUDurationTest extends TestFmwk { String out; String expected; String expected2; - + // test 1 d = newDuration(1, 2, 46, 40); // "PT2H46M40S" df = DurationFormat.getInstance(new ULocale("en")); @@ -229,7 +232,7 @@ public class ICUDurationTest extends TestFmwk { } else { errln("FAIL: got " + out + " wanted " + expected + " from " + d); } - + // test 2 d = newDuration(10000); df = DurationFormat.getInstance(new ULocale("en")); @@ -313,7 +316,7 @@ public class ICUDurationTest extends TestFmwk { DurationFormat df = DurationFormat.getInstance(locale); String output = df.format(d); - + if(output.equals(to)) { logln("SUCCESS: locale: " + loc + ", from " + from + " ["+d.toString()+"] " +" to " + to + "= " + output); } else { @@ -364,7 +367,7 @@ public class ICUDurationTest extends TestFmwk { errln("FAIL: null DurationFormat returned."); } } - + /* Tests the class * DurationFormat */ @@ -372,14 +375,18 @@ public class ICUDurationTest extends TestFmwk { public void TestDurationFormat(){ @SuppressWarnings("serial") class TestDurationFormat extends DurationFormat { + @Override public StringBuffer format(Object object, StringBuffer toAppend, FieldPosition pos) {return null;} + @Override public String formatDurationFrom(long duration, long referenceDate) {return null;} + @Override public String formatDurationFromNow(long duration) {return null;} + @Override public String formatDurationFromNowTo(Date targetDate) {return null;} public TestDurationFormat() {super();} - + } - + // Tests the constructor and the following method // public Object parseObject(String source, ParsePosition pos) try{ diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/duration/LanguageTestFmwk.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/duration/LanguageTestFmwk.java index 56564ef3ed8..e20b0c2f5c2 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/duration/LanguageTestFmwk.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/duration/LanguageTestFmwk.java @@ -21,6 +21,8 @@ import java.util.List; import java.util.Map; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.duration.BasicPeriodFormatterService; @@ -37,10 +39,11 @@ import com.ibm.icu.impl.duration.impl.DataRecord.EUnitVariant; /** * Test cases for en */ +@RunWith(JUnit4.class) public abstract class LanguageTestFmwk extends TestFmwk implements TimeUnitConstants { private static final TimeUnit[] units = { - TimeUnit.YEAR, TimeUnit.MONTH, TimeUnit.WEEK, TimeUnit.DAY, TimeUnit.HOUR, + TimeUnit.YEAR, TimeUnit.MONTH, TimeUnit.WEEK, TimeUnit.DAY, TimeUnit.HOUR, TimeUnit.MINUTE, TimeUnit.SECOND, TimeUnit.MILLISECOND }; @@ -63,7 +66,7 @@ public abstract class LanguageTestFmwk extends TestFmwk implements TimeUnitConst private static final Map datacache = new HashMap(); // String->TestData private static final long[] approxDurations = { - 36525L*24*60*60*10, 3045*24*60*60*10L, 7*24*60*60*1000L, 24*60*60*1000L, + 36525L*24*60*60*10, 3045*24*60*60*10L, 7*24*60*60*1000L, 24*60*60*1000L, 60*60*1000L, 60*1000L, 1000L, 1L }; @@ -536,46 +539,57 @@ class FileTestData extends LanguageTestFmwk.TestData { private String[] fractionalUnitTargets; private String[] multipleUnitTargets; + @Override int[] getFullPluralizedFormCounts() { return fullPluralizedFormCounts; } + @Override String[] getFullPluralizedFormTargets() { return fullPluralizedFormTargets; } + @Override String[] getMediumFormTargets() { return mediumFormTargets; } + @Override String[] getShortFormTargets() { return shortFormTargets; } + @Override String[] getCustomMinuteTargets() { return customMinuteTargets; } + @Override String[] getLimitedUnitTargets() { return limitedUnitTargets; } + @Override int[] getHalfUnitCounts() { return halfUnitCounts; } + @Override String[] getHalfUnitTargets() { return halfUnitTargets; } + @Override float[] getFractionalUnitCounts() { return fractionalUnitCounts; } + @Override String[] getFractionalUnitTargets() { return fractionalUnitTargets; } + @Override String[] getMultipleUnitTargets() { return multipleUnitTargets; } @@ -695,46 +709,57 @@ class DefaultData extends LanguageTestFmwk.TestData { return instance; } + @Override int[] getFullPluralizedFormCounts() { return fullPluralizedFormCounts; } + @Override String[] getFullPluralizedFormTargets() { return null; } + @Override String[] getMediumFormTargets() { return null; } + @Override String[] getShortFormTargets() { return null; } + @Override String[] getCustomMinuteTargets() { return null; } + @Override String[] getLimitedUnitTargets() { return null; } + @Override int[] getHalfUnitCounts() { return halfUnitCounts; } + @Override String[] getHalfUnitTargets() { return null; } + @Override float[] getFractionalUnitCounts() { return fractionalUnitCounts; } + @Override String[] getFractionalUnitTargets() { return null; } + @Override String[] getMultipleUnitTargets() { return null; } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/duration/PeriodBuilderFactoryTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/duration/PeriodBuilderFactoryTest.java index 0d5adbf4853..fa98ad5c89e 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/duration/PeriodBuilderFactoryTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/duration/PeriodBuilderFactoryTest.java @@ -12,6 +12,8 @@ package com.ibm.icu.dev.test.duration; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.duration.BasicPeriodFormatterService; @@ -21,14 +23,15 @@ import com.ibm.icu.impl.duration.PeriodBuilderFactory; import com.ibm.icu.impl.duration.TimeUnit; import com.ibm.icu.impl.duration.TimeUnitConstants; +@RunWith(JUnit4.class) public class PeriodBuilderFactoryTest extends TestFmwk implements TimeUnitConstants { private PeriodBuilderFactory pbf; private static final long[] approxDurations = { - 36525L*24*60*60*10, 3045*24*60*60*10L, 7*24*60*60*1000L, 24*60*60*1000L, + 36525L*24*60*60*10, 3045*24*60*60*10L, 7*24*60*60*1000L, 24*60*60*1000L, 60*60*1000L, 60*1000L, 1000L, 1L }; - + @Test public void testSetAvailableUnitRange() { // sanity check, make sure by default all units are set @@ -86,7 +89,7 @@ public class PeriodBuilderFactoryTest extends TestFmwk implements TimeUnitConsta assertNotNull(null, pbf.getOneOrTwoUnitBuilder()); assertNotNull(null, pbf.getMultiUnitBuilder(2)); } - + @Test public void testBuilderFactoryPeriodConstruction() { // see ticket #8307 @@ -98,7 +101,7 @@ public class PeriodBuilderFactoryTest extends TestFmwk implements TimeUnitConsta assertEquals("hours", 1.0f, p.getCount(HOUR)); assertEquals("minutes", 35.501f, p.getCount(MINUTE)); assertFalse("seconds", p.isSet(SECOND)); - + pb = pbf.getMultiUnitBuilder(3); p = pb.create(H1M35S30M100); assertEquals("hours", 1.0f, p.getCount(HOUR)); diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/duration/PeriodTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/duration/PeriodTest.java index ae9a33ba847..bf9d3f7d766 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/duration/PeriodTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/duration/PeriodTest.java @@ -12,11 +12,14 @@ package com.ibm.icu.dev.test.duration; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.duration.Period; import com.ibm.icu.impl.duration.TimeUnit; +@RunWith(JUnit4.class) public class PeriodTest extends TestFmwk { @Test public void testIsSet() { diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/duration/RegressionTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/duration/RegressionTest.java index bf3b26f5897..973845bb662 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/duration/RegressionTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/duration/RegressionTest.java @@ -9,6 +9,8 @@ package com.ibm.icu.dev.test.duration; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.duration.BasicPeriodFormatterService; @@ -18,23 +20,24 @@ import com.ibm.icu.impl.duration.PeriodFormatterService; import com.ibm.icu.text.DurationFormat; import com.ibm.icu.util.ULocale; +@RunWith(JUnit4.class) public class RegressionTest extends TestFmwk { // bug6397 @Test public void TestDisallowedMillis() { // original test case - // if we don't support milliseconds, format times less than 1 second as + // if we don't support milliseconds, format times less than 1 second as // 'less than 1 second' { ULocale ul = new ULocale("th"); DurationFormat df = DurationFormat.getInstance(ul); String result = df.formatDurationFromNow(500); assertEquals( - "original test case", - "\u0E44\u0E21\u0E48\u0E16\u0E36\u0E07\u0E2D\u0E35\u0E01 1 \u0E27\u0E34\u0E19\u0E32\u0E17\u0E35", + "original test case", + "\u0E44\u0E21\u0E48\u0E16\u0E36\u0E07\u0E2D\u0E35\u0E01 1 \u0E27\u0E34\u0E19\u0E32\u0E17\u0E35", result); } - + // same issue, but using English and the internal APIs { PeriodFormatterService pfs = BasicPeriodFormatterService.getInstance(); @@ -49,10 +52,10 @@ public class RegressionTest extends TestFmwk { "english test case", "less than 1 second from now", result); - + } - - // if the limit is set on milliseconds, and they are not supported, + + // if the limit is set on milliseconds, and they are not supported, // use an effective limit based on seconds { PeriodFormatterService pfs = BasicPeriodFormatterService.getInstance(); diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/duration/ResourceBasedPeriodFormatterDataServiceTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/duration/ResourceBasedPeriodFormatterDataServiceTest.java index 97a412e033f..59dc9c26c0b 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/duration/ResourceBasedPeriodFormatterDataServiceTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/duration/ResourceBasedPeriodFormatterDataServiceTest.java @@ -15,11 +15,14 @@ import java.util.Collection; import java.util.Iterator; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.duration.impl.PeriodFormatterData; import com.ibm.icu.impl.duration.impl.ResourceBasedPeriodFormatterDataService; +@RunWith(JUnit4.class) public class ResourceBasedPeriodFormatterDataServiceTest extends TestFmwk { @Test public void testAvailable() { diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/BigNumberFormatTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/BigNumberFormatTest.java index 86946deea8a..649b7b5e2b8 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/BigNumberFormatTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/BigNumberFormatTest.java @@ -12,6 +12,8 @@ import java.text.ParseException; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.Utility; @@ -23,6 +25,7 @@ import com.ibm.icu.text.NumberFormat; * @test * General test of Big NumberFormat */ +@RunWith(JUnit4.class) public class BigNumberFormatTest extends TestFmwk { static final int ILLEGAL = -1; diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/CompactDecimalFormatTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/CompactDecimalFormatTest.java index 7e3f34e8131..cdc2694c39b 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/CompactDecimalFormatTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/CompactDecimalFormatTest.java @@ -25,6 +25,8 @@ import java.util.Locale; import java.util.Map; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.number.Properties; @@ -37,6 +39,7 @@ import com.ibm.icu.util.Currency; import com.ibm.icu.util.CurrencyAmount; import com.ibm.icu.util.ULocale; +@RunWith(JUnit4.class) public class CompactDecimalFormatTest extends TestFmwk { Object[][] EnglishTestData = { // default is 2 digits of accuracy diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateFormatMiscTests.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateFormatMiscTests.java index 8df8e871b71..0e02ab82c45 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateFormatMiscTests.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateFormatMiscTests.java @@ -7,7 +7,7 @@ ******************************************************************************* */ -/** +/** * Port From: ICU4C v1.8.1 : format : DateFormatMiscTests * Source File: $ICU4CRoot/source/test/intltest/miscdtfm.cpp **/ @@ -20,14 +20,18 @@ import java.util.Date; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.DateFormatSymbols; import com.ibm.icu.text.SimpleDateFormat; -/** +/** * Performs miscellaneous tests for DateFormat, SimpleDateFormat, DateFormatSymbols **/ -public class DateFormatMiscTests extends com.ibm.icu.dev.test.TestFmwk { +@RunWith(JUnit4.class) +public class DateFormatMiscTests extends TestFmwk { /* * @bug 4097450 */ @@ -38,13 +42,13 @@ public class DateFormatMiscTests extends com.ibm.icu.dev.test.TestFmwk { // String dstring[] = { "97", "1997", "97", "1997", "01", "2001", "01", "2001", - "1", "1", "11", "11", "111", "111"}; - - String dformat[] = + "1", "1", "11", "11", "111", "111"}; + + String dformat[] = { - "yy", "yy", "yyyy", "yyyy", "yy", "yy", "yyyy", "yyyy", - "yy", "yyyy", "yy", "yyyy", "yy", "yyyy"}; - + "yy", "yy", "yyyy", "yyyy", "yy", "yy", "yyyy", "yyyy", + "yy", "yyyy", "yy", "yyyy", "yy", "yyyy"}; + SimpleDateFormat formatter; SimpleDateFormat resultFormatter = new SimpleDateFormat("yyyy"); logln("Format\tSource\tResult"); @@ -55,7 +59,7 @@ public class DateFormatMiscTests extends com.ibm.icu.dev.test.TestFmwk { try { StringBuffer str = new StringBuffer(""); FieldPosition pos = new FieldPosition(0); - logln(resultFormatter.format(formatter.parse(dstring[i]), str, pos).toString()); + logln(resultFormatter.format(formatter.parse(dstring[i]), str, pos).toString()); } catch (ParseException exception) { errln("exception --> " + exception); @@ -63,7 +67,7 @@ public class DateFormatMiscTests extends com.ibm.icu.dev.test.TestFmwk { logln(""); } } - + /* @Bug 4099975 * SimpleDateFormat constructor SimpleDateFormat(String, DateFormatSymbols) * should clone the DateFormatSymbols parameter @@ -76,15 +80,15 @@ public class DateFormatMiscTests extends com.ibm.icu.dev.test.TestFmwk { DateFormatSymbols symbols = new DateFormatSymbols(Locale.US); SimpleDateFormat df = new SimpleDateFormat("E hh:mm", symbols); SimpleDateFormat dfClone = (SimpleDateFormat) df.clone(); - + logln(df.toLocalizedPattern()); String s0 = df.format(d); String s_dfClone = dfClone.format(d); - + symbols.setLocalPatternChars("abcdefghijklmonpqr"); // change value of field logln(df.toLocalizedPattern()); String s1 = df.format(d); - + if (!s1.equals(s0) || !s1.equals(s_dfClone)) { errln("Constructor: the formats are not equal"); } @@ -98,15 +102,15 @@ public class DateFormatMiscTests extends com.ibm.icu.dev.test.TestFmwk { SimpleDateFormat df = new SimpleDateFormat("E hh:mm"); df.setDateFormatSymbols(symbols); SimpleDateFormat dfClone = (SimpleDateFormat) df.clone(); - + logln(df.toLocalizedPattern()); String s0 = df.format(d); String s_dfClone = dfClone.format(d); - + symbols.setLocalPatternChars("abcdefghijklmonpqr"); // change value of field logln(df.toLocalizedPattern()); String s1 = df.format(d); - + if (!s1.equals(s0) || !s1.equals(s_dfClone)) { errln("setDateFormatSymbols: the formats are not equal"); } @@ -115,7 +119,7 @@ public class DateFormatMiscTests extends com.ibm.icu.dev.test.TestFmwk { } } } - + /* * @bug 4117335 */ diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateFormatRegressionTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateFormatRegressionTest.java index d3d1b3fc183..2d5645f3564 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateFormatRegressionTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateFormatRegressionTest.java @@ -7,7 +7,7 @@ ******************************************************************************* */ -/** +/** * Port From: ICU4C v1.8.1 : format : DateFormatRegressionTest * Source File: $ICU4CRoot/source/test/intltest/dtfmrgts.cpp **/ @@ -28,7 +28,10 @@ import java.util.Date; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.DateFormat; import com.ibm.icu.text.SimpleDateFormat; import com.ibm.icu.util.Calendar; @@ -39,10 +42,11 @@ import com.ibm.icu.util.SimpleTimeZone; import com.ibm.icu.util.TimeZone; import com.ibm.icu.util.ULocale; -/** +/** * Performs regression test for DateFormat **/ -public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { +@RunWith(JUnit4.class) +public class DateFormatRegressionTest extends TestFmwk { /** * @bug 4029195 */ @@ -58,7 +62,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { FieldPosition pos = new FieldPosition(0); fmtd = sdf.format(today, fmtd, pos); logln("today: " + fmtd); - + sdf.applyPattern("G yyyy DDD"); StringBuffer todayS = new StringBuffer(""); todayS = sdf.format(today, todayS, pos); @@ -69,7 +73,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { } catch (Exception e) { errln("Error reparsing date: " + e.getMessage()); } - + try { StringBuffer rt = new StringBuffer(""); rt = sdf.format(sdf.parse(todayS.toString()), rt, pos); @@ -81,24 +85,24 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { e.printStackTrace(); } } - + /** * @bug 4052408 */ @Test public void Test4052408() { - - DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.US); + + DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.US); Calendar cal = Calendar.getInstance(); cal.clear(); cal.set(97 + 1900, Calendar.MAY, 3, 8, 55); Date dt = cal.getTime(); String str = fmt.format(dt); logln(str); - + if (!str.equals("5/3/97, 8:55 AM")) errln("Fail: Test broken; Want 5/3/97, 8:55 AM Got " + str); - + String expected[] = { "", //"ERA_FIELD", "97", //"YEAR_FIELD", @@ -118,27 +122,27 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { "8", //"HOUR1_FIELD", "", //"HOUR0_FIELD", "" //"TIMEZONE_FIELD" - }; + }; String fieldNames[] = { - "ERA_FIELD", - "YEAR_FIELD", - "MONTH_FIELD", - "DATE_FIELD", - "HOUR_OF_DAY1_FIELD", - "HOUR_OF_DAY0_FIELD", - "MINUTE_FIELD", - "SECOND_FIELD", - "MILLISECOND_FIELD", - "DAY_OF_WEEK_FIELD", - "DAY_OF_YEAR_FIELD", - "DAY_OF_WEEK_IN_MONTH_FIELD", - "WEEK_OF_YEAR_FIELD", - "WEEK_OF_MONTH_FIELD", - "AM_PM_FIELD", - "HOUR1_FIELD", - "HOUR0_FIELD", - "TIMEZONE_FIELD"}; - + "ERA_FIELD", + "YEAR_FIELD", + "MONTH_FIELD", + "DATE_FIELD", + "HOUR_OF_DAY1_FIELD", + "HOUR_OF_DAY0_FIELD", + "MINUTE_FIELD", + "SECOND_FIELD", + "MILLISECOND_FIELD", + "DAY_OF_WEEK_FIELD", + "DAY_OF_YEAR_FIELD", + "DAY_OF_WEEK_IN_MONTH_FIELD", + "WEEK_OF_YEAR_FIELD", + "WEEK_OF_MONTH_FIELD", + "AM_PM_FIELD", + "HOUR1_FIELD", + "HOUR0_FIELD", + "TIMEZONE_FIELD"}; + boolean pass = true; for (int i = 0; i <= 17; ++i) { FieldPosition pos = new FieldPosition(i); @@ -148,7 +152,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { String dst = buf.substring(pos.getBeginIndex(), pos.getEndIndex()); str = dst; log(i + ": " + fieldNames[i] + ", \"" + str + "\", " - + pos.getBeginIndex() + ", " + pos.getEndIndex()); + + pos.getBeginIndex() + ", " + pos.getEndIndex()); String exp = expected[i]; if ((exp.length() == 0 && str.length() == 0) || str.equals(exp)) logln(" ok"); @@ -160,14 +164,14 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { if (!pass) errln("Fail: FieldPosition not set right by DateFormat"); } - + /** * @bug 4056591 * Verify the function of the [s|g]et2DigitYearStart() API. */ @Test public void Test4056591() { - + try { SimpleDateFormat fmt = new SimpleDateFormat("yyMMdd", Locale.US); Calendar cal = Calendar.getInstance(); @@ -189,11 +193,11 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { cal.clear(); cal.set(1861, Calendar.DECEMBER, 25); Date d4 = cal.getTime(); - + Date dates[] = {d1, d2, d3, d4}; - - String strings[] = {"091225", "091224", "091226", "611225"}; - + + String strings[] = {"091225", "091224", "091226", "611225"}; + for (int i = 0; i < 4; i++) { String s = strings[i]; Date exp = dates[i]; @@ -207,40 +211,40 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { e.printStackTrace(); } } - + /** * @bug 4059917 */ @Test - public void Test4059917() { + public void Test4059917() { SimpleDateFormat fmt; String myDate; fmt = new SimpleDateFormat("yyyy/MM/dd"); myDate = "1997/01/01"; - aux917( fmt, myDate ); + aux917( fmt, myDate ); fmt = new SimpleDateFormat("yyyyMMdd"); myDate = "19970101"; aux917( fmt, myDate ); } - + public void aux917(SimpleDateFormat fmt, String str) { - + String pat = fmt.toPattern(); logln("=================="); logln("testIt: pattern=" + pat + " string=" + str); ParsePosition pos = new ParsePosition(0); Object o = fmt.parseObject(str, pos); //logln( UnicodeString("Parsed object: ") + o ); - + StringBuffer formatted = new StringBuffer(""); FieldPosition poss = new FieldPosition(0); formatted = fmt.format(o, formatted, poss); - + logln("Formatted string: " + formatted); if (!formatted.toString().equals(str)) errln("Fail: Want " + str + " Got " + formatted); } - + /** * @bug 4060212 */ @@ -252,14 +256,14 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-DDD.hh:mm:ss"); ParsePosition pos = new ParsePosition(0); Date myDate = formatter.parse(dateString, pos); - DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.LONG); + DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.LONG); String myString = fmt.format(myDate); logln(myString); Calendar cal = new GregorianCalendar(); cal.setTime(myDate); if ((cal.get(Calendar.DAY_OF_YEAR) != 40)) errln("Fail: Got " + cal.get(Calendar.DAY_OF_YEAR) + " Want 40"); - + logln("Using yyyy-ddd.hh:mm:ss"); formatter = new SimpleDateFormat("yyyy-ddd.hh:mm:ss"); pos.setIndex(0); @@ -275,7 +279,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { */ @Test public void Test4061287() { - + SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy"); try { logln(df.parse("35/01/1971").toString()); @@ -293,7 +297,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { if (!ok) errln("Fail: Lenient not working"); } - + /** * @bug 4065240 */ @@ -304,7 +308,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { String strShortDate, strFullDate; Locale saveLocale = Locale.getDefault(); TimeZone saveZone = TimeZone.getDefault(); - + try { Locale curLocale = new Locale("de", "DE"); Locale.setDefault(curLocale); @@ -324,16 +328,16 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { strFullDate = "The current date (long form) is "; String temp2 = fulldate.format(curDate); strFullDate += temp2; - + logln(strShortDate); logln(strFullDate); - + // {sfb} What to do with resource bundle stuff????? - + // Check to see if the resource is present; if not, we can't test //ResourceBundle bundle = //The variable is never used - // ICULocaleData.getBundle("DateFormatZoneData", curLocale); - + // ICULocaleData.getBundle("DateFormatZoneData", curLocale); + // {sfb} API change to ResourceBundle -- add getLocale() /*if (bundle.getLocale().getLanguage().equals("de")) { // UPDATE THIS AS ZONE NAME RESOURCE FOR in de_DE is updated @@ -349,16 +353,16 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { Locale.setDefault(saveLocale); TimeZone.setDefault(saveZone); } - + } - + /* DateFormat.equals is too narrowly defined. As a result, MessageFormat does not work correctly. DateFormat.equals needs to be written so that the Calendar sub-object is not compared using Calendar.equals, but rather compared for equivalency. This may necessitate adding a (package private) method to Calendar to test for equivalency. - + Currently this bug breaks MessageFormat.toPattern */ /** @@ -368,7 +372,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { public void Test4071441() { DateFormat fmtA = DateFormat.getInstance(); DateFormat fmtB = DateFormat.getInstance(); - + // {sfb} Is it OK to cast away const here? Calendar calA = fmtA.getCalendar(); Calendar calB = fmtB.getCalendar(); @@ -388,14 +392,14 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { errln("Fail: DateFormat unequal when Calendars equivalent"); logln("DateFormat.equals ok"); } - + /* The java.text.DateFormat.parse(String) method expects for the US locale a string formatted according to mm/dd/yy and parses it correctly. - + When given a string mm/dd/yyyy it only parses up to the first two y's, typically resulting in a date in the year 1919. - + Please extend the parsing method(s) to handle strings with four-digit year values (probably also applicable to various other locales. */ @@ -423,9 +427,9 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { } catch (ParseException e) { errln("Fail: " + e); e.printStackTrace(); - } + } } - + /** * @bug 4089106 */ @@ -442,24 +446,24 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { TimeZone.setDefault(def); } } - + /** * @bug 4100302 */ @Test public void Test4100302() { - + Locale locales[] = { - Locale.CANADA, Locale.CANADA_FRENCH, Locale.CHINA, - Locale.CHINESE, Locale.ENGLISH, Locale.FRANCE, Locale.FRENCH, - Locale.GERMAN, Locale.GERMANY, Locale.ITALIAN, Locale.ITALY, - Locale.JAPAN, Locale.JAPANESE, Locale.KOREA, Locale.KOREAN, - Locale.PRC, Locale.SIMPLIFIED_CHINESE, Locale.TAIWAN, - Locale.TRADITIONAL_CHINESE, Locale.UK, Locale.US}; + Locale.CANADA, Locale.CANADA_FRENCH, Locale.CHINA, + Locale.CHINESE, Locale.ENGLISH, Locale.FRANCE, Locale.FRENCH, + Locale.GERMAN, Locale.GERMANY, Locale.ITALIAN, Locale.ITALY, + Locale.JAPAN, Locale.JAPANESE, Locale.KOREA, Locale.KOREAN, + Locale.PRC, Locale.SIMPLIFIED_CHINESE, Locale.TAIWAN, + Locale.TRADITIONAL_CHINESE, Locale.UK, Locale.US}; try { boolean pass = true; for (int i = 0; i < 21; i++) { - Format format = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, locales[i]); + Format format = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, locales[i]); byte[] bytes; ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); @@ -471,7 +475,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { Object o = ois.readObject(); if (!format.equals(o)) { pass = false; - logln("DateFormat instance for locale " + locales[i] + " is incorrectly serialized/deserialized."); + logln("DateFormat instance for locale " + locales[i] + " is incorrectly serialized/deserialized."); } else { logln("DateFormat instance for locale " + locales[i] + " is OKAY."); } @@ -485,9 +489,9 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { } catch (ClassNotFoundException e) { errln("Fail: " + e); } - + } - + /** * @bug 4101483 */ @@ -504,7 +508,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { if (fp.getBeginIndex() == fp.getEndIndex()) errln("Fail: Empty field"); } - + /** * @bug 4103340 * @bug 4138203 @@ -515,25 +519,25 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { */ @Test public void Test4103340() { - - // choose a date that is the FIRST of some month + + // choose a date that is the FIRST of some month // and some arbitrary time Calendar cal = Calendar.getInstance(); cal.clear(); cal.set(1997, 3, 1, 1, 1, 1); - Date d = cal.getTime(); + Date d = cal.getTime(); SimpleDateFormat df = new SimpleDateFormat("MMMM", Locale.US); String s = d.toString(); StringBuffer s2 = new StringBuffer(""); FieldPosition pos = new FieldPosition(0); s2 = df.format(d, s2, pos); - logln("Date=" + s); + logln("Date=" + s); logln("DF=" + s2); String substr = s2.substring(0,2); if (s.indexOf(substr) == -1) errln("Months should match"); } - + /** * @bug 4103341 */ @@ -551,7 +555,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { TimeZone.setDefault(saveZone); } } - + /** * @bug 4104136 */ @@ -582,7 +586,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { errln( "Fail: Expected result " + exp); } } - + /** * @bug 4104522 * CANNOT REPRODUCE @@ -605,9 +609,9 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { pp.setIndex(0); text = "time"; dt = sdf.parse(text, pp); - logln(" text: \"" + text + "\"" + " date: " + dt); + logln(" text: \"" + text + "\"" + " date: " + dt); } - + /** * @bug 4106807 */ @@ -615,19 +619,19 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { public void Test4106807() { Date dt; DateFormat df = DateFormat.getDateTimeInstance(); - + SimpleDateFormat sdfs[] = { - new SimpleDateFormat("yyyyMMddHHmmss"), - new SimpleDateFormat("yyyyMMddHHmmss'Z'"), - new SimpleDateFormat("yyyyMMddHHmmss''"), - new SimpleDateFormat("yyyyMMddHHmmss'a''a'"), - new SimpleDateFormat("yyyyMMddHHmmss %")}; + new SimpleDateFormat("yyyyMMddHHmmss"), + new SimpleDateFormat("yyyyMMddHHmmss'Z'"), + new SimpleDateFormat("yyyyMMddHHmmss''"), + new SimpleDateFormat("yyyyMMddHHmmss'a''a'"), + new SimpleDateFormat("yyyyMMddHHmmss %")}; String strings[] = { - "19980211140000", - "19980211140000", - "19980211140000", - "19980211140000a", - "19980211140000 "}; + "19980211140000", + "19980211140000", + "19980211140000", + "19980211140000a", + "19980211140000 "}; GregorianCalendar gc = new GregorianCalendar(); TimeZone timeZone = TimeZone.getDefault(); TimeZone gmt = (TimeZone) timeZone.clone(); @@ -639,12 +643,12 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { format.setTimeZone(gmt); dt = format.parse(dateString); // {sfb} some of these parses will fail purposely - + StringBuffer fmtd = new StringBuffer(""); FieldPosition pos = new FieldPosition(0); fmtd = df.format(dt, fmtd, pos); logln(fmtd.toString()); - //logln(df.format(dt)); + //logln(df.format(dt)); gc.setTime(dt); logln("" + gc.get(Calendar.ZONE_OFFSET)); StringBuffer s = new StringBuffer(""); @@ -655,35 +659,35 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { } } } - + /* Synopsis: Chinese time zone CTT is not recogonized correctly. - Description: Platform Chinese Windows 95 - ** Time zone set to CST ** + Description: Platform Chinese Windows 95 - ** Time zone set to CST ** */ /** * @bug 4108407 */ - - // {sfb} what to do with this one ?? + + // {sfb} what to do with this one ?? @Test public void Test4108407() { /* // TODO user.timezone is a protected system property, catch securityexception and warn // if this is reenabled - long l = System.currentTimeMillis(); + long l = System.currentTimeMillis(); logln("user.timezone = " + System.getProperty("user.timezone", "?")); - logln("Time Zone :" + - DateFormat.getDateInstance().getTimeZone().getID()); - logln("Default format :" + - DateFormat.getDateInstance().format(new Date(l))); - logln("Full format :" + - DateFormat.getDateInstance(DateFormat.FULL).format(new - Date(l))); + logln("Time Zone :" + + DateFormat.getDateInstance().getTimeZone().getID()); + logln("Default format :" + + DateFormat.getDateInstance().format(new Date(l))); + logln("Full format :" + + DateFormat.getDateInstance(DateFormat.FULL).format(new + Date(l))); logln("*** Set host TZ to CST ***"); logln("*** THE RESULTS OF THIS TEST MUST BE VERIFIED MANUALLY ***"); */ } - + /** * @bug 4134203 * SimpleDateFormat won't parse "GMT" @@ -692,7 +696,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { public void Test4134203() { String dateFormat = "MM/dd/yy HH:mm:ss zzz"; SimpleDateFormat fmt = new SimpleDateFormat(dateFormat); - + ParsePosition p0 = new ParsePosition(0); Date d = fmt.parse("01/22/92 04:52:00 GMT", p0); logln(d.toString()); @@ -701,15 +705,15 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { // In the failure case an exception is thrown by parse(); // if no exception is thrown, the test passes. } - + /** * @bug 4151631 * SimpleDateFormat incorrect handling of 2 single quotes in format() */ @Test public void Test4151631() { - String pattern = - "'TO_DATE('''dd'-'MM'-'yyyy HH:mm:ss''' , ''DD-MM-YYYY HH:MI:SS'')'"; + String pattern = + "'TO_DATE('''dd'-'MM'-'yyyy HH:mm:ss''' , ''DD-MM-YYYY HH:MI:SS'')'"; logln("pattern=" + pattern); SimpleDateFormat format = new SimpleDateFormat(pattern, Locale.US); StringBuffer result = new StringBuffer(""); @@ -718,14 +722,14 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { cal.clear(); cal.set(1998, Calendar.JUNE, 30, 13, 30, 0); Date d = cal.getTime(); - result = format.format(d, result, pos); + result = format.format(d, result, pos); if (!result.toString().equals("TO_DATE('30-06-1998 13:30:00' , 'DD-MM-YYYY HH:MI:SS')")) { errln("Fail: result=" + result); } else { logln("Pass: result=" + result); } } - + /** * @bug 4151706 * 'z' at end of date format throws index exception in SimpleDateFormat @@ -751,7 +755,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { FieldPosition pos = new FieldPosition(0); logln(dateString + " . " + fmt.format(d, temp, pos)); } - + /** * @bug 4162071 * Cannot reproduce this bug under 1.2 FCS -- it may be a convoluted duplicate @@ -771,7 +775,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { errln("Parse format \"" + format + "\" failed."); } } - + /** * DateFormat shouldn't parse year "-1" as a two-digit year (e.g., "-1" . 1999). */ @@ -784,10 +788,10 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { * greater than "99", are treated as literal years. So "1/2/3456" * becomes 3456 AD. Likewise, "1/2/-3" becomes -3 AD == 2 BC. */ - final String STRINGS[] = - {"02/29/00", "01/23/01", "04/05/-1", "01/23/-9", "11/12/1314", "10/31/1", "09/12/+1", "09/12/001",}; + final String STRINGS[] = + {"02/29/00", "01/23/01", "04/05/-1", "01/23/-9", "11/12/1314", "10/31/1", "09/12/+1", "09/12/001",}; int STRINGS_COUNT = STRINGS.length; - + Calendar cal = Calendar.getInstance(); Date FAIL_DATE = cal.getTime(); cal.clear(); @@ -808,16 +812,16 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { cal.clear(); cal.set(1, Calendar.OCTOBER, 31); Date d5 = cal.getTime(); - cal.clear(); + cal.clear(); cal.set(1, Calendar.SEPTEMBER, 12); Date d7 = cal.getTime(); Date DATES[] = {d0, d1, d2, d3, d4, d5, FAIL_DATE, d7}; - + String out = ""; boolean pass = true; for (int i = 0; i < STRINGS_COUNT; ++i) { String str = STRINGS[i]; - Date expected = DATES[i]; + Date expected = DATES[i]; Date actual = null; try { actual = fmt.parse(str); @@ -831,7 +835,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { // Yuck: See j25 actStr = ((DateFormat) dispFmt).format(actual); } - + if (expected.getTime() == (actual.getTime())) { out += str + " => " + actStr + "\n"; } else { @@ -852,18 +856,18 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { err(out); } } - + /** * j32 {JDK Bug 4210209 4209272} * DateFormat cannot parse Feb 29 2000 when setLenient(false) */ @Test public void Test4210209() { - + String pattern = "MMM d, yyyy"; DateFormat fmt = new SimpleDateFormat(pattern, Locale.US); DateFormat disp = new SimpleDateFormat("MMM dd yyyy GG", Locale.US); - + Calendar calx = fmt.getCalendar(); calx.setLenient(false); Calendar calendar = Calendar.getInstance(); @@ -880,7 +884,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { if (pos.getErrorIndex() != -1) { errln("FAIL: Error index should be -1"); } - + // The underlying bug is in GregorianCalendar. If the following lines // succeed, the bug is fixed. If the bug isn't fixed, they will throw // an exception. @@ -891,7 +895,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { d = cal.getTime(); logln("Attempt to set Calendar to Feb 29 2000: " + disp.format(d)); } - + @Test public void Test714() { //TimeZone Offset @@ -982,7 +986,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { logln(what + "=" + s); first = s.charAt(0); if(first(kHindiZero+9)) { - errln(what + "- wrong digit, got " + s + " (integer digit value " + new Integer((int)first).toString()); + errln(what + "- wrong digit, got " + s + " (integer digit value " + new Integer(first).toString()); } } @@ -993,7 +997,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { logln(what + ": " + s); first = s.charAt(0); if(first(kArabicZero+9)) { - errln(what + " wrong digit, got " + s + " (integer digit value " + new Integer((int)first).toString()); + errln(what + " wrong digit, got " + s + " (integer digit value " + new Integer(first).toString()); } } @@ -1004,7 +1008,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { logln(what + ": " + s); first = s.charAt(0); if(first(kArabicZero+9)) { - errln(what + " wrong digit but got " + s + " (integer digit value " + new Integer((int)first).toString()); + errln(what + " wrong digit but got " + s + " (integer digit value " + new Integer(first).toString()); } } { @@ -1014,7 +1018,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { logln(what + ": " + s); first = s.charAt(0); if(first(kLatinZero+9)) { - errln(what + " wrong digit but got " + s + " (integer digit value " + new Integer((int)first).toString()); + errln(what + " wrong digit but got " + s + " (integer digit value " + new Integer(first).toString()); } } @@ -1025,7 +1029,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { logln(what+ ": " + s); first = s.charAt(0); if(first(kArabicZero+9)) { - errln(what + " wrong digit but got " + s + " (integer digit value " + new Integer((int)first).toString()); + errln(what + " wrong digit but got " + s + " (integer digit value " + new Integer(first).toString()); } } @@ -1036,7 +1040,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { logln(what+ ": " + s); first = s.charAt(0); if(first(kArabicZero+9)) { - errln(what + " wrong digit but got " + s + " (integer digit value " + new Integer((int)first).toString()); + errln(what + " wrong digit but got " + s + " (integer digit value " + new Integer(first).toString()); } } @@ -1047,7 +1051,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { logln(what+ ": " + s); first = s.charAt(0); if(first(kArabicZero+9)) { - errln(what + " wrong digit but got " + s + " (integer digit value " + new Integer((int)first).toString()); + errln(what + " wrong digit but got " + s + " (integer digit value " + new Integer(first).toString()); } } } @@ -1138,7 +1142,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { String twelfthMonthLocalizedCivil = shortMonthsCivil[11]; islamicCivilTwelfthMonthLocalized[i] = twelfthMonthLocalizedCivil; - + com.ibm.icu.util.IslamicCalendar islamicCalendar = new com.ibm.icu.util.IslamicCalendar(locale); islamicCalendar.setCivil(false); com.ibm.icu.text.SimpleDateFormat islamicDateFormat = (com.ibm.icu.text.SimpleDateFormat) islamicCalendar @@ -1195,7 +1199,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { } } } - + @Test public void TestParsing() { String pattern = "EEE-WW-MMMM-yyyy"; @@ -1205,7 +1209,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { SimpleDateFormat format = new SimpleDateFormat(pattern); Calendar cal = GregorianCalendar.getInstance(Locale.US); ParsePosition pos = new ParsePosition(0); - + try { format.parse(text, cal, pos); } catch (Exception e) { @@ -1231,7 +1235,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { String dangiDateStr = fmt.format(d); assertEquals("Bad date format", "Mo1 20, 2013", dangiDateStr); } - + @Test public void TestT10110() { try { @@ -1250,7 +1254,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { @Test public void TestT10239() { - + class TestDateFormatItem { public String parseString; public String pattern; @@ -1262,7 +1266,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { expectedResult = expResult; } }; - + final TestDateFormatItem[] items = { // parse String pattern expected result new TestDateFormatItem("1 Oct 13 2013", "e MMM dd yyyy", "1 Oct 13 2013"), @@ -1277,7 +1281,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { StringBuffer result = new StringBuffer(); Date d = new Date(); - Calendar cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT"), Locale.US); + Calendar cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT"), Locale.US); SimpleDateFormat sdfmt = new SimpleDateFormat(); ParsePosition p = new ParsePosition(0); for (TestDateFormatItem item: items) { @@ -1307,7 +1311,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { } } } - + @Test public void TestT10334() { @@ -1315,11 +1319,11 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { String text = new String("--mon-02-march-2011"); SimpleDateFormat format = new SimpleDateFormat(pattern); - format.setBooleanAttribute(DateFormat.BooleanAttribute.PARSE_PARTIAL_LITERAL_MATCH, false); + format.setBooleanAttribute(DateFormat.BooleanAttribute.PARSE_PARTIAL_LITERAL_MATCH, false); try { format.parse(text); errln("parse partial match did NOT fail in strict mode!"); - } catch (ParseException pe) { + } catch (ParseException pe) { // expected } @@ -1335,7 +1339,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { format.applyPattern(pattern); Date referenceDate = null; try { - referenceDate = format.parse(text); + referenceDate = format.parse(text); } catch (ParseException pe) { errln("unable to instantiate reference date: " + pe.getLocalizedMessage()); } @@ -1343,7 +1347,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { FieldPosition fp = new FieldPosition(0); pattern = new String("YYYY LL dd ee cc qq QQ"); format.applyPattern(pattern); - StringBuffer formattedString = new StringBuffer(); + StringBuffer formattedString = new StringBuffer(); formattedString = format.format(referenceDate, formattedString, fp); logln("ref date: " + formattedString); @@ -1352,13 +1356,13 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { text = new String("2013 12 10 03 3 04 04"); format.applyPattern(pattern); logln(format.format(referenceDate)); - + format.setBooleanAttribute(DateFormat.BooleanAttribute.PARSE_ALLOW_NUMERIC, true); ParsePosition pp = new ParsePosition(0); format.parse(text, pp); int errorIdx = pp.getErrorIndex(); if (errorIdx != -1) { - + errln("numeric parse error at["+errorIdx+"] on char["+pattern.substring(errorIdx, errorIdx+1)+"] in pattern["+pattern+"]"); } @@ -1369,7 +1373,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { } catch (ParseException pe) { // expected } - + /* * test to verify new code (and improve code coverage) for normal quarter processing */ @@ -1384,7 +1388,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { @Test public void TestT10619() { - + class TestDateFormatLeniencyItem { public boolean leniency; public String parseString; @@ -1412,7 +1416,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { StringBuffer result = new StringBuffer(); Date d = new Date(); - Calendar cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT"), Locale.US); + Calendar cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT"), Locale.US); SimpleDateFormat sdfmt = new SimpleDateFormat(); ParsePosition p = new ParsePosition(0); for (TestDateFormatLeniencyItem item: items) { @@ -1443,7 +1447,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { } } } - + @Test public void TestT10906() { @@ -1454,7 +1458,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { try { format.parse(text, pp); int errorIdx = pp.getErrorIndex(); - if (errorIdx == -1) { + if (errorIdx == -1) { errln("failed to report invalid (negative) starting parse position"); } } catch(StringIndexOutOfBoundsException e) { @@ -1476,6 +1480,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { this.d = d; } + @Override public void run() { String s0 = fmt.format(d); for (int i = 0; i < 1000; i++) { diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateFormatRegressionTestJ.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateFormatRegressionTestJ.java index 922507739fa..a797a877108 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateFormatRegressionTestJ.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateFormatRegressionTestJ.java @@ -20,31 +20,35 @@ import java.util.Locale; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.DateFormat; import com.ibm.icu.text.DateFormatSymbols; import com.ibm.icu.text.SimpleDateFormat; import com.ibm.icu.util.Calendar; import com.ibm.icu.util.TimeZone; -public class DateFormatRegressionTestJ extends com.ibm.icu.dev.test.TestFmwk { - +@RunWith(JUnit4.class) +public class DateFormatRegressionTestJ extends TestFmwk { + private static final String TIME_STRING = "2000/11/17 08:01:00"; private static final long UTC_LONG = 974476860000L; private SimpleDateFormat sdf_; - + @Before public void init()throws Exception { - sdf_ = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); + sdf_ = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); } - + //Return value of getAmPmStrings @Test public void Test4103926() { String act_Ampms[]; String exp_Ampms[]={"AM","PM"}; Locale.setDefault(Locale.US); - + DateFormatSymbols dfs = new DateFormatSymbols(); act_Ampms = dfs.getAmPmStrings(); if(act_Ampms.length != exp_Ampms.length) { @@ -57,24 +61,24 @@ public class DateFormatRegressionTestJ extends com.ibm.icu.dev.test.TestFmwk { } } - // Missing digit in millisecond format in SimpleDateFormat + // Missing digit in millisecond format in SimpleDateFormat @Test public void Test4148168() { Date d = new Date(1002705212906L); String[] ISOPattern = { - "''yyyy-MM-dd-hh.mm.ss.S''", "''yyyy-MM-dd-hh.mm.ss.SS''", - "''yyyy-MM-dd-hh.mm.ss.SSS''", "''yyyy-MM-dd-hh.mm.ss.SSSS''", - "''yyyy-MM-dd-hh.mm.ss.SSSSS''", "''yyyy-MM-dd-hh.mm.ss.SSSSSS''", + "''yyyy-MM-dd-hh.mm.ss.S''", "''yyyy-MM-dd-hh.mm.ss.SS''", + "''yyyy-MM-dd-hh.mm.ss.SSS''", "''yyyy-MM-dd-hh.mm.ss.SSSS''", + "''yyyy-MM-dd-hh.mm.ss.SSSSS''", "''yyyy-MM-dd-hh.mm.ss.SSSSSS''", "''yyyy-MM-dd-hh.mm.ss.SSSSSSS''", "''yyyy-MM-dd-hh.mm.ss.SSS000''"}; SimpleDateFormat aSimpleDF = (SimpleDateFormat)DateFormat.getDateTimeInstance(); - + for(int i = 0; i" + str); - + d = sdf.parse(str, new ParsePosition(0)); logln(" after parse----->" + d.toString()); - + str = sdf.format(d); logln(" after format----->" + str); - + d = sdf.parse(str, new ParsePosition(0)); logln(" after parse----->" + d.toString()); - + str = sdf.format(d); - logln(" after format----->" + str); + logln(" after format----->" + str); } } - + //Class used by Test4407042 class DateParseThread extends Thread { + @Override public void run() { SimpleDateFormat sdf = (SimpleDateFormat) sdf_.clone(); TimeZone defaultTZ = TimeZone.getDefault(); @@ -272,7 +277,7 @@ public class DateFormatRegressionTestJ extends com.ibm.icu.dev.test.TestFmwk { long t = date.getTime(); i++; if (t != ms) { - throw new ParseException("Parse Error: " + i + " (" + sdf.format(date) + throw new ParseException("Parse Error: " + i + " (" + sdf.format(date) + ") " + t + " != " + ms, 0); } } @@ -281,10 +286,11 @@ public class DateFormatRegressionTestJ extends com.ibm.icu.dev.test.TestFmwk { } } } - + //Class used by Test4407042 class DateFormatThread extends Thread { - public void run() { + @Override + public void run() { SimpleDateFormat sdf = (SimpleDateFormat) sdf_.clone(); TimeZone tz = TimeZone.getTimeZone("PST"); sdf.setTimeZone(tz); @@ -293,11 +299,11 @@ public class DateFormatRegressionTestJ extends com.ibm.icu.dev.test.TestFmwk { i++; String s = sdf.format(new Date(UTC_LONG)); if (!s.equals(TIME_STRING)) { - errln("Format Error: " + i + " " + s + " != " + errln("Format Error: " + i + " " + s + " != " + TIME_STRING); } } } } - + } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateFormatRoundTripTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateFormatRoundTripTest.java index ff515fdfaf4..35044f5056c 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateFormatRoundTripTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateFormatRoundTripTest.java @@ -21,7 +21,10 @@ import java.util.Locale; import java.util.Random; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.DateFormat; import com.ibm.icu.text.SimpleDateFormat; import com.ibm.icu.util.Calendar; @@ -31,7 +34,8 @@ import com.ibm.icu.util.TimeZone; /** * Performs round-trip tests for DateFormat **/ -public class DateFormatRoundTripTest extends com.ibm.icu.dev.test.TestFmwk { +@RunWith(JUnit4.class) +public class DateFormatRoundTripTest extends TestFmwk { public boolean INFINITE = false; public boolean quick = true; private SimpleDateFormat dateFormat; diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateFormatTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateFormatTest.java index c3de66d88d7..fdd9dded4b1 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateFormatTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateFormatTest.java @@ -37,7 +37,10 @@ import java.util.ResourceBundle; import java.util.Set; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.ICUData; import com.ibm.icu.impl.ICUResourceBundle; import com.ibm.icu.text.ChineseDateFormat; @@ -63,7 +66,8 @@ import com.ibm.icu.util.ULocale; import com.ibm.icu.util.UResourceBundle; import com.ibm.icu.util.VersionInfo; -public class DateFormatTest extends com.ibm.icu.dev.test.TestFmwk { +@RunWith(JUnit4.class) +public class DateFormatTest extends TestFmwk { /** * Verify that patterns have the correct values and could produce the * the DateFormat instances that contain the correct localized patterns. @@ -2394,9 +2398,9 @@ public class DateFormatTest extends com.ibm.icu.dev.test.TestFmwk { f.format((Object)cal, buf, pos); f.format((Object)now, buf, pos); - f.format((Object)new Long(now.getTime()), buf, pos); + f.format(new Long(now.getTime()), buf, pos); try { - f.format((Object)"Howdy", buf, pos); + f.format("Howdy", buf, pos); } catch (Exception e) { } @@ -4000,7 +4004,7 @@ public class DateFormatTest extends com.ibm.icu.dev.test.TestFmwk { String expected = data[i + 1]; if (!out.equals(expected)) { - errln((String)"FAIL: " + in + " -> " + out + " expected -> " + expected); + errln("FAIL: " + in + " -> " + out + " expected -> " + expected); } } } @@ -4023,7 +4027,7 @@ public class DateFormatTest extends com.ibm.icu.dev.test.TestFmwk { String res1 = result.toString(); String expected = "\u4e8c\u3007\u3007\u4e5d\u5e74\u4e03\u6708\u4e8c\u5341\u516b\u65e5"; if (! res1.equals(expected)) { - errln((String)"FAIL: -> " + result.toString() + " expected -> " + expected); + errln("FAIL: -> " + result.toString() + " expected -> " + expected); } ParsePosition pp = new ParsePosition(0); Date parsedate = sdf.parse(expected, pp); @@ -4090,7 +4094,7 @@ public class DateFormatTest extends com.ibm.icu.dev.test.TestFmwk { String expected = DATA[i][1]; if (!result.equals(expected)) - errln((String) "FAIL: -> " + result.toString() + " expected -> " + expected); + errln("FAIL: -> " + result.toString() + " expected -> " + expected); } } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateIntervalFormatTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateIntervalFormatTest.java index 859bc1bdaed..ec22af2cbee 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateIntervalFormatTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateIntervalFormatTest.java @@ -8,7 +8,7 @@ ******************************************************************************* */ -/** +/** * Port From: ICU4C v1.8.1 : format : DateIntervalFormatTest * Source File: $ICU4CRoot/source/test/intltest/dtifmtts.cpp **/ @@ -25,6 +25,8 @@ import java.util.ListIterator; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.Utility; @@ -39,14 +41,15 @@ import com.ibm.icu.util.Output; import com.ibm.icu.util.TimeZone; import com.ibm.icu.util.ULocale; -public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { +@RunWith(JUnit4.class) +public class DateIntervalFormatTest extends TestFmwk { /** - * + * */ private static final ULocale SPANISH = new ULocale("es"); /** - * + * */ private static final ULocale LA_SPANISH = new ULocale("es-419"); @@ -58,7 +61,7 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { // first item is date pattern // followed by a group of locale/from_data/to_data/skeleton/interval_data String[] DATA = { - "yyyy MM dd HH:mm:ss", + "yyyy MM dd HH:mm:ss", // test root "root", "2007 11 10 10:10:10", "2007 12 10 10:10:10", "yM", "2007-11 \\u2013 2007-12", @@ -67,623 +70,623 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { "en", "2007 11 10 10:10:10", "2007 11 10 15:10:10", "hms", "10:10:10 AM \\u2013 3:10:10 PM", // test skeleton with both date and time - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMyhm", "Nov 10, 2007, 10:10 AM \\u2013 Nov 20, 2007, 10:10 AM", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMyhm", "Nov 10, 2007, 10:10 AM \\u2013 Nov 20, 2007, 10:10 AM", - "en", "2007 11 10 10:10:10", "2007 11 10 11:10:10", "dMMMyhm", "Nov 10, 2007, 10:10 \\u2013 11:10 AM", + "en", "2007 11 10 10:10:10", "2007 11 10 11:10:10", "dMMMyhm", "Nov 10, 2007, 10:10 \\u2013 11:10 AM", - "en", "2007 11 10 10:10:10", "2007 11 10 11:10:10", "hms", "10:10:10 AM \\u2013 11:10:10 AM", + "en", "2007 11 10 10:10:10", "2007 11 10 11:10:10", "hms", "10:10:10 AM \\u2013 11:10:10 AM", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEEEdMMMMy", "Wednesday, October 10, 2007 \\u2013 Friday, October 10, 2008", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEEEdMMMMy", "Wednesday, October 10, 2007 \\u2013 Friday, October 10, 2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMMMy", "October 10, 2007 \\u2013 October 10, 2008", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMMMy", "October 10, 2007 \\u2013 October 10, 2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMMM", "October 10, 2007 \\u2013 October 10, 2008", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMMM", "October 10, 2007 \\u2013 October 10, 2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "MMMMy", "October 2007 \\u2013 October 2008", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "MMMMy", "October 2007 \\u2013 October 2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEEEdMMMM", "Wednesday, October 10, 2007 \\u2013 Friday, October 10, 2008", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEEEdMMMM", "Wednesday, October 10, 2007 \\u2013 Friday, October 10, 2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdMMMy", "Wed, Oct 10, 2007 \\u2013 Fri, Oct 10, 2008", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdMMMy", "Wed, Oct 10, 2007 \\u2013 Fri, Oct 10, 2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMMy", "Oct 10, 2007 \\u2013 Oct 10, 2008", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMMy", "Oct 10, 2007 \\u2013 Oct 10, 2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMM", "Oct 10, 2007 \\u2013 Oct 10, 2008", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMM", "Oct 10, 2007 \\u2013 Oct 10, 2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "MMMy", "Oct 2007 \\u2013 Oct 2008", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "MMMy", "Oct 2007 \\u2013 Oct 2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdMMM", "Wed, Oct 10, 2007 \\u2013 Fri, Oct 10, 2008", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdMMM", "Wed, Oct 10, 2007 \\u2013 Fri, Oct 10, 2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdMy", "Wed, 10/10/2007 \\u2013 Fri, 10/10/2008", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdMy", "Wed, 10/10/2007 \\u2013 Fri, 10/10/2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMy", "10/10/2007 \\u2013 10/10/2008", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMy", "10/10/2007 \\u2013 10/10/2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dM", "10/10/2007 \\u2013 10/10/2008", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dM", "10/10/2007 \\u2013 10/10/2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "My", "10/2007 \\u2013 10/2008", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "My", "10/2007 \\u2013 10/2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdM", "Wed, 10/10/2007 \\u2013 Fri, 10/10/2008", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdM", "Wed, 10/10/2007 \\u2013 Fri, 10/10/2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "d", "10/10/2007 \\u2013 10/10/2008", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "d", "10/10/2007 \\u2013 10/10/2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "Ed", "10 Wed \\u2013 10 Fri", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "Ed", "10 Wed \\u2013 10 Fri", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "y", "2007 \\u2013 2008", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "y", "2007 \\u2013 2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "M", "10/2007 \\u2013 10/2008", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "M", "10/2007 \\u2013 10/2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "MMM", "Oct 2007 \\u2013 Oct 2008", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "MMM", "Oct 2007 \\u2013 Oct 2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "MMMM", "October 2007 \\u2013 October 2008", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "MMMM", "October 2007 \\u2013 October 2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hm", "10/10/2007, 10:10 AM \\u2013 10/10/2008, 10:10 AM", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hm", "10/10/2007, 10:10 AM \\u2013 10/10/2008, 10:10 AM", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hmv", "10/10/2007, 10:10 AM PT \\u2013 10/10/2008, 10:10 AM PT", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hmv", "10/10/2007, 10:10 AM PT \\u2013 10/10/2008, 10:10 AM PT", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hmz", "10/10/2007, 10:10 AM PDT \\u2013 10/10/2008, 10:10 AM PDT", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hmz", "10/10/2007, 10:10 AM PDT \\u2013 10/10/2008, 10:10 AM PDT", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "h", "10/10/2007, 10 AM \\u2013 10/10/2008, 10 AM", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "h", "10/10/2007, 10 AM \\u2013 10/10/2008, 10 AM", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hv", "10/10/2007, 10 AM PT \\u2013 10/10/2008, 10 AM PT", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hv", "10/10/2007, 10 AM PT \\u2013 10/10/2008, 10 AM PT", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hz", "10/10/2007, 10 AM PDT \\u2013 10/10/2008, 10 AM PDT", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hz", "10/10/2007, 10 AM PDT \\u2013 10/10/2008, 10 AM PDT", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEddMMyyyy", "Wed, 10/10/2007 \\u2013 Fri, 10/10/2008", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEddMMyyyy", "Wed, 10/10/2007 \\u2013 Fri, 10/10/2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EddMMy", "Wed, 10/10/2007 \\u2013 Fri, 10/10/2008", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EddMMy", "Wed, 10/10/2007 \\u2013 Fri, 10/10/2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hhmm", "10/10/2007, 10:10 AM \\u2013 10/10/2008, 10:10 AM", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hhmm", "10/10/2007, 10:10 AM \\u2013 10/10/2008, 10:10 AM", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hhmmzz", "10/10/2007, 10:10 AM PDT \\u2013 10/10/2008, 10:10 AM PDT", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hhmmzz", "10/10/2007, 10:10 AM PDT \\u2013 10/10/2008, 10:10 AM PDT", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hms", "10/10/2007, 10:10:10 AM \\u2013 10/10/2008, 10:10:10 AM", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hms", "10/10/2007, 10:10:10 AM \\u2013 10/10/2008, 10:10:10 AM", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMMMMy", "O 10, 2007 \\u2013 O 10, 2008", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMMMMy", "O 10, 2007 \\u2013 O 10, 2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEEEEdM", "W, 10/10/2007 \\u2013 F, 10/10/2008", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEEEEdM", "W, 10/10/2007 \\u2013 F, 10/10/2008", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEEEdMMMMy", "Wednesday, October 10 \\u2013 Saturday, November 10, 2007", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEEEdMMMMy", "Wednesday, October 10 \\u2013 Saturday, November 10, 2007", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMMMy", "October 10 \\u2013 November 10, 2007", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMMMy", "October 10 \\u2013 November 10, 2007", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMMM", "October 10 \\u2013 November 10", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMMM", "October 10 \\u2013 November 10", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMMMy", "October \\u2013 November 2007", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMMMy", "October \\u2013 November 2007", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEEEdMMMM", "Wednesday, October 10 \\u2013 Saturday, November 10", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEEEdMMMM", "Wednesday, October 10 \\u2013 Saturday, November 10", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EdMMMy", "Wed, Oct 10 \\u2013 Sat, Nov 10, 2007", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EdMMMy", "Wed, Oct 10 \\u2013 Sat, Nov 10, 2007", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMMy", "Oct 10 \\u2013 Nov 10, 2007", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMMy", "Oct 10 \\u2013 Nov 10, 2007", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMM", "Oct 10 \\u2013 Nov 10", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMM", "Oct 10 \\u2013 Nov 10", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMMy", "Oct \\u2013 Nov 2007", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMMy", "Oct \\u2013 Nov 2007", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EdMMM", "Wed, Oct 10 \\u2013 Sat, Nov 10", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EdMMM", "Wed, Oct 10 \\u2013 Sat, Nov 10", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EdMy", "Wed, 10/10/2007 \\u2013 Sat, 11/10/2007", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EdMy", "Wed, 10/10/2007 \\u2013 Sat, 11/10/2007", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMy", "10/10/2007 \\u2013 11/10/2007", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMy", "10/10/2007 \\u2013 11/10/2007", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dM", "10/10 \\u2013 11/10", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dM", "10/10 \\u2013 11/10", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "My", "10/2007 \\u2013 11/2007", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "My", "10/2007 \\u2013 11/2007", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EdM", "Wed, 10/10 \\u2013 Sat, 11/10", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EdM", "Wed, 10/10 \\u2013 Sat, 11/10", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "d", "10/10 \\u2013 11/10", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "d", "10/10 \\u2013 11/10", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "Ed", "10 Wed \\u2013 10 Sat", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "Ed", "10 Wed \\u2013 10 Sat", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "y", "2007", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "y", "2007", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "M", "10 \\u2013 11", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "M", "10 \\u2013 11", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMM", "Oct \\u2013 Nov", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMM", "Oct \\u2013 Nov", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMMM", "October \\u2013 November", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMMM", "October \\u2013 November", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hm", "10/10/2007, 10:10 AM \\u2013 11/10/2007, 10:10 AM", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hm", "10/10/2007, 10:10 AM \\u2013 11/10/2007, 10:10 AM", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hmv", "10/10/2007, 10:10 AM PT \\u2013 11/10/2007, 10:10 AM PT", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hmv", "10/10/2007, 10:10 AM PT \\u2013 11/10/2007, 10:10 AM PT", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hmz", "10/10/2007, 10:10 AM PDT \\u2013 11/10/2007, 10:10 AM PST", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hmz", "10/10/2007, 10:10 AM PDT \\u2013 11/10/2007, 10:10 AM PST", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "h", "10/10/2007, 10 AM \\u2013 11/10/2007, 10 AM", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "h", "10/10/2007, 10 AM \\u2013 11/10/2007, 10 AM", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hv", "10/10/2007, 10 AM PT \\u2013 11/10/2007, 10 AM PT", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hv", "10/10/2007, 10 AM PT \\u2013 11/10/2007, 10 AM PT", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hz", "10/10/2007, 10 AM PDT \\u2013 11/10/2007, 10 AM PST", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hz", "10/10/2007, 10 AM PDT \\u2013 11/10/2007, 10 AM PST", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEddMMyyyy", "Wed, 10/10/2007 \\u2013 Sat, 11/10/2007", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEddMMyyyy", "Wed, 10/10/2007 \\u2013 Sat, 11/10/2007", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EddMMy", "Wed, 10/10/2007 \\u2013 Sat, 11/10/2007", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EddMMy", "Wed, 10/10/2007 \\u2013 Sat, 11/10/2007", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hhmm", "10/10/2007, 10:10 AM \\u2013 11/10/2007, 10:10 AM", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hhmm", "10/10/2007, 10:10 AM \\u2013 11/10/2007, 10:10 AM", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hhmmzz", "10/10/2007, 10:10 AM PDT \\u2013 11/10/2007, 10:10 AM PST", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hhmmzz", "10/10/2007, 10:10 AM PDT \\u2013 11/10/2007, 10:10 AM PST", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hms", "10/10/2007, 10:10:10 AM \\u2013 11/10/2007, 10:10:10 AM", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hms", "10/10/2007, 10:10:10 AM \\u2013 11/10/2007, 10:10:10 AM", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMMMMy", "O 10 \\u2013 N 10, 2007", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMMMMy", "O 10 \\u2013 N 10, 2007", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEEEEdM", "W, 10/10 \\u2013 S, 11/10", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEEEEdM", "W, 10/10 \\u2013 S, 11/10", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMMMy", "Saturday, November 10 \\u2013 Tuesday, November 20, 2007", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMMMy", "Saturday, November 10 \\u2013 Tuesday, November 20, 2007", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMMy", "November 10 \\u2013 20, 2007", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMMy", "November 10 \\u2013 20, 2007", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMM", "November 10 \\u2013 20", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMM", "November 10 \\u2013 20", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMMMy", "November 2007", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMMMy", "November 2007", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMMM", "Saturday, November 10 \\u2013 Tuesday, November 20", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMMM", "Saturday, November 10 \\u2013 Tuesday, November 20", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMMMy", "Sat, Nov 10 \\u2013 Tue, Nov 20, 2007", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMMMy", "Sat, Nov 10 \\u2013 Tue, Nov 20, 2007", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMM", "Nov 10 \\u2013 20", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMM", "Nov 10 \\u2013 20", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMMy", "Nov 2007", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMMy", "Nov 2007", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMMM", "Sat, Nov 10 \\u2013 Tue, Nov 20", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMMM", "Sat, Nov 10 \\u2013 Tue, Nov 20", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMy", "Sat, 11/10/2007 \\u2013 Tue, 11/20/2007", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMy", "Sat, 11/10/2007 \\u2013 Tue, 11/20/2007", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMy", "11/10/2007 \\u2013 11/20/2007", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMy", "11/10/2007 \\u2013 11/20/2007", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dM", "11/10 \\u2013 11/20", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dM", "11/10 \\u2013 11/20", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "My", "11/2007", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdM", "Sat, 11/10 \\u2013 Tue, 11/20", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "My", "11/2007", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdM", "Sat, 11/10 \\u2013 Tue, 11/20", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "d", "10 \\u2013 20", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "Ed", "10 Sat \\u2013 20 Tue", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "d", "10 \\u2013 20", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "Ed", "10 Sat \\u2013 20 Tue", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "M", "11", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "M", "11", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMM", "Nov", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMM", "Nov", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hm", "11/10/2007, 10:10 AM \\u2013 11/20/2007, 10:10 AM", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hm", "11/10/2007, 10:10 AM \\u2013 11/20/2007, 10:10 AM", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hmv", "11/10/2007, 10:10 AM PT \\u2013 11/20/2007, 10:10 AM PT", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hmv", "11/10/2007, 10:10 AM PT \\u2013 11/20/2007, 10:10 AM PT", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hmz", "11/10/2007, 10:10 AM PST \\u2013 11/20/2007, 10:10 AM PST", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hmz", "11/10/2007, 10:10 AM PST \\u2013 11/20/2007, 10:10 AM PST", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hz", "11/10/2007, 10 AM PST \\u2013 11/20/2007, 10 AM PST", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hz", "11/10/2007, 10 AM PST \\u2013 11/20/2007, 10 AM PST", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEddMMyyyy", "Sat, 11/10/2007 \\u2013 Tue, 11/20/2007", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEddMMyyyy", "Sat, 11/10/2007 \\u2013 Tue, 11/20/2007", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EddMMy", "Sat, 11/10/2007 \\u2013 Tue, 11/20/2007", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EddMMy", "Sat, 11/10/2007 \\u2013 Tue, 11/20/2007", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hhmm", "11/10/2007, 10:10 AM \\u2013 11/20/2007, 10:10 AM", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hhmm", "11/10/2007, 10:10 AM \\u2013 11/20/2007, 10:10 AM", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hms", "11/10/2007, 10:10:10 AM \\u2013 11/20/2007, 10:10:10 AM", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hms", "11/10/2007, 10:10:10 AM \\u2013 11/20/2007, 10:10:10 AM", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMMMy", "N 10 \\u2013 20, 2007", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMMMy", "N 10 \\u2013 20, 2007", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEEdM", "S, 11/10 \\u2013 T, 11/20", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEEdM", "S, 11/10 \\u2013 T, 11/20", - "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEdMMMMy", "Wednesday, January 10, 2007", + "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEdMMMMy", "Wednesday, January 10, 2007", - "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMMMy", "January 10, 2007", + "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMMMy", "January 10, 2007", - "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMMM", "January 10", + "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMMM", "January 10", - "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "MMMMy", "January 2007", + "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "MMMMy", "January 2007", - "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEdMMMM", "Wednesday, January 10", + "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEdMMMM", "Wednesday, January 10", - "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMMy", "Jan 10, 2007", + "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMMy", "Jan 10, 2007", - "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMM", "Jan 10", + "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMM", "Jan 10", - "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "MMMy", "Jan 2007", + "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "MMMy", "Jan 2007", - "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EdMMM", "Wed, Jan 10", + "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EdMMM", "Wed, Jan 10", - "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EdMy", "Wed, 1/10/2007", + "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EdMy", "Wed, 1/10/2007", - "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMy", "1/10/2007", + "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMy", "1/10/2007", - "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dM", "1/10", + "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dM", "1/10", - "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EdM", "Wed, 1/10", + "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EdM", "Wed, 1/10", - "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "d", "10", + "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "d", "10", - "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "Ed", "10 Wed", + "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "Ed", "10 Wed", - "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "y", "2007", + "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "y", "2007", - "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "MMM", "Jan", + "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "MMM", "Jan", - "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "MMMM", "January", + "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "MMMM", "January", - "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hm", "10:00 AM \\u2013 2:10 PM", + "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hm", "10:00 AM \\u2013 2:10 PM", - "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hmz", "10:00 AM \\u2013 2:10 PM PST", + "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hmz", "10:00 AM \\u2013 2:10 PM PST", - "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "h", "10 AM \\u2013 2 PM", + "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "h", "10 AM \\u2013 2 PM", - "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hv", "10 AM \\u2013 2 PM PT", + "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hv", "10 AM \\u2013 2 PM PT", - "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hz", "10 AM \\u2013 2 PM PST", + "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hz", "10 AM \\u2013 2 PM PST", - "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEddMMyyyy", "Wed, 01/10/2007", + "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEddMMyyyy", "Wed, 01/10/2007", - "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hhmm", "10:00 AM \\u2013 2:10 PM", + "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hhmm", "10:00 AM \\u2013 2:10 PM", - "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hhmmzz", "10:00 AM \\u2013 2:10 PM PST", + "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hhmmzz", "10:00 AM \\u2013 2:10 PM PST", - "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMMMMy", "J 10, 2007", + "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMMMMy", "J 10, 2007", - "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEEdM", "W, 1/10", + "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEEdM", "W, 1/10", - "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EEEEdMMMMy", "Wednesday, January 10, 2007", + "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EEEEdMMMMy", "Wednesday, January 10, 2007", - "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "dMMMMy", "January 10, 2007", + "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "dMMMMy", "January 10, 2007", - "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "MMMMy", "January 2007", + "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "MMMMy", "January 2007", - "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EdMMMy", "Wed, Jan 10, 2007", + "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EdMMMy", "Wed, Jan 10, 2007", - "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "dMMMy", "Jan 10, 2007", + "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "dMMMy", "Jan 10, 2007", - "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "dMMM", "Jan 10", + "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "dMMM", "Jan 10", - "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EdMMM", "Wed, Jan 10", + "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EdMMM", "Wed, Jan 10", - "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EdMy", "Wed, 1/10/2007", + "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EdMy", "Wed, 1/10/2007", - "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "dM", "1/10", + "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "dM", "1/10", - "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EdM", "Wed, 1/10", + "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EdM", "Wed, 1/10", - "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "y", "2007", + "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "y", "2007", - "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "MMM", "Jan", + "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "MMM", "Jan", - "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hm", "10:00 \\u2013 10:20 AM", + "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hm", "10:00 \\u2013 10:20 AM", - "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hmv", "10:00 \\u2013 10:20 AM PT", + "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hmv", "10:00 \\u2013 10:20 AM PT", - "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "h", "10 AM", + "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "h", "10 AM", - "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hz", "10 AM PST", + "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hz", "10 AM PST", - "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EddMMy", "Wed, 01/10/2007", + "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EddMMy", "Wed, 01/10/2007", - "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hhmm", "10:00 \\u2013 10:20 AM", + "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hhmm", "10:00 \\u2013 10:20 AM", - "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hhmmzz", "10:00 \\u2013 10:20 AM PST", + "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hhmmzz", "10:00 \\u2013 10:20 AM PST", - "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hms", "10:00:10 AM \\u2013 10:20:10 AM", + "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hms", "10:00:10 AM \\u2013 10:20:10 AM", - "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "dMMMM", "January 10", + "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "dMMMM", "January 10", - "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EEEEdMMMM", "Wednesday, January 10", + "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EEEEdMMMM", "Wednesday, January 10", - "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EdMMMy", "Wed, Jan 10, 2007", + "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EdMMMy", "Wed, Jan 10, 2007", - "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "dMMM", "Jan 10", + "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "dMMM", "Jan 10", - "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EdMMM", "Wed, Jan 10", - "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "dM", "1/10", + "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EdMMM", "Wed, Jan 10", + "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "dM", "1/10", - "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "My", "1/2007", + "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "My", "1/2007", - "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EdM", "Wed, 1/10", - "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "d", "10", + "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EdM", "Wed, 1/10", + "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "d", "10", - "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "Ed", "10 Wed", + "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "Ed", "10 Wed", - "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "y", "2007", + "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "y", "2007", - "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "M", "1", + "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "M", "1", - "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "MMM", "Jan", + "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "MMM", "Jan", - "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "MMMM", "January", + "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "MMMM", "January", - "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hm", "10:10 AM", + "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hm", "10:10 AM", - "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hmv", "10:10 AM PT", + "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hmv", "10:10 AM PT", - "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hmz", "10:10 AM PST", + "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hmz", "10:10 AM PST", - "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "h", "10 AM", + "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "h", "10 AM", - "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hz", "10 AM PST", + "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hz", "10 AM PST", - "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hhmmzz", "10:10 AM PST", + "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hhmmzz", "10:10 AM PST", - "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hms", "10:10:10 AM \u2013 10:10:20 AM", + "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hms", "10:10:10 AM \u2013 10:10:20 AM", - "en", "2007 01 01 22:00:00", "2007 01 01 23:00:00", "yMMMMdHm", "January 1, 2007, 22:00 \u2013 23:00", + "en", "2007 01 01 22:00:00", "2007 01 01 23:00:00", "yMMMMdHm", "January 1, 2007, 22:00 \u2013 23:00", - "zh", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEEEdMMMMy", "2007\\u5e7410\\u670810\\u65e5\\u661f\\u671f\\u4e09\\u81f32008\\u5e7410\\u670810\\u65e5\\u661f\\u671f\\u4e94", + "zh", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEEEdMMMMy", "2007\\u5e7410\\u670810\\u65e5\\u661f\\u671f\\u4e09\\u81f32008\\u5e7410\\u670810\\u65e5\\u661f\\u671f\\u4e94", - "zh", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hm", "2007/10/10 \\u4e0a\\u534810:10 \\u2013 2008/10/10 \\u4e0a\\u534810:10", + "zh", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hm", "2007/10/10 \\u4e0a\\u534810:10 \\u2013 2008/10/10 \\u4e0a\\u534810:10", - "zh", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMMMy", "2007\\u5e7410\\u670810\\u65e5\\u81f311\\u670810\\u65e5", + "zh", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMMMy", "2007\\u5e7410\\u670810\\u65e5\\u81f311\\u670810\\u65e5", - "zh", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMMM", "10\\u670810\\u65e5\\u81f311\\u670810\\u65e5", + "zh", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMMM", "10\\u670810\\u65e5\\u81f311\\u670810\\u65e5", - "zh", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMMMy", "2007\\u5e7410\\u6708\\u81f311\\u6708", + "zh", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMMMy", "2007\\u5e7410\\u6708\\u81f311\\u6708", - "zh", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEEEdMMMM", "10\\u670810\\u65e5\\u661f\\u671f\\u4e09\\u81f311\\u670810\\u65e5\\u661f\\u671f\\u516d", + "zh", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEEEdMMMM", "10\\u670810\\u65e5\\u661f\\u671f\\u4e09\\u81f311\\u670810\\u65e5\\u661f\\u671f\\u516d", - "zh", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hmv", "2007/10/10 \\u6D1B\\u6749\\u77F6\\u65F6\\u95F4 \\u4E0A\\u534810:10 \\u2013 2007/11/10 \\u6D1B\\u6749\\u77F6\\u65F6\\u95F4 \\u4E0A\\u534810:10", + "zh", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hmv", "2007/10/10 \\u6D1B\\u6749\\u77F6\\u65F6\\u95F4 \\u4E0A\\u534810:10 \\u2013 2007/11/10 \\u6D1B\\u6749\\u77F6\\u65F6\\u95F4 \\u4E0A\\u534810:10", - "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMMMy", "2007\\u5e7411\\u670810\\u65e5\\u661f\\u671f\\u516d\\u81f320\\u65e5\\u661f\\u671f\\u4e8c", + "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMMMy", "2007\\u5e7411\\u670810\\u65e5\\u661f\\u671f\\u516d\\u81f320\\u65e5\\u661f\\u671f\\u4e8c", - "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMMy", "2007\\u5e7411\\u670810\\u65e5\\u81f320\\u65e5", + "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMMy", "2007\\u5e7411\\u670810\\u65e5\\u81f320\\u65e5", - "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMM", "11\\u670810\\u65e5\\u81f320\\u65e5", + "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMM", "11\\u670810\\u65e5\\u81f320\\u65e5", "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMMMy", "2007\\u5E7411\\u6708", // (fixed expected result per ticket 6872<-6626) - "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMMM", "11\\u670810\\u65e5\\u661f\\u671f\\u516d\\u81f320\\u65e5\\u661f\\u671f\\u4e8c", + "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMMM", "11\\u670810\\u65e5\\u661f\\u671f\\u516d\\u81f320\\u65e5\\u661f\\u671f\\u4e8c", - "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMMM", "11\\u670810\\u65e5\\u5468\\u516d\\u81f320\\u65e5\\u5468\\u4e8c", + "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMMM", "11\\u670810\\u65e5\\u5468\\u516d\\u81f320\\u65e5\\u5468\\u4e8c", "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMy", "2007/11/10\\u5468\\u516d\\u81f32007/11/20\\u5468\\u4e8c", - "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMy", "2007/11/10 \\u2013 2007/11/20", + "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMy", "2007/11/10 \\u2013 2007/11/20", "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dM", "11/10 \\u2013 11/20", - "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "My", "2007\u5E7411\u6708", - "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdM", "11/10\\u5468\\u516d\\u81f311/20\\u5468\\u4e8c", + "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "My", "2007\u5E7411\u6708", + "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdM", "11/10\\u5468\\u516d\\u81f311/20\\u5468\\u4e8c", - "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "d", "10\\u201320\\u65e5", + "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "d", "10\\u201320\\u65e5", "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "y", "2007\\u5E74", // (fixed expected result per ticket:6626:) - "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "M", "11\\u6708", + "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "M", "11\\u6708", "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMM", "11\\u6708", // (fixed expected result per ticket 6872<-6626 and others) "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMMM", "\\u5341\\u4E00\\u6708", // (fixed expected result per ticket 6872<-6626 and others) - "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hmz", "2007/11/10 GMT-8 \\u4e0a\\u534810:10 \\u2013 2007/11/20 GMT-8 \\u4e0a\\u534810:10", + "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hmz", "2007/11/10 GMT-8 \\u4e0a\\u534810:10 \\u2013 2007/11/20 GMT-8 \\u4e0a\\u534810:10", - "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "h", "2007/11/10 \\u4e0a\\u534810\\u65f6 \\u2013 2007/11/20 \\u4e0a\\u534810\\u65f6", + "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "h", "2007/11/10 \\u4e0a\\u534810\\u65f6 \\u2013 2007/11/20 \\u4e0a\\u534810\\u65f6", "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEdMMMMy", "2007\\u5e741\\u670810\\u65e5\\u661f\\u671f\\u4e09", // (fixed expected result per ticket 6872<-6626) - "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hm", "\\u4e0a\\u534810:00\\u81f3\\u4e0b\\u53482:10", + "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hm", "\\u4e0a\\u534810:00\\u81f3\\u4e0b\\u53482:10", - "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hmv", "\\u6D1B\\u6749\\u77F6\\u65F6\\u95F4\\u4E0A\\u534810:00\\u81F3\\u4E0B\\u53482:10", + "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hmv", "\\u6D1B\\u6749\\u77F6\\u65F6\\u95F4\\u4E0A\\u534810:00\\u81F3\\u4E0B\\u53482:10", - "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hmz", "GMT-8\\u4e0a\\u534810:00\\u81f3\\u4e0b\\u53482:10", + "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hmz", "GMT-8\\u4e0a\\u534810:00\\u81f3\\u4e0b\\u53482:10", - "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "h", "\\u4e0a\\u534810\\u65F6\\u81f3\\u4e0b\\u53482\\u65f6", + "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "h", "\\u4e0a\\u534810\\u65F6\\u81f3\\u4e0b\\u53482\\u65f6", - "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hv", "\\u6D1B\\u6749\\u77F6\\u65F6\\u95F4\\u4E0A\\u534810\\u65F6\\u81F3\\u4E0B\\u53482\\u65F6", + "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hv", "\\u6D1B\\u6749\\u77F6\\u65F6\\u95F4\\u4E0A\\u534810\\u65F6\\u81F3\\u4E0B\\u53482\\u65F6", - "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hz", "GMT-8\\u4e0a\\u534810\\u65F6\\u81f3\\u4e0b\\u53482\\u65f6", + "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hz", "GMT-8\\u4e0a\\u534810\\u65F6\\u81f3\\u4e0b\\u53482\\u65f6", "zh", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "dMMMM", "1\\u670810\\u65e5", // (fixed expected result per ticket 6872<-6626) - "zh", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hm", "\\u4e0a\\u534810:00\\u81f310:20", + "zh", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hm", "\\u4e0a\\u534810:00\\u81f310:20", - "zh", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hmv", "\\u6D1B\\u6749\\u77F6\\u65F6\\u95F4\\u4E0A\\u534810:00\\u81F310:20", + "zh", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hmv", "\\u6D1B\\u6749\\u77F6\\u65F6\\u95F4\\u4E0A\\u534810:00\\u81F310:20", - "zh", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "h", "\\u4e0a\\u534810\\u65f6", + "zh", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "h", "\\u4e0a\\u534810\\u65f6", - "zh", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hz", "GMT-8\\u4e0a\\u534810\\u65f6", + "zh", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hz", "GMT-8\\u4e0a\\u534810\\u65f6", "zh", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EEEEdMMMMy", "2007\\u5e741\\u670810\\u65e5\\u661f\\u671f\\u4e09", // (fixed expected result per ticket 6872<-6626) - "zh", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hm", "\\u4e0a\\u534810:10", + "zh", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hm", "\\u4e0a\\u534810:10", - "zh", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "h", "\\u4e0a\\u534810\\u65f6", + "zh", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "h", "\\u4e0a\\u534810\\u65f6", - "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEEEdMMMy", "Mittwoch, 10. Okt. 2007 \\u2013 Freitag, 10. Okt. 2008", + "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEEEdMMMy", "Mittwoch, 10. Okt. 2007 \\u2013 Freitag, 10. Okt. 2008", - "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMMy", "10. Okt. 2007 \\u2013 10. Okt. 2008", + "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMMy", "10. Okt. 2007 \\u2013 10. Okt. 2008", - "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMM", "10. Okt. 2007 \\u2013 10. Okt. 2008", + "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMM", "10. Okt. 2007 \\u2013 10. Okt. 2008", - "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "MMMy", "Okt. 2007 \\u2013 Okt. 2008", + "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "MMMy", "Okt. 2007 \\u2013 Okt. 2008", - "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEEdMMM", "Mi., 10. Okt. 2007 \\u2013 Fr., 10. Okt. 2008", + "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEEdMMM", "Mi., 10. Okt. 2007 \\u2013 Fr., 10. Okt. 2008", - "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdMy", "Mi., 10.10.2007 \\u2013 Fr., 10.10.2008", + "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdMy", "Mi., 10.10.2007 \\u2013 Fr., 10.10.2008", - "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMy", "10.10.2007 \\u2013 10.10.2008", + "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMy", "10.10.2007 \\u2013 10.10.2008", - "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dM", "10.10.2007 \\u2013 10.10.2008", + "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dM", "10.10.2007 \\u2013 10.10.2008", - "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "My", "10.2007 \\u2013 10.2008", + "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "My", "10.2007 \\u2013 10.2008", - "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdM", "Mi., 10.10.2007 \\u2013 Fr., 10.10.2008", + "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdM", "Mi., 10.10.2007 \\u2013 Fr., 10.10.2008", - "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "d", "10.10.2007 \\u2013 10.10.2008", + "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "d", "10.10.2007 \\u2013 10.10.2008", - "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "y", "2007\\u20132008", + "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "y", "2007\\u20132008", - "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "M", "10.2007 \\u2013 10.2008", + "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "M", "10.2007 \\u2013 10.2008", - "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "MMM", "Okt. 2007 \\u2013 Okt. 2008", + "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "MMM", "Okt. 2007 \\u2013 Okt. 2008", - "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hm", "10.10.2007, 10:10 vorm. \\u2013 10.10.2008, 10:10 vorm.", + "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hm", "10.10.2007, 10:10 vorm. \\u2013 10.10.2008, 10:10 vorm.", - "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "jm", "10.10.2007, 10:10 \\u2013 10.10.2008, 10:10", + "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "jm", "10.10.2007, 10:10 \\u2013 10.10.2008, 10:10", - "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEEEdMMMy", "Mittwoch, 10. Okt. \\u2013 Samstag, 10. Nov. 2007", + "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEEEdMMMy", "Mittwoch, 10. Okt. \\u2013 Samstag, 10. Nov. 2007", - "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMMy", "10. Okt. \\u2013 10. Nov. 2007", + "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMMy", "10. Okt. \\u2013 10. Nov. 2007", - "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMM", "10. Okt. \\u2013 10. Nov.", + "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMM", "10. Okt. \\u2013 10. Nov.", - "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMMy", "Okt.\\u2013Nov. 2007", + "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMMy", "Okt.\\u2013Nov. 2007", - "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEEEdMMM", "Mittwoch, 10. Okt. \\u2013 Samstag, 10. Nov.", + "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEEEdMMM", "Mittwoch, 10. Okt. \\u2013 Samstag, 10. Nov.", - "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EdMy", "Mi., 10.10.2007 \\u2013 Sa., 10.11.2007", + "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EdMy", "Mi., 10.10.2007 \\u2013 Sa., 10.11.2007", - "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dM", "10.10. \\u2013 10.11.", + "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dM", "10.10. \\u2013 10.11.", - "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "My", "10.2007 \\u2013 11.2007", + "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "My", "10.2007 \\u2013 11.2007", - "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EdM", "Mi., 10.10. \\u2013 Sa., 10.11.", + "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EdM", "Mi., 10.10. \\u2013 Sa., 10.11.", - "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "d", "10.10. \\u2013 10.11.", + "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "d", "10.10. \\u2013 10.11.", - "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "M", "10.\\u201311.", + "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "M", "10.\\u201311.", - "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMM", "Okt.\\u2013Nov.", + "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMM", "Okt.\\u2013Nov.", - "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hmv", "10.10.2007, 10:10 vorm. Los Angeles Zeit \\u2013 10.11.2007, 10:10 vorm. Los Angeles Zeit", + "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hmv", "10.10.2007, 10:10 vorm. Los Angeles Zeit \\u2013 10.11.2007, 10:10 vorm. Los Angeles Zeit", - "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "jmv", "10.10.2007, 10:10 Los Angeles Zeit \\u2013 10.11.2007, 10:10 Los Angeles Zeit", + "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "jmv", "10.10.2007, 10:10 Los Angeles Zeit \\u2013 10.11.2007, 10:10 Los Angeles Zeit", - "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hms", "10.10.2007, 10:10:10 vorm. \\u2013 10.11.2007, 10:10:10 vorm.", + "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hms", "10.10.2007, 10:10:10 vorm. \\u2013 10.11.2007, 10:10:10 vorm.", - "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMMy", "Samstag, 10. \\u2013 Dienstag, 20. Nov. 2007", + "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMMy", "Samstag, 10. \\u2013 Dienstag, 20. Nov. 2007", - "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMy", "10.\\u201320. Nov. 2007", + "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMy", "10.\\u201320. Nov. 2007", - "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMM", "10.\\u201320. Nov.", + "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMM", "10.\\u201320. Nov.", - "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMMy", "Nov. 2007", + "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMMy", "Nov. 2007", - "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMM", "Samstag, 10. \\u2013 Dienstag, 20. Nov.", + "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMM", "Samstag, 10. \\u2013 Dienstag, 20. Nov.", - "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMy", "Sa., 10.11.2007 \\u2013 Di., 20.11.2007", + "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMy", "Sa., 10.11.2007 \\u2013 Di., 20.11.2007", - "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMy", "10.11.2007 \\u2013 20.11.2007", + "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMy", "10.11.2007 \\u2013 20.11.2007", - "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dM", "10.11. \\u2013 20.11.", + "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dM", "10.11. \\u2013 20.11.", - "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "My", "11.2007", + "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "My", "11.2007", - "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdM", "Sa., 10.11. \\u2013 Di., 20.11.", + "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdM", "Sa., 10.11. \\u2013 Di., 20.11.", - "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "d", "10.\\u201320.", + "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "d", "10.\\u201320.", - "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "y", "2007", + "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "y", "2007", - "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "M", "11", + "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "M", "11", - "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hmv", "10.11.2007, 10:10 vorm. Los Angeles Zeit \\u2013 20.11.2007, 10:10 vorm. Los Angeles Zeit", + "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hmv", "10.11.2007, 10:10 vorm. Los Angeles Zeit \\u2013 20.11.2007, 10:10 vorm. Los Angeles Zeit", - "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "jmv", "10.11.2007, 10:10 Los Angeles Zeit \\u2013 20.11.2007, 10:10 Los Angeles Zeit", + "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "jmv", "10.11.2007, 10:10 Los Angeles Zeit \\u2013 20.11.2007, 10:10 Los Angeles Zeit", - "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEdMMMy", "Mittwoch, 10. Jan. 2007", + "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEdMMMy", "Mittwoch, 10. Jan. 2007", - "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMMy", "10. Jan. 2007", + "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMMy", "10. Jan. 2007", - "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMM", "10. Jan.", + "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMM", "10. Jan.", - "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "MMMy", "Jan. 2007", + "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "MMMy", "Jan. 2007", - "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEdMMM", "Mittwoch, 10. Jan.", + "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEdMMM", "Mittwoch, 10. Jan.", - "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hmz", "10:00 vorm. \\u2013 2:10 nachm. GMT-8", + "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hmz", "10:00 vorm. \\u2013 2:10 nachm. GMT-8", - "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "h", "10 Uhr vorm. \\u2013 2 Uhr nachm.", + "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "h", "10 Uhr vorm. \\u2013 2 Uhr nachm.", - "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EEEEdMMM", "Mittwoch, 10. Jan.", + "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EEEEdMMM", "Mittwoch, 10. Jan.", - "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hm", "10:00\\u201310:20 vorm.", + "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hm", "10:00\\u201310:20 vorm.", - "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hmv", "10:00\\u201310:20 vorm. Los Angeles Zeit", + "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hmv", "10:00\\u201310:20 vorm. Los Angeles Zeit", - "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hmz", "10:00\\u201310:20 vorm. GMT-8", + "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hmz", "10:00\\u201310:20 vorm. GMT-8", - "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "h", "10 Uhr vorm.", + "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "h", "10 Uhr vorm.", - "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hv", "10 Uhr vorm. Los Angeles Zeit", + "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hv", "10 Uhr vorm. Los Angeles Zeit", - "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hz", "10 Uhr vorm. GMT-8", + "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hz", "10 Uhr vorm. GMT-8", - "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EEEEdMMMy", "Mittwoch, 10. Jan. 2007", + "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EEEEdMMMy", "Mittwoch, 10. Jan. 2007", - "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hm", "10:10 vorm.", + "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hm", "10:10 vorm.", - "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "jm", "10:10", + "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "jm", "10:10", - "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hmv", "10:10 vorm. Los Angeles Zeit", + "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hmv", "10:10 vorm. Los Angeles Zeit", - "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "jmv", "10:10 Los Angeles Zeit", + "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "jmv", "10:10 Los Angeles Zeit", - "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hmz", "10:10 vorm. GMT-8", + "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hmz", "10:10 vorm. GMT-8", - "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "jmz", "10:10 GMT-8", + "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "jmz", "10:10 GMT-8", - "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "h", "10 Uhr vorm.", + "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "h", "10 Uhr vorm.", - "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hv", "10 Uhr vorm. Los Angeles Zeit", + "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hv", "10 Uhr vorm. Los Angeles Zeit", - "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hz", "10 Uhr vorm. GMT-8", + "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hz", "10 Uhr vorm. GMT-8", // Thai (default calendar buddhist) - "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "EEEEdMMMy", "\\u0E27\\u0E31\\u0E19\\u0E1E\\u0E38\\u0E18\\u0E17\\u0E35\\u0E48 10 \\u0E15.\\u0E04. 2550 \\u2013 \\u0E27\\u0E31\\u0E19\\u0E28\\u0E38\\u0E01\\u0E23\\u0E4C\\u0E17\\u0E35\\u0E48 10 \\u0E15.\\u0E04. 2551", + "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "EEEEdMMMy", "\\u0E27\\u0E31\\u0E19\\u0E1E\\u0E38\\u0E18\\u0E17\\u0E35\\u0E48 10 \\u0E15.\\u0E04. 2550 \\u2013 \\u0E27\\u0E31\\u0E19\\u0E28\\u0E38\\u0E01\\u0E23\\u0E4C\\u0E17\\u0E35\\u0E48 10 \\u0E15.\\u0E04. 2551", - "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "dMMM", "10 \\u0E15.\\u0E04. 2550 \\u2013 10 \\u0E15.\\u0E04. 2551", + "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "dMMM", "10 \\u0E15.\\u0E04. 2550 \\u2013 10 \\u0E15.\\u0E04. 2551", - "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "MMMy", "\\u0E15.\\u0E04. 2550 \\u2013 \\u0E15.\\u0E04. 2551", + "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "MMMy", "\\u0E15.\\u0E04. 2550 \\u2013 \\u0E15.\\u0E04. 2551", - "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "EdMy", "\\u0E1E. 10/10/2550 \\u2013 \\u0E28. 10/10/2551", + "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "EdMy", "\\u0E1E. 10/10/2550 \\u2013 \\u0E28. 10/10/2551", - "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "dMy", "10/10/2550 \\u2013 10/10/2551", + "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "dMy", "10/10/2550 \\u2013 10/10/2551", - "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "My", "10/2550 \\u2013 10/2551", + "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "My", "10/2550 \\u2013 10/2551", - "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "EdM", "\\u0E1E. 10/10/2550 \\u2013 \\u0E28. 10/10/2551", + "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "EdM", "\\u0E1E. 10/10/2550 \\u2013 \\u0E28. 10/10/2551", - "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "y", "2550\\u20132551", + "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "y", "2550\\u20132551", - "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "M", "10/2550 \\u2013 10/2551", + "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "M", "10/2550 \\u2013 10/2551", - "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "EEEEdMMMy", "\\u0E27\\u0E31\\u0E19\\u0E1E\\u0E38\\u0E18\\u0E17\\u0E35\\u0E48 10 \\u0E15.\\u0E04. \\u2013 \\u0E27\\u0E31\\u0E19\\u0E40\\u0E2A\\u0E32\\u0E23\\u0E4C\\u0E17\\u0E35\\u0E48 10 \\u0E1E.\\u0E22. 2550", + "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "EEEEdMMMy", "\\u0E27\\u0E31\\u0E19\\u0E1E\\u0E38\\u0E18\\u0E17\\u0E35\\u0E48 10 \\u0E15.\\u0E04. \\u2013 \\u0E27\\u0E31\\u0E19\\u0E40\\u0E2A\\u0E32\\u0E23\\u0E4C\\u0E17\\u0E35\\u0E48 10 \\u0E1E.\\u0E22. 2550", - "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "dMMM", "10 \\u0E15.\\u0E04. \\u2013 10 \\u0E1E.\\u0E22.", + "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "dMMM", "10 \\u0E15.\\u0E04. \\u2013 10 \\u0E1E.\\u0E22.", - "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "MMMy", "\\u0E15.\\u0E04.\\u2013\\u0E1E.\\u0E22. 2550", + "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "MMMy", "\\u0E15.\\u0E04.\\u2013\\u0E1E.\\u0E22. 2550", - "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "dM", "10/10 \\u2013 10/11", + "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "dM", "10/10 \\u2013 10/11", - "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "My", "10/2550 \\u2013 11/2550", + "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "My", "10/2550 \\u2013 11/2550", - "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "d", "10/10 \\u2013 10/11", + "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "d", "10/10 \\u2013 10/11", - "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "y", "\u0E1E.\u0E28. 2550", + "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "y", "\u0E1E.\u0E28. 2550", - "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "MMM", "\\u0E15.\\u0E04.\\u2013\\u0E1E.\\u0E22.", + "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "MMM", "\\u0E15.\\u0E04.\\u2013\\u0E1E.\\u0E22.", }; expect(DATA, DATA.length); @@ -707,7 +710,7 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { errln("parse exception" + e); continue; } - DateInterval dtitv = new DateInterval(date.getTime(), + DateInterval dtitv = new DateInterval(date.getTime(), date_2.getTime()); String oneSkeleton = data[i++]; DateIntervalFormat dtitvfmt = DateIntervalFormat.getInstance( @@ -721,7 +724,7 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { } - /* + /* * Test format using user defined DateIntervalInfo */ @Test @@ -730,22 +733,22 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { // followed by a group of locale/from_data/to_data/interval_data String[] DATA = { "yyyy MM dd HH:mm:ss", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "Oct 10, 2007 --- Oct 10, 2008", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "Oct 10, 2007 --- Oct 10, 2008", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "2007 Oct 10 - Nov 2007", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "2007 Oct 10 - Nov 2007", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "Nov 10, 2007 --- Nov 20, 2007", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "Nov 10, 2007 --- Nov 20, 2007", - "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "Jan 10, 2007", + "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "Jan 10, 2007", - "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "Jan 10, 2007", + "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "Jan 10, 2007", - "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "Jan 10, 2007", + "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "Jan 10, 2007", - "zh", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "2007\\u5e7410\\u670810\\u65e5 --- 2008\\u5e7410\\u670810\\u65e5", + "zh", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "2007\\u5e7410\\u670810\\u65e5 --- 2008\\u5e7410\\u670810\\u65e5", - "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "2007\\u5e7411\\u670810\\u65e5 --- 2007\\u5e7411\\u670820\\u65e5", + "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "2007\\u5e7411\\u670810\\u65e5 --- 2007\\u5e7411\\u670820\\u65e5", "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "2007\\u5e741\\u670810\\u65e5", // (fixed expected result per ticket 6872<-6626) @@ -753,29 +756,29 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { "zh", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "2007\\u5e741\\u670810\\u65e5", // (fixed expected result per ticket 6872<-6626) - "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "10. Okt. 2007 --- 10. Okt. 2008", + "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "10. Okt. 2007 --- 10. Okt. 2008", - "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "2007 Okt. 10 - Nov. 2007", + "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "2007 Okt. 10 - Nov. 2007", - "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "10. Nov. 2007 --- 20. Nov. 2007", + "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "10. Nov. 2007 --- 20. Nov. 2007", - "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "10. Jan. 2007", + "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "10. Jan. 2007", - "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "10. Jan. 2007", + "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "10. Jan. 2007", - "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "10. Jan. 2007", + "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "10. Jan. 2007", - "es", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "10 oct. 2007 --- 10 oct. 2008", + "es", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "10 oct. 2007 --- 10 oct. 2008", - "es", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "2007 oct. 10 - nov. 2007", + "es", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "2007 oct. 10 - nov. 2007", - "es", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "10 nov. 2007 --- 20 nov. 2007", + "es", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "10 nov. 2007 --- 20 nov. 2007", - "es", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "10 ene. 2007", + "es", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "10 ene. 2007", - "es", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "10 ene. 2007", + "es", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "10 ene. 2007", - "es", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "10 ene. 2007", + "es", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "10 ene. 2007", }; expectUserDII(DATA, DATA.length); } @@ -798,7 +801,7 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { errln("parse exception" + e); continue; } - DateInterval dtitv = new DateInterval(date.getTime(), + DateInterval dtitv = new DateInterval(date.getTime(), date_2.getTime()); DateIntervalInfo dtitvinf = new DateIntervalInfo(); @@ -818,7 +821,7 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { - /* + /* * Test format using user defined DateIntervalInfo */ @Test @@ -826,24 +829,24 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { // first item is date pattern // followed by a group of locale/from_data/to_data/interval_data String[] DATA = { - "yyyy MM dd HH:mm:ss", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "all diff", + "yyyy MM dd HH:mm:ss", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "all diff", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "2007 diff Oct 10 - Nov 2007", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "2007 diff Oct 10 - Nov 2007", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "2007 Nov 10 ~ 20", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "2007 Nov 10 ~ 20", - "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "Jan 10, 2007", + "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "Jan 10, 2007", - "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "Jan 10, 2007", + "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "Jan 10, 2007", - "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "Jan 10, 2007", + "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "Jan 10, 2007", - "zh", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "all diff", + "zh", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "all diff", - "zh", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "2007 diff 10\\u6708 10 - 11\\u6708 2007", + "zh", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "2007 diff 10\\u6708 10 - 11\\u6708 2007", - "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "2007 11\\u6708 10 ~ 20", + "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "2007 11\\u6708 10 ~ 20", "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "2007\u5E741\\u670810\u65E5", // (fixed expected result per ticket 6872<-6626) @@ -872,7 +875,7 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { errln("parse exception" + e); continue; } - DateInterval dtitv = new DateInterval(date.getTime(), + DateInterval dtitv = new DateInterval(date.getTime(), date_2.getTime()); DateIntervalFormat dtitvfmt = DateIntervalFormat.getInstance("yyyyMMMdd", loc); @@ -920,12 +923,12 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { // and the 2nd in the pair is the later date String[] DATA = { "yyyy MM dd HH:mm:ss", - "2007 10 10 10:10:10", "2008 10 10 10:10:10", - "2007 10 10 10:10:10", "2007 11 10 10:10:10", - "2007 11 10 10:10:10", "2007 11 20 10:10:10", - "2007 01 10 10:00:10", "2007 01 10 14:10:10", - "2007 01 10 10:00:10", "2007 01 10 10:20:10", - "2007 01 10 10:10:10", "2007 01 10 10:10:20", + "2007 10 10 10:10:10", "2008 10 10 10:10:10", + "2007 10 10 10:10:10", "2007 11 10 10:10:10", + "2007 11 10 10:10:10", "2007 11 20 10:10:10", + "2007 01 10 10:00:10", "2007 01 10 14:10:10", + "2007 01 10 10:00:10", "2007 01 10 10:20:10", + "2007 01 10 10:10:10", "2007 01 10 10:10:20", }; @@ -973,8 +976,8 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { int localeIndex; for ( localeIndex = 0; localeIndex < testLocale.length; ++localeIndex) { - stress(DATA, DATA.length, new Locale(testLocale[localeIndex][0], - testLocale[localeIndex][1], testLocale[localeIndex][2]), + stress(DATA, DATA.length, new Locale(testLocale[localeIndex][0], + testLocale[localeIndex][1], testLocale[localeIndex][2]), testLocale[localeIndex][0]+testLocale[localeIndex][1]); } } @@ -1009,7 +1012,7 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { "hv", "hz", "EEddMMyyyy", // following could be normalized - "EddMMy", + "EddMMy", "hhmm", "hhmmzz", "hms", // following could not be normalized @@ -1036,8 +1039,8 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { } DateInterval dtitv = new DateInterval(date.getTime(), date_2.getTime()); - for ( int skeletonIndex = 0; - skeletonIndex < skeleton.length; + for ( int skeletonIndex = 0; + skeletonIndex < skeleton.length; ++skeletonIndex ) { String oneSkeleton = skeleton[skeletonIndex]; // need special handle of "Thai" since the default calendar @@ -1057,7 +1060,7 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { } - // test interval format by algorithm + // test interval format by algorithm for ( int style = DateFormat.FULL; style < 4; ++style ) { SimpleDateFormat dtfmt = (SimpleDateFormat) DateFormat.getDateInstance(style, loc); FieldPosition pos = new FieldPosition(0); @@ -1067,12 +1070,12 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { fromCalendar.setTimeInMillis(dtitv.getFromDate()); toCalendar.setTimeInMillis(dtitv.getToDate()); dtfmt.intervalFormatByAlgorithm(fromCalendar, toCalendar, str, pos); - } - } + } + } } /* - * Ticket#6396 DateIntervalInfo of ICU4J 4.0d3 throw NullPointerException + * Ticket#6396 DateIntervalInfo of ICU4J 4.0d3 throw NullPointerException */ @Test public void TestT6396() { @@ -1187,7 +1190,7 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { } catch (Exception e){} // Tests when "if ( firstPatternIndex == -1 || secondPatternIndex == -1 )" is true - dii = (DateIntervalInfo) dii.cloneAsThawed(); + dii = dii.cloneAsThawed(); try{ dii.setFallbackIntervalPattern(""); errln("DateIntervalInfo.setFallbackIntervalPattern(String fallbackPattern) " + @@ -1242,11 +1245,11 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { // Tests when "if ( lrgDiffCalUnit > MINIMUM_SUPPORTED_CALENDAR_FIELD )" is true // MINIMUM_SUPPORTED_CALENDAR_FIELD = Calendar.SECOND; try{ - dii = (DateIntervalInfo) dii.cloneAsThawed(); + dii = dii.cloneAsThawed(); dii.setIntervalPattern("", Calendar.SECOND+1, ""); errln("DateIntervalInfo.setIntervalPattern(String,int,String) " + "was suppose to return an exception when the " + - "variable 'lrgDiffCalUnit' is greater than " + + "variable 'lrgDiffCalUnit' is greater than " + "MINIMUM_SUPPORTED_CALENDAR_FIELD."); } catch(Exception e){} } @@ -1465,7 +1468,7 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { "Custom DateIntervalInfo objects should not mess up cache", expected, dif.format(from, to, new StringBuffer(), new FieldPosition(0)) - .toString()); + .toString()); } @@ -1505,7 +1508,7 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { "Custom DateIntervalInfo objects should not mess up cache", expected, dif.format(from, to, new StringBuffer(), new FieldPosition(0)) - .toString()); + .toString()); } @Test @@ -1545,13 +1548,13 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { @Test public void TestTicket11583 () { ULocale[] locales = { - ULocale.ENGLISH, - SPANISH, - LA_SPANISH, + ULocale.ENGLISH, + SPANISH, + LA_SPANISH, }; String[] skeletons = { - "yMMMMd", "yMMMM", "MMMM", - "yMMMd", "yMMM", "MMM", + "yMMMMd", "yMMMM", "MMMM", + "yMMMd", "yMMM", "MMM", "yMMd", "yMMdd", "yMM", "MM", "yMdd", "yMd", "yM", "M" }; @@ -1568,10 +1571,10 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { DateFormat dateFormat = DateFormat.getPatternInstance(skeleton, locale); String dateFormatPattern = ((SimpleDateFormat)dateFormat).toPattern(); - + DateIntervalFormat intervalFormat = DateIntervalFormat.getInstance(skeleton, locale); DateIntervalInfo intervalInfo = intervalFormat.getDateIntervalInfo(); - + if (skeleton.equals(filterPattern)) { logln(filterPattern + " => " + intervalInfo.getRawPatterns().get(filterPattern)); } @@ -1584,7 +1587,7 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { String formattedEnd = dateFormat.format(endDate); PatternInfo patternInfo = intervalFormat.getRawPatterns().get("M"); - + String firstPart = patternInfo.getFirstPart(); String secondPart = patternInfo.getSecondPart(); if (!matches(dateFormatPattern, firstPart, secondPart)) { @@ -1596,7 +1599,7 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { + dateFormatPattern + "» and date interval format «" + firstPart + secondPart + "»."); } } - + logln(locale + "\tskeleton: «" + skeleton + "»\tpattern: «" + dateFormatPattern @@ -1623,7 +1626,7 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { // brute force for now int lastButOne = dateFormatPattern.length()-1; for (int i = 1; i < lastButOne; ++i) { - if (firstPart.startsWith(dateFormatPattern.substring(0,i)) + if (firstPart.startsWith(dateFormatPattern.substring(0,i)) && secondPart.endsWith(dateFormatPattern.substring(i,dateFormatPattern.length()))) { return true; } @@ -1633,7 +1636,7 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { @Test public void TestFPos_SkelWithSeconds () { - + final long[] deltas = { 0L, // none 200L, // 200 millisec @@ -1657,7 +1660,7 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { format = fmt; } }; - + final ExpectPosAndFormat[] exp_en_HHmm = { new ExpectPosAndFormat( 3, 5, "09:00" ), new ExpectPosAndFormat( 3, 5, "09:00" ), @@ -1780,7 +1783,7 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { expected = exp; } }; - + final LocaleAndSkeletonItem[] locSkelItems = { new LocaleAndSkeletonItem( "en", "HHmm", DateFormat.MINUTE_FIELD, exp_en_HHmm ), new LocaleAndSkeletonItem( "en", "HHmmss", DateFormat.MINUTE_FIELD, exp_en_HHmmss ), @@ -1793,7 +1796,7 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { new LocaleAndSkeletonItem( "ja", "yyMMddHHmmss", DateFormat.MINUTE_FIELD, exp_ja_yyMMddHHmmss ), new LocaleAndSkeletonItem( "ja", "yMMMdHHmmss", DateFormat.MINUTE_FIELD, exp_ja_yMMMdHHmmss ) }; - + //final String zoneGMT = "GMT"; final long startTimeGMT = 1416474000000L; // 2014 Nov 20 09:00 GMT @@ -1826,18 +1829,18 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { final DateIntervalFormat formatter = DateIntervalFormat.getInstance(DateFormat.YEAR_MONTH_DAY, ULocale.US); final ArrayList testIntervals = new ArrayList(); final ArrayListexpectedResults = new ArrayList(); - + // Create and save the input test data. TimeZone tz = TimeZone.getTimeZone("Americal/Los_Angeles"); Calendar intervalStart = Calendar.getInstance(tz, ULocale.US); - Calendar intervalEnd = Calendar.getInstance(tz, ULocale.US); + Calendar intervalEnd = Calendar.getInstance(tz, ULocale.US); intervalStart.set(2009, 6, 1); intervalEnd.set(2009, 6, 2); - testIntervals.add(new DateInterval(intervalStart.getTimeInMillis(), intervalEnd.getTimeInMillis())); + testIntervals.add(new DateInterval(intervalStart.getTimeInMillis(), intervalEnd.getTimeInMillis())); intervalStart.set(2015, 2, 27); intervalEnd.set(2015, 3, 1); testIntervals.add(new DateInterval(intervalStart.getTimeInMillis(), intervalEnd.getTimeInMillis())); - + // Run the formatter single-threaded to create and save the expected results. for (DateInterval interval: testIntervals) { FieldPosition pos = new FieldPosition(0); @@ -1845,9 +1848,10 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { formatter.format(interval, result, pos); expectedResults.add(result.toString()); } - + class TestThread extends Thread { public String errorMessage; + @Override public void run() { for (int loop=0; loop < 2000; ++loop) { ListIterator expectedItr = expectedResults.listIterator(); @@ -1866,7 +1870,7 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { } } } - + List threads = new ArrayList(); for (int i=0; i<4; ++i) { threads.add(new TestThread()); diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateTimeGeneratorTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateTimeGeneratorTest.java index 81d5d5fc851..0463b786b99 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateTimeGeneratorTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateTimeGeneratorTest.java @@ -23,6 +23,8 @@ import java.util.Random; import java.util.Set; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.PatternTokenizer; @@ -40,6 +42,7 @@ import com.ibm.icu.util.SimpleTimeZone; import com.ibm.icu.util.TimeZone; import com.ibm.icu.util.ULocale; +@RunWith(JUnit4.class) public class DateTimeGeneratorTest extends TestFmwk { public static boolean GENERATE_TEST_DATA; static { diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDateFormat.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDateFormat.java index 4426e65fa5c..ec36fc1e454 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDateFormat.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDateFormat.java @@ -6,7 +6,7 @@ * Corporation and others. All Rights Reserved. */ -/** +/** * Port From: JDK 1.4b1 : java.text.Format.IntlTestDateFormat * Source File: java/text/format/IntlTestDateFormat.java **/ @@ -25,12 +25,16 @@ import java.util.Random; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.DateFormat; import com.ibm.icu.text.SimpleDateFormat; import com.ibm.icu.util.ULocale; -public class IntlTestDateFormat extends com.ibm.icu.dev.test.TestFmwk { +@RunWith(JUnit4.class) +public class IntlTestDateFormat extends TestFmwk { // Values in milliseconds (== Date) private static final long ONESECOND = 1000; private static final long ONEMINUTE = 60 * ONESECOND; @@ -52,12 +56,12 @@ public class IntlTestDateFormat extends com.ibm.icu.dev.test.TestFmwk { public IntlTestDateFormat() { //Constructure } - + @Before public void init() throws Exception { fFormat = DateFormat.getInstance(); } - + @Test public void TestULocale() { localeTest(ULocale.getDefault(), "Default Locale"); @@ -144,7 +148,7 @@ public class IntlTestDateFormat extends com.ibm.icu.dev.test.TestFmwk { SimpleDateFormat s = (SimpleDateFormat) fFormat; logln(fTestName + " Pattern " + s.toPattern()); } - + private void tryDate(Date theDate) { final int DEPTH = 10; Date[] date = new Date[DEPTH]; diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDateFormatAPI.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDateFormatAPI.java index 3fb37fe75f1..8e950686f77 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDateFormatAPI.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDateFormatAPI.java @@ -6,7 +6,7 @@ * Corporation and others. All Rights Reserved. **/ -/** +/** * Port From: JDK 1.4b1 : java.text.Format.IntlTestDateFormatAPI * Source File: java/text/format/IntlTestDateFormatAPI.java **/ @@ -25,7 +25,10 @@ import java.util.Date; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.dev.test.TestUtil; import com.ibm.icu.dev.test.TestUtil.JavaVendor; import com.ibm.icu.text.DateFormat; @@ -33,7 +36,8 @@ import com.ibm.icu.text.NumberFormat; import com.ibm.icu.util.Calendar; import com.ibm.icu.util.TimeZone; -public class IntlTestDateFormatAPI extends com.ibm.icu.dev.test.TestFmwk +@RunWith(JUnit4.class) +public class IntlTestDateFormatAPI extends TestFmwk { // Test that the equals method works correctly. @Test diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDateFormatAPIC.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDateFormatAPIC.java index 52224afb1ca..91e5e8d2b82 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDateFormatAPIC.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDateFormatAPIC.java @@ -7,7 +7,7 @@ ******************************************************************************* */ -/** +/** * Port From: ICU4C v1.8.1 : format : IntlTestDateFormatAPI * Source File: $ICU4CRoot/source/test/intltest/dtfmapts.cpp **/ @@ -19,7 +19,10 @@ import java.text.ParsePosition; import java.util.Date; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.DateFormat; import com.ibm.icu.text.DecimalFormat; import com.ibm.icu.text.NumberFormat; @@ -30,7 +33,8 @@ import com.ibm.icu.text.SimpleDateFormat; * try to test the full functionality. It just calls each function in the class and * verifies that it works on a basic level. */ -public class IntlTestDateFormatAPIC extends com.ibm.icu.dev.test.TestFmwk { +@RunWith(JUnit4.class) +public class IntlTestDateFormatAPIC extends TestFmwk { /** * Test hiding of parse() and format() APIs in the Format hierarchy. * We test the entire hierarchy, even though this test is located in @@ -38,17 +42,17 @@ public class IntlTestDateFormatAPIC extends com.ibm.icu.dev.test.TestFmwk { */ @Test public void TestNameHiding() { - + // N.B.: This test passes if it COMPILES, since it's a test of // compile-time name hiding. - + Date dateObj = new Date(0); Number numObj = new Double(3.1415926535897932384626433832795); StringBuffer strBuffer = new StringBuffer(""); String str; FieldPosition fpos = new FieldPosition(0); ParsePosition ppos = new ParsePosition(0); - + // DateFormat calling Format API { logln("DateFormat"); @@ -60,7 +64,7 @@ public class IntlTestDateFormatAPIC extends com.ibm.icu.dev.test.TestFmwk { errln("FAIL: Can't create DateFormat"); } } - + // SimpleDateFormat calling Format & DateFormat API { logln("SimpleDateFormat"); @@ -78,7 +82,7 @@ public class IntlTestDateFormatAPIC extends com.ibm.icu.dev.test.TestFmwk { System.out.println(pe); } } - + // NumberFormat calling Format API { logln("NumberFormat"); @@ -90,7 +94,7 @@ public class IntlTestDateFormatAPIC extends com.ibm.icu.dev.test.TestFmwk { errln("FAIL: Can't create NumberFormat"); } } - + // DecimalFormat calling Format & NumberFormat API { logln("DecimalFormat"); @@ -113,7 +117,7 @@ public class IntlTestDateFormatAPIC extends com.ibm.icu.dev.test.TestFmwk { System.out.println(pe); } } - + //ICU4J have not the classes ChoiceFormat and MessageFormat /* // ChoiceFormat calling Format & NumberFormat API @@ -135,8 +139,8 @@ public class IntlTestDateFormatAPIC extends com.ibm.icu.dev.test.TestFmwk { System.out.println(pe); } } - - + + // MessageFormat calling Format API { logln("MessageFormat"); diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDateFormatSymbols.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDateFormatSymbols.java index 6b39e73320a..4a3a6721373 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDateFormatSymbols.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDateFormatSymbols.java @@ -6,11 +6,11 @@ * Corporation and others. All Rights Reserved. **/ -/** +/** * Port From: JDK 1.4b1 : java.text.Format.IntlTestDateFormatSymbols * Source File: java/text/format/IntlTestDateFormatSymbols.java **/ - + /* @test 1.4 98/03/06 @summary test International Date Format Symbols @@ -21,12 +21,16 @@ package com.ibm.icu.dev.test.format; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.DateFormatSymbols; import com.ibm.icu.util.Calendar; import com.ibm.icu.util.ULocale; -public class IntlTestDateFormatSymbols extends com.ibm.icu.dev.test.TestFmwk +@RunWith(JUnit4.class) +public class IntlTestDateFormatSymbols extends TestFmwk { // Test getMonths @Test @@ -56,7 +60,7 @@ public class IntlTestDateFormatSymbols extends com.ibm.icu.dev.test.TestFmwk int[] context = {DateFormatSymbols.STANDALONE, DateFormatSymbols.FORMAT}; int[] width = {DateFormatSymbols.WIDE, DateFormatSymbols.ABBREVIATED, DateFormatSymbols.NARROW}; - + for (int i = 0; i < context.length; i++) { for (int j = 0; j < width.length; j++) { String[] month =symbol.getMonths(context[i],width[j]); @@ -70,7 +74,7 @@ public class IntlTestDateFormatSymbols extends com.ibm.icu.dev.test.TestFmwk } } } - + @Test public void TestGetWeekdays2(){ DateFormatSymbols symbol; @@ -78,7 +82,7 @@ public class IntlTestDateFormatSymbols extends com.ibm.icu.dev.test.TestFmwk int[] context = {DateFormatSymbols.STANDALONE, DateFormatSymbols.FORMAT}; int[] width = {DateFormatSymbols.WIDE, DateFormatSymbols.ABBREVIATED, DateFormatSymbols.NARROW}; - + for (int i = 0; i < context.length; i++) { for (int j = 0; j < width.length; j++) { String[] wd =symbol.getWeekdays(context[i],width[j]); @@ -91,9 +95,9 @@ public class IntlTestDateFormatSymbols extends com.ibm.icu.dev.test.TestFmwk } } } - + } - + @Test public void TestGetEraNames(){ DateFormatSymbols symbol; @@ -102,7 +106,7 @@ public class IntlTestDateFormatSymbols extends com.ibm.icu.dev.test.TestFmwk for (int i = 0; i < s.length; i++) { logln(s[i]); } - + } private boolean UnicodeStringsArePrefixes(String[] prefixArray, String[] baseArray){ @@ -508,7 +512,7 @@ public class IntlTestDateFormatSymbols extends com.ibm.icu.dev.test.TestFmwk if(! en.equals(fr)) { errln("ERROR: Clone failed"); } - + final String[] shortYearNames = zhChiCal.getYearNames(DateFormatSymbols.FORMAT, DateFormatSymbols.ABBREVIATED); final String[] narrowYearNames = zhChiCal.getYearNames(DateFormatSymbols.STANDALONE, DateFormatSymbols.NARROW); if (shortYearNames == null || shortYearNames.length != 60 || @@ -537,7 +541,7 @@ public class IntlTestDateFormatSymbols extends com.ibm.icu.dev.test.TestFmwk !testZodiacNames[0].equals("Rat") || !testZodiacNames[11].equals("Pig")) { errln("ERROR: setZodiacNames then getZodiacNames not working for zh@calendar=chinese"); } - + String leapMonthPatternFmtAbbrev = zhChiCal.getLeapMonthPattern(DateFormatSymbols.FORMAT, DateFormatSymbols.ABBREVIATED); if (leapMonthPatternFmtAbbrev == null || !leapMonthPatternFmtAbbrev.equals("\u95F0{0}")) { errln("ERROR: invalid FORMAT/ABBREVIATED leapMonthPattern from zh@calendar=chinese"); diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDecimalFormatAPI.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDecimalFormatAPI.java index 9f28b1c057d..5ec2d856650 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDecimalFormatAPI.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDecimalFormatAPI.java @@ -25,14 +25,18 @@ import java.text.ParsePosition; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.math.BigDecimal; import com.ibm.icu.math.MathContext; import com.ibm.icu.text.DecimalFormat; import com.ibm.icu.text.DecimalFormatSymbols; import com.ibm.icu.text.NumberFormat; -public class IntlTestDecimalFormatAPI extends com.ibm.icu.dev.test.TestFmwk +@RunWith(JUnit4.class) +public class IntlTestDecimalFormatAPI extends TestFmwk { /** * Problem 1: simply running diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDecimalFormatAPIC.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDecimalFormatAPIC.java index 3532ed1e33b..5f0c778ea5c 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDecimalFormatAPIC.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDecimalFormatAPIC.java @@ -24,7 +24,10 @@ import java.util.List; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.CurrencyPluralInfo; import com.ibm.icu.text.DecimalFormat; import com.ibm.icu.text.DecimalFormatSymbols; @@ -34,7 +37,8 @@ import com.ibm.icu.util.ULocale; // This is an API test, not a unit test. It doesn't test very many cases, and doesn't // try to test the full functionality. It just calls each function in the class and // verifies that it works on a basic level. -public class IntlTestDecimalFormatAPIC extends com.ibm.icu.dev.test.TestFmwk { +@RunWith(JUnit4.class) +public class IntlTestDecimalFormatAPIC extends TestFmwk { // This test checks various generic API methods in DecimalFormat to achieve 100% API coverage. @Test diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDecimalFormatSymbols.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDecimalFormatSymbols.java index 360f3f2e904..a015c5bbc4e 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDecimalFormatSymbols.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDecimalFormatSymbols.java @@ -23,14 +23,18 @@ import java.util.Arrays; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.DecimalFormat; import com.ibm.icu.text.DecimalFormatSymbols; import com.ibm.icu.text.NumberingSystem; import com.ibm.icu.util.Currency; import com.ibm.icu.util.ULocale; -public class IntlTestDecimalFormatSymbols extends com.ibm.icu.dev.test.TestFmwk +@RunWith(JUnit4.class) +public class IntlTestDecimalFormatSymbols extends TestFmwk { // Test the API of DecimalFormatSymbols; primarily a simple get/set set. @Test diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDecimalFormatSymbolsC.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDecimalFormatSymbolsC.java index 77495f41d34..8f5e759b964 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDecimalFormatSymbolsC.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDecimalFormatSymbolsC.java @@ -18,14 +18,18 @@ import java.text.FieldPosition; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.DecimalFormat; import com.ibm.icu.text.DecimalFormatSymbols; /** * Tests for DecimalFormatSymbols **/ -public class IntlTestDecimalFormatSymbolsC extends com.ibm.icu.dev.test.TestFmwk { +@RunWith(JUnit4.class) +public class IntlTestDecimalFormatSymbolsC extends TestFmwk { /** * Test the API of DecimalFormatSymbols; primarily a simple get/set set. */ diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestNumberFormat.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestNumberFormat.java index b106de70c73..2f7dcb10c1f 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestNumberFormat.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestNumberFormat.java @@ -17,6 +17,8 @@ import java.util.Locale; import java.util.Random; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.DecimalFormat; @@ -26,7 +28,8 @@ import com.ibm.icu.text.NumberFormat; * This test does round-trip testing (format -> parse -> format -> parse -> etc.) of * NumberFormat. */ -public class IntlTestNumberFormat extends com.ibm.icu.dev.test.TestFmwk { +@RunWith(JUnit4.class) +public class IntlTestNumberFormat extends TestFmwk { public NumberFormat fNumberFormat; diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestNumberFormatAPI.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestNumberFormatAPI.java index 4c6167233e5..a4aa716d34f 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestNumberFormatAPI.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestNumberFormatAPI.java @@ -5,7 +5,7 @@ * Copyright (C) 1996-2009, International Business Machines * Corporation and others. All Rights Reserved. **/ -/** +/** * Port From: JDK 1.4b1 : java.text.Format.IntlTestNumberFormatAPI * Source File: java/text/format/IntlTestNumberFormatAPI.java **/ @@ -24,11 +24,15 @@ import java.text.ParsePosition; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.NumberFormat; import com.ibm.icu.util.ULocale; -public class IntlTestNumberFormatAPI extends com.ibm.icu.dev.test.TestFmwk +@RunWith(JUnit4.class) +public class IntlTestNumberFormatAPI extends TestFmwk { // This test checks various generic API methods in DecimalFormat to achieve 100% API coverage. @Test @@ -52,17 +56,17 @@ public class IntlTestNumberFormatAPI extends com.ibm.icu.dev.test.TestFmwk NumberFormat per = NumberFormat.getPercentInstance(); NumberFormat per_fr = NumberFormat.getPercentInstance(Locale.FRENCH); - + NumberFormat integer = NumberFormat.getIntegerInstance(); - + NumberFormat int_fr = NumberFormat.getIntegerInstance(Locale.FRENCH); - + //Fix "The variable is never used" compilation warnings logln("Currency : " + cur.format(1234.5)); logln("Percent : " + per.format(1234.5)); logln("Integer : " + integer.format(1234.5)); logln("Int_fr : " + int_fr.format(1234.5)); - + // ======= Test equality logln("Testing equality operator"); @@ -201,7 +205,7 @@ public class IntlTestNumberFormatAPI extends com.ibm.icu.dev.test.TestFmwk // errln("ERROR: Couldn't create a DecimalFormat"); // } } - + // Jitterbug 4451, for coverage @Test public void TestCoverage(){ @@ -216,11 +220,17 @@ public class IntlTestNumberFormatAPI extends com.ibm.icu.dev.test.TestFmwk errln("NumberFormat.getPattern(Locale, int) should delegate to (ULocale,)"); } } + @Override public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) {return null;} + @Override public StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos) {return null;} + @Override public StringBuffer format(BigInteger number, StringBuffer toAppendTo, FieldPosition pos) {return null;} + @Override public StringBuffer format(java.math.BigDecimal number, StringBuffer toAppendTo, FieldPosition pos) {return null;} + @Override public StringBuffer format(com.ibm.icu.math.BigDecimal number, StringBuffer toAppendTo, FieldPosition pos) {return null;} + @Override public Number parse(String text, ParsePosition parsePosition) {return null;} } new StubNumberFormat().run(); diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestSimpleDateFormatAPI.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestSimpleDateFormatAPI.java index c0852a013ba..afa0634cebc 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestSimpleDateFormatAPI.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestSimpleDateFormatAPI.java @@ -12,11 +12,11 @@ * Taligent is a registered trademark of Taligent, Inc. **/ -/** +/** * Port From: JDK 1.4b1 : java.text.Format.IntlTestSimpleDateFormatAPI * Source File: java/text/format/IntlTestSimpleDateFormatAPI.java **/ - + package com.ibm.icu.dev.test.format; import java.text.FieldPosition; @@ -27,7 +27,10 @@ import java.util.Date; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.DateFormatSymbols; import com.ibm.icu.text.SimpleDateFormat; @@ -35,7 +38,8 @@ import com.ibm.icu.text.SimpleDateFormat; * @test 1.4 98/03/06 * @summary test International Simple Date Format API */ -public class IntlTestSimpleDateFormatAPI extends com.ibm.icu.dev.test.TestFmwk +@RunWith(JUnit4.class) +public class IntlTestSimpleDateFormatAPI extends TestFmwk { // This test checks various generic API methods in DecimalFormat to achieve 100% API coverage. @Test @@ -154,7 +158,7 @@ public class IntlTestSimpleDateFormatAPI extends com.ibm.icu.dev.test.TestFmwk if( ! s3.equals(p1) ) { errln("ERROR: toLocalizedPattern() result did not match pattern applied"); } - + // ======= Test for Ticket 5684 (Parsing patterns with 'Y' and 'e' logln("Testing parse()"); @@ -182,7 +186,7 @@ public class IntlTestSimpleDateFormatAPI extends com.ibm.icu.dev.test.TestFmwk // errln("ERROR: Couldn't create a SimpleDateFormat"); // } } - + // Jitterbug 4451, for coverage @Test public void TestCoverage(){ diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/ListFormatterTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/ListFormatterTest.java index 9f52775b384..667525c2b00 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/ListFormatterTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/ListFormatterTest.java @@ -12,11 +12,14 @@ import java.util.ArrayList; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.ListFormatter; import com.ibm.icu.util.ULocale; +@RunWith(JUnit4.class) public class ListFormatterTest extends TestFmwk { String[] HardcodedTestData = { "", @@ -141,7 +144,7 @@ public class ListFormatterTest extends TestFmwk { assertEquals("4", strings[4], listFormat.format("A", "B", "C", "D")); assertEquals("5", strings[5], listFormat.format("A", "B", "C", "D", "E")); } - + @Test public void TestFromList() { ListFormatter listFormatter = ListFormatter.getInstance(ULocale.ENGLISH); @@ -151,16 +154,16 @@ public class ListFormatterTest extends TestFmwk { list.add("C"); assertEquals("list", "A, B, and C", listFormatter.format(list)); } - + @Test public void TestCreatePatternForNumItems() { ListFormatter listFormatter = ListFormatter.getInstance(ULocale.ENGLISH); assertEquals( "createPatternForNumItems", "{0}, {1}, and {2}", - listFormatter.getPatternForNumItems(3)); + listFormatter.getPatternForNumItems(3)); } - + @Test public void TestGetPatternForNumItemsException() { ListFormatter listFormatter = ListFormatter.getInstance(ULocale.ENGLISH); @@ -171,13 +174,13 @@ public class ListFormatterTest extends TestFmwk { // expected. } } - + @Test public void TestGetLocale() { assertEquals( "getLocale", ULocale.ENGLISH, ListFormatter.getInstance(ULocale.ENGLISH).getLocale()); } - + @Test public void Test9946() { ListFormatter listFormatter = ListFormatter.getInstance(ULocale.ENGLISH); diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/MeasureUnitTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/MeasureUnitTest.java index 14de333161e..361a79b5696 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/MeasureUnitTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/MeasureUnitTest.java @@ -28,6 +28,8 @@ import java.util.Set; import java.util.TreeMap; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.dev.test.serializable.FormatHandler; @@ -50,6 +52,7 @@ import com.ibm.icu.util.ULocale; * for information on how to update with each new release. * @author markdavis */ +@RunWith(JUnit4.class) public class MeasureUnitTest extends TestFmwk { static class OrderedPair extends Pair implements Comparable> { diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/MeasureUnitThreadTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/MeasureUnitThreadTest.java index e78f1cbf4de..e86ed12fe3a 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/MeasureUnitThreadTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/MeasureUnitThreadTest.java @@ -4,12 +4,15 @@ package com.ibm.icu.dev.test.format; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.util.Currency; import com.ibm.icu.util.MeasureUnit; import com.ibm.icu.util.ULocale; +@RunWith(JUnit4.class) public class MeasureUnitThreadTest extends TestFmwk { @Test diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/MessagePatternUtilTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/MessagePatternUtilTest.java index b53be9589c5..42e4c34a692 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/MessagePatternUtilTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/MessagePatternUtilTest.java @@ -17,7 +17,10 @@ import java.util.List; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.MessagePattern; import com.ibm.icu.text.MessagePatternUtil; import com.ibm.icu.text.MessagePatternUtil.ArgNode; @@ -31,7 +34,8 @@ import com.ibm.icu.text.MessagePatternUtil.VariantNode; * Test MessagePatternUtil (MessagePattern-as-tree-of-nodes API) * by building parallel trees of nodes and verifying that they match. */ -public final class MessagePatternUtilTest extends com.ibm.icu.dev.test.TestFmwk { +@RunWith(JUnit4.class) +public final class MessagePatternUtilTest extends TestFmwk { // The following nested "Expect..." classes are used to build // a tree structure parallel to what the MessagePatternUtil class builds. // These nested test classes are not static so that they have access to TestFmwk methods. diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/MessageRegressionTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/MessageRegressionTest.java index 2583a792e0c..28a57431465 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/MessageRegressionTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/MessageRegressionTest.java @@ -46,12 +46,16 @@ import java.util.Locale; import java.util.Map; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.MessageFormat; import com.ibm.icu.text.NumberFormat; import com.ibm.icu.util.ULocale; -public class MessageRegressionTest extends com.ibm.icu.dev.test.TestFmwk { +@RunWith(JUnit4.class) +public class MessageRegressionTest extends TestFmwk { /* @bug 4074764 * Null exception when formatting pattern with MessageFormat * with no parameters. @@ -178,7 +182,7 @@ public class MessageRegressionTest extends com.ibm.icu.dev.test.TestFmwk { pos.setErrorIndex(4); if (pos.getErrorIndex() != 4) errln("setErrorIndex failed, got " + pos.getErrorIndex() + " instead of 4"); - + if (objs != null) { errln("objs should be null"); } @@ -526,8 +530,8 @@ public class MessageRegressionTest extends com.ibm.icu.dev.test.TestFmwk { */ @Test public void Test4142938() { - String pat = "''Vous'' {0,choice,0#n''|1#}avez s\u00E9lectionne\u00E9 " + - "{0,choice,0#aucun|1#{0}} client{0,choice,0#s|1#|2#s} " + + String pat = "''Vous'' {0,choice,0#n''|1#}avez s\u00E9lectionne\u00E9 " + + "{0,choice,0#aucun|1#{0}} client{0,choice,0#s|1#|2#s} " + "personnel{0,choice,0#s|1#|2#s}."; MessageFormat mf = new MessageFormat(pat); @@ -535,13 +539,13 @@ public class MessageRegressionTest extends com.ibm.icu.dev.test.TestFmwk { "'Vous' n'avez s\u00E9lectionne\u00E9 aucun clients personnels.", "'Vous' avez s\u00E9lectionne\u00E9 ", "'Vous' avez s\u00E9lectionne\u00E9 " - }; + }; String[] SUFFIX = { null, " client personnel.", " clients personnels." }; - + for (int i=0; i<3; i++) { String out = mf.format(new Object[]{new Integer(i)}); if (SUFFIX[i] == null) { @@ -646,7 +650,7 @@ public class MessageRegressionTest extends com.ibm.icu.dev.test.TestFmwk { throw new RuntimeException("didn't get exception for invalid input"); } } - + @Test public void test4293229() { MessageFormat format = new MessageFormat("'''{'0}'' '''{0}'''"); @@ -658,12 +662,12 @@ public class MessageRegressionTest extends com.ibm.icu.dev.test.TestFmwk { expected + "\", got \"" + result + "\""); } } - + // This test basically ensures that the tests defined above also work with // valid named arguments. @Test public void testBugTestsWithNamesArguments() { - + { // Taken from Test4031438(). String pattern1 = "Impossible {arg1} has occurred -- status code is {arg0} and message is {arg2}."; String pattern2 = "Double '' Quotes {ARG_ZERO} test and quoted '{ARG_ONE}' test plus 'other {ARG_TWO} stuff'."; @@ -812,7 +816,7 @@ public class MessageRegressionTest extends com.ibm.icu.dev.test.TestFmwk { logln("\"" + mf.format(objs3) + "\""); } catch (Exception e) { errln("Exception thrown for null argument tests."); - } + } }{ // Taken from Test4118594(). String argName = "something_stupid"; MessageFormat mf = new MessageFormat("{"+ argName + "}, {" + argName + "}, {" + argName + "}"); @@ -870,7 +874,7 @@ public class MessageRegressionTest extends com.ibm.icu.dev.test.TestFmwk { ostream.writeObject(original); ostream.flush(); byte bytes[] = baos.toByteArray(); - + ObjectInputStream istream = new ObjectInputStream(new ByteArrayInputStream(bytes)); MessageFormat reconstituted = (MessageFormat)istream.readObject(); return reconstituted; diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatRegistrationTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatRegistrationTest.java index 44611b523c5..54feb3bad8c 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatRegistrationTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatRegistrationTest.java @@ -11,12 +11,16 @@ package com.ibm.icu.dev.test.format; import java.util.Arrays; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.NumberFormat; import com.ibm.icu.text.NumberFormat.SimpleNumberFormatFactory; import com.ibm.icu.util.ULocale; -public class NumberFormatRegistrationTest extends com.ibm.icu.dev.test.TestFmwk { +@RunWith(JUnit4.class) +public class NumberFormatRegistrationTest extends TestFmwk { @Test public void TestRegistration() { final ULocale SRC_LOC = ULocale.FRANCE; @@ -34,6 +38,7 @@ public class NumberFormatRegistrationTest extends com.ibm.icu.dev.test.TestFmwk currencyStyle = NumberFormat.getIntegerInstance(swapLoc); } + @Override public NumberFormat createFormat(ULocale loc, int formatType) { if (formatType == FORMAT_CURRENCY) { return currencyStyle; diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatRegressionTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatRegressionTest.java index d7d1f600efc..1dcb2ba84ad 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatRegressionTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatRegressionTest.java @@ -23,7 +23,10 @@ import java.util.Date; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.DateFormat; import com.ibm.icu.text.DecimalFormat; import com.ibm.icu.text.DecimalFormatSymbols; @@ -34,7 +37,8 @@ import com.ibm.icu.util.ULocale; /** * Performs regression test for MessageFormat **/ -public class NumberFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { +@RunWith(JUnit4.class) +public class NumberFormatRegressionTest extends TestFmwk { /** * alphaWorks upgrade */ @@ -76,7 +80,7 @@ public class NumberFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { // or this (with changes to fr_CH per cldrbug:9370): //nf.setGroupingUsed(false); // so they are done in DateFormat.setNumberFormat - + // create the DateFormat DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, loc); diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatRoundTripTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatRoundTripTest.java index f72ad205429..c4bf06fc1fc 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatRoundTripTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatRoundTripTest.java @@ -7,7 +7,7 @@ ******************************************************************************* */ -/** +/** * Porting From: ICU4C v1.8.1 : format : NumberFormatRoundTripTest * Source File: $ICU4CRoot/source/test/intltest/nmfmtrt.cpp **/ @@ -18,15 +18,19 @@ import java.util.Locale; import java.util.Random; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.DecimalFormat; import com.ibm.icu.text.NumberFormat; -/** +/** * Performs round-trip tests for NumberFormat **/ -public class NumberFormatRoundTripTest extends com.ibm.icu.dev.test.TestFmwk { - +@RunWith(JUnit4.class) +public class NumberFormatRoundTripTest extends TestFmwk { + public double MAX_ERROR = 1e-14; public double max_numeric_error = 0.0; public double min_numeric_error = 1.0; @@ -35,27 +39,27 @@ public class NumberFormatRoundTripTest extends com.ibm.icu.dev.test.TestFmwk { public boolean EXACT_NUMERIC_COMPARE = false; public boolean DEBUG = false; public boolean quick = true; - + @Test public void TestNumberFormatRoundTrip() { - + NumberFormat fmt = null; - + logln("Default Locale"); - + logln("Default Number format"); fmt = NumberFormat.getInstance(); _test(fmt); - + logln("Currency Format"); fmt = NumberFormat.getCurrencyInstance(); _test(fmt); - + logln("Percent Format"); fmt = NumberFormat.getPercentInstance(); _test(fmt); - - + + int locCount = 0; final Locale[] loc = NumberFormat.getAvailableLocales(); if(quick) { @@ -65,20 +69,20 @@ public class NumberFormatRoundTripTest extends com.ibm.icu.dev.test.TestFmwk { } for(int i = 0; i < locCount; ++i) { logln(loc[i].getDisplayName()); - + fmt = NumberFormat.getInstance(loc[i]); _test(fmt); - + fmt = NumberFormat.getCurrencyInstance(loc[i]); _test(fmt); - + fmt = NumberFormat.getPercentInstance(loc[i]); _test(fmt); } - + logln("Numeric error " + min_numeric_error + " to " + max_numeric_error); } - + /** * Return a random value from -range..+range. */ @@ -88,14 +92,14 @@ public class NumberFormatRoundTripTest extends com.ibm.icu.dev.test.TestFmwk { random = createRandom(); // use test framework's random seed } return random.nextDouble() * range; - } - + } + private void _test(NumberFormat fmt) { - + _test(fmt, Double.NaN); _test(fmt, Double.POSITIVE_INFINITY); _test(fmt, Double.NEGATIVE_INFINITY); - + _test(fmt, 500); _test(fmt, 0); _test(fmt, -0); @@ -106,50 +110,50 @@ public class NumberFormatRoundTripTest extends com.ibm.icu.dev.test.TestFmwk { _test(fmt, 9223372036854775808.0d); _test(fmt, -9223372036854775809.0d); //_test(fmt, 6.936065876100493E74d); - + // _test(fmt, 6.212122845281909E48d); for (int i = 0; i < 10; ++i) { - + _test(fmt, randomDouble(1)); - + _test(fmt, randomDouble(10000)); - + _test(fmt, Math.floor((randomDouble(10000)))); - + _test(fmt, randomDouble(1e50)); - + _test(fmt, randomDouble(1e-50)); - + _test(fmt, randomDouble(1e100)); - + _test(fmt, randomDouble(1e75)); - + _test(fmt, randomDouble(1e308) / ((DecimalFormat) fmt).getMultiplier()); - + _test(fmt, randomDouble(1e75) / ((DecimalFormat) fmt).getMultiplier()); - + _test(fmt, randomDouble(1e65) / ((DecimalFormat) fmt).getMultiplier()); - + _test(fmt, randomDouble(1e-292)); - + _test(fmt, randomDouble(1e-78)); - + _test(fmt, randomDouble(1e-323)); - + _test(fmt, randomDouble(1e-100)); - + _test(fmt, randomDouble(1e-78)); } } - + private void _test(NumberFormat fmt, double value) { _test(fmt, new Double(value)); } - + private void _test(NumberFormat fmt, long value) { _test(fmt, new Long(value)); } - + private void _test(NumberFormat fmt, Number value) { logln("test data = " + value); fmt.setMaximumFractionDigits(999); @@ -158,7 +162,7 @@ public class NumberFormatRoundTripTest extends com.ibm.icu.dev.test.TestFmwk { s = fmt.format(value.doubleValue()); else s = fmt.format(value.longValue()); - + Number n = new Double(0); boolean show = verbose; if (DEBUG) @@ -169,25 +173,25 @@ public class NumberFormatRoundTripTest extends com.ibm.icu.dev.test.TestFmwk { } catch (java.text.ParseException e) { System.out.println(e); } - + if (DEBUG) logln(s + " P> " /*+ n.getString(temp)*/); - + if (value.getClass().getName().equalsIgnoreCase("java.lang.Double")) s2 = fmt.format(n.doubleValue()); else s2 = fmt.format(n.longValue()); - + if (DEBUG) logln(/*n.getString(temp) +*/ " F> " + s2); - + if (STRING_COMPARE) { if (!s.equals(s2)) { errln("*** STRING ERROR \"" + s + "\" != \"" + s2 + "\""); show = true; } } - + if (EXACT_NUMERIC_COMPARE) { if (value != n) { errln("*** NUMERIC ERROR"); @@ -196,42 +200,42 @@ public class NumberFormatRoundTripTest extends com.ibm.icu.dev.test.TestFmwk { } else { // Compute proportional error double error = proportionalError(value, n); - + if (error > MAX_ERROR) { errln("*** NUMERIC ERROR " + error); show = true; } - + if (error > max_numeric_error) max_numeric_error = error; if (error < min_numeric_error) min_numeric_error = error; } - + if (show) logln( /*value.getString(temp) +*/ value.getClass().getName() + " F> " + s + " P> " + /*n.getString(temp) +*/ n.getClass().getName() + " F> " + s2); - + } - + private double proportionalError(Number a, Number b) { double aa,bb; - + if(a.getClass().getName().equalsIgnoreCase("java.lang.Double")) aa = a.doubleValue(); else aa = a.longValue(); - + if(a.getClass().getName().equalsIgnoreCase("java.lang.Double")) bb = b.doubleValue(); else bb = b.longValue(); - + double error = aa - bb; - if(aa != 0 && bb != 0) + if(aa != 0 && bb != 0) error /= aa; - + return Math.abs(error); - } + } } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatSpecificationTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatSpecificationTest.java index a657158809e..ebbc00cfe1e 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatSpecificationTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatSpecificationTest.java @@ -9,6 +9,8 @@ package com.ibm.icu.dev.test.format; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.DecimalFormat; @@ -21,6 +23,7 @@ import com.ibm.icu.util.ULocale; * @author rocketman * */ +@RunWith(JUnit4.class) public class NumberFormatSpecificationTest extends TestFmwk { @Test public void TestBasicPatterns() { @@ -32,9 +35,9 @@ public class NumberFormatSpecificationTest extends TestFmwk { assertEquals("", "1234,567", formatFrWithPattern(num, "###0.#####")); assertEquals("", "1234,5670", formatFrWithPattern(num, "###0.0000#")); assertEquals("", "01234,5670", formatFrWithPattern(num, "00000.0000")); - assertEquals("", "1 234,57 €", formatFrWithPattern(num, "#,##0.00 ¤")); + assertEquals("", "1 234,57 €", formatFrWithPattern(num, "#,##0.00 ¤")); } - + @Test public void TestNfSetters() { NumberFormat nf = nfWithPattern("#,##0.##"); @@ -42,9 +45,9 @@ public class NumberFormatSpecificationTest extends TestFmwk { nf.setMinimumIntegerDigits(4); assertEquals("", "34 567,89", format(1234567.89, nf)); assertEquals("", "0 034,56", format(34.56, nf)); - + } - + @Test public void TestRounding() { assertEquals("", "1,0", formatFrWithPattern(1.25, "0.5")); @@ -58,7 +61,7 @@ public class NumberFormatSpecificationTest extends TestFmwk { assertEquals("", "273,00", formatFrWithPattern(272.0, "2.73")); assertEquals("", "1 03,60", formatFrWithPattern(104.0, "#,#3.70")); } - + @Test public void TestSignificantDigits() { assertEquals("", "1230", formatFrWithPattern(1234.0, "@@@")); @@ -70,9 +73,9 @@ public class NumberFormatSpecificationTest extends TestFmwk { assertEquals("", "12 34 567", formatFrWithPattern(1234567.0, "@@@@,@@,@##")); assertEquals("", "12 34 567", formatFrWithPattern(1234567.001, "@@@@,@@,@##")); assertEquals("", "12 34 567", formatFrWithPattern(1234567.001, "@@@@,@@,###")); - assertEquals("", "1 200", formatFrWithPattern(1234.0, "#,#@@")); + assertEquals("", "1 200", formatFrWithPattern(1234.0, "#,#@@")); } - + @Test public void TestScientificNotation() { assertEquals("", "1,23E4", formatFrWithPattern(12345.0, "0.00E0")); @@ -89,7 +92,7 @@ public class NumberFormatSpecificationTest extends TestFmwk { assertEquals("", "170,0E-3", formatFrWithPattern(0.17, "##0.000#E0")); } } - + @Test public void TestPercent() { assertEquals("", "57,3%", formatFrWithPattern(0.573, "0.0%")); @@ -99,9 +102,9 @@ public class NumberFormatSpecificationTest extends TestFmwk { assertEquals("", "%3,260", formatFrWithPattern(0.0326, "%@@@@")); assertEquals("", "%1 540", formatFrWithPattern(15.43, "%#,@@@")); assertEquals("", "%1 656,4", formatFrWithPattern(16.55, "%#,##4.1")); - assertEquals("", "%16,3E3", formatFrWithPattern(162.55, "%##0.00E0")); + assertEquals("", "%16,3E3", formatFrWithPattern(162.55, "%##0.00E0")); } - + @Test public void TestPerMilli() { assertEquals("", "573,0‰", formatFrWithPattern(0.573, "0.0‰")); @@ -113,7 +116,7 @@ public class NumberFormatSpecificationTest extends TestFmwk { assertEquals("", "‰16 551,7", formatFrWithPattern(16.55, "‰#,##4.1")); assertEquals("", "‰163E3", formatFrWithPattern(162.55, "‰##0.00E0")); } - + @Test public void TestPadding() { assertEquals("", "$***1 234", formatFrWithPattern(1234, "$**####,##0")); @@ -132,31 +135,31 @@ public class NumberFormatSpecificationTest extends TestFmwk { DecimalFormat fmt = new DecimalFormat("¤¤ **#######0", sym); fmt.setCurrency(Currency.getInstance("JPY")); if (!logKnownIssue("11025", "Padding broken when used with currencies")) { - assertEquals("", "JPY ****433", fmt.format(433.22)); + assertEquals("", "JPY ****433", fmt.format(433.22)); } } { DecimalFormatSymbols sym = new DecimalFormatSymbols(ULocale.US); DecimalFormat fmt = new DecimalFormat("¤¤ **#######0;¤¤ (#)", sym); - assertEquals("", "USD (433.22)", fmt.format(-433.22)); + assertEquals("", "USD (433.22)", fmt.format(-433.22)); } assertEquals("", "QU***43,3E-1", formatFrWithPattern(4.33, "QU**00.#####E0")); { DecimalFormatSymbols sym = new DecimalFormatSymbols(ULocale.FRANCE); sym.setExponentSeparator("EE"); DecimalFormat fmt = new DecimalFormat("QU**00.#####E0", sym); - assertEquals("", "QU**43,3EE-1", fmt.format(4.33)); + assertEquals("", "QU**43,3EE-1", fmt.format(4.33)); } // padding cannot work as intended with scientific notation. assertEquals("", "QU**43,32E-1", formatFrWithPattern(4.332, "QU**00.#####E0")); } - + private static String formatFrWithPattern(double d, String pattern) { DecimalFormatSymbols sym = new DecimalFormatSymbols(ULocale.FRANCE); DecimalFormat fmt = new DecimalFormat(pattern, sym); return fmt.format(d).replace('\u00a0', ' '); } - + private static NumberFormat nfWithPattern(String pattern) { DecimalFormatSymbols sym = new DecimalFormatSymbols(ULocale.FRANCE); return new DecimalFormat(pattern, sym); @@ -165,6 +168,6 @@ public class NumberFormatSpecificationTest extends TestFmwk { private static String format(double d, NumberFormat nf) { return nf.format(d).replace('\u00a0', ' '); } - + } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatTest.java index 21c190c5e82..23c699bb03c 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatTest.java @@ -35,6 +35,8 @@ import java.util.Locale; import java.util.Set; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.dev.test.TestUtil; @@ -66,6 +68,7 @@ import com.ibm.icu.util.Currency.CurrencyUsage; import com.ibm.icu.util.CurrencyAmount; import com.ibm.icu.util.ULocale; +@RunWith(JUnit4.class) public class NumberFormatTest extends TestFmwk { @Test diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberRegressionTests.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberRegressionTests.java index 0b03a846b7d..f805d8a1106 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberRegressionTests.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberRegressionTests.java @@ -39,6 +39,8 @@ import java.util.Date; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.ICUData; @@ -51,6 +53,7 @@ import com.ibm.icu.util.GregorianCalendar; import com.ibm.icu.util.ULocale; import com.ibm.icu.util.VersionInfo; +@RunWith(JUnit4.class) public class NumberRegressionTests extends TestFmwk { private static final char EURO = '\u20ac'; diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/PluralFormatTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/PluralFormatTest.java index 96fbcf4e86d..129713c5ee4 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/PluralFormatTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/PluralFormatTest.java @@ -13,6 +13,8 @@ import java.util.Locale; import java.util.Map; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.Utility; @@ -25,6 +27,7 @@ import com.ibm.icu.util.ULocale; * @author tschumann (Tim Schumann) * */ +@RunWith(JUnit4.class) public class PluralFormatTest extends TestFmwk { private void helperTestRules(String localeIDs, String testPattern, Map changes) { String[] locales = Utility.split(localeIDs, ','); diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/PluralFormatUnitTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/PluralFormatUnitTest.java index 100e83778a2..3cb3a04e03b 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/PluralFormatUnitTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/PluralFormatUnitTest.java @@ -19,6 +19,8 @@ import java.util.Map; import java.util.Set; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.DecimalFormat; @@ -35,6 +37,7 @@ import com.ibm.icu.util.ULocale; * @author tschumann (Tim Schumann) * */ +@RunWith(JUnit4.class) public class PluralFormatUnitTest extends TestFmwk { @Test public void TestConstructor() { @@ -402,7 +405,7 @@ public class PluralFormatUnitTest extends TestFmwk { assertEquals("offset-decimals format(2)", "another 1.0 meters", pf2.format(2)); assertEquals("offset-decimals format(2.5)", "another 1.5 meters", pf2.format(2.5)); } - + @Test public void TestNegative() { PluralFormat pluralFormat = new PluralFormat(ULocale.ENGLISH, "one{# foot}other{# feet}"); diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/PluralRangesTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/PluralRangesTest.java index 25653afd4d4..5f8b81f08f2 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/PluralRangesTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/PluralRangesTest.java @@ -11,6 +11,8 @@ package com.ibm.icu.dev.test.format; import java.util.Arrays; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.SimpleFormatterImpl; @@ -26,8 +28,9 @@ import com.ibm.icu.util.ULocale; /** * @author markdavis - * + * */ +@RunWith(JUnit4.class) public class PluralRangesTest extends TestFmwk { @Test public void TestLocaleData() { diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/PluralRulesTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/PluralRulesTest.java index 3de97b1476d..c5bb67dafaa 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/PluralRulesTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/PluralRulesTest.java @@ -33,6 +33,8 @@ import java.util.TreeMap; import java.util.TreeSet; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.dev.test.serializable.SerializableTestUtility; @@ -55,6 +57,7 @@ import com.ibm.icu.util.ULocale; * @author dougfelt (Doug Felt) * @author markdavis (Mark Davis) [for fractional support] */ +@RunWith(JUnit4.class) public class PluralRulesTest extends TestFmwk { PluralRulesFactory factory = PluralRulesFactory.NORMAL; @@ -862,14 +865,14 @@ public class PluralRulesTest extends TestFmwk { enum StandardPluralCategories { zero, one, two, few, many, other; /** - * + * */ private static final Set ALL = Collections.unmodifiableSet(EnumSet .allOf(StandardPluralCategories.class)); /** * Return a mutable set - * + * * @param source * @return */ @@ -882,6 +885,7 @@ public class PluralRulesTest extends TestFmwk { } static final Comparator> SHORTEST_FIRST = new Comparator>() { + @Override public int compare(Set arg0, Set arg1) { int diff = arg0.size() - arg1.size(); if (diff != 0) { @@ -927,6 +931,7 @@ public class PluralRulesTest extends TestFmwk { } private static final Comparator PLURAL_RULE_COMPARATOR = new Comparator() { + @Override public int compare(PluralRules o1, PluralRules o2) { return o1.compareTo(o2); } @@ -1066,12 +1071,14 @@ public class PluralRulesTest extends TestFmwk { } public static class FixedDecimalHandler implements SerializableTestUtility.Handler { + @Override public Object[] getTestObjects() { FixedDecimal items[] = { new FixedDecimal(3d), new FixedDecimal(3d, 2), new FixedDecimal(3.1d, 1), new FixedDecimal(3.1d, 2), }; return items; } + @Override public boolean hasSameBehavior(Object a, Object b) { FixedDecimal a1 = (FixedDecimal) a; FixedDecimal b1 = (FixedDecimal) b; diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/RBNFParseTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/RBNFParseTest.java index 9322fa86c02..dfdf0222fa8 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/RBNFParseTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/RBNFParseTest.java @@ -11,11 +11,14 @@ package com.ibm.icu.dev.test.format; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.RuleBasedNumberFormat; import com.ibm.icu.util.ULocale; +@RunWith(JUnit4.class) public class RBNFParseTest extends TestFmwk { @Test public void TestParse() { diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/RbnfRoundTripTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/RbnfRoundTripTest.java index 9e959060508..a8574c21cb0 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/RbnfRoundTripTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/RbnfRoundTripTest.java @@ -11,10 +11,13 @@ package com.ibm.icu.dev.test.format; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.RuleBasedNumberFormat; +@RunWith(JUnit4.class) public class RbnfRoundTripTest extends TestFmwk { /** * Perform an exhaustive round-trip test on the English spellout rules diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/RbnfTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/RbnfTest.java index ec80686c447..fbfaa6b962e 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/RbnfTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/RbnfTest.java @@ -14,6 +14,8 @@ import java.util.Locale; import java.util.Random; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.math.BigDecimal; @@ -28,6 +30,7 @@ import com.ibm.icu.util.ULocale; * This does not test lenient parse mode, since testing the default implementation * introduces a dependency on collation. See RbnfLenientScannerTest. */ +@RunWith(JUnit4.class) public class RbnfTest extends TestFmwk { static String fracRules = "%main:\n" + diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/RelativeDateTimeFormatterTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/RelativeDateTimeFormatterTest.java index 95863977275..b9c67e43c77 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/RelativeDateTimeFormatterTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/RelativeDateTimeFormatterTest.java @@ -11,6 +11,8 @@ package com.ibm.icu.dev.test.format; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.math.BigDecimal; @@ -24,6 +26,7 @@ import com.ibm.icu.text.RelativeDateTimeFormatter.RelativeUnit; import com.ibm.icu.text.RelativeDateTimeFormatter.Style; import com.ibm.icu.util.ULocale; +@RunWith(JUnit4.class) public class RelativeDateTimeFormatterTest extends TestFmwk { @Test public void TestRelativeDateWithQuantity() { diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/ScientificNumberFormatterTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/ScientificNumberFormatterTest.java index 09b79d2ba79..02357e48930 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/ScientificNumberFormatterTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/ScientificNumberFormatterTest.java @@ -9,6 +9,8 @@ package com.ibm.icu.dev.test.format; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.DecimalFormat; @@ -20,6 +22,7 @@ import com.ibm.icu.util.ULocale; * @author rocketman * */ +@RunWith(JUnit4.class) public class ScientificNumberFormatterTest extends TestFmwk { @Test public void TestBasic() { @@ -35,8 +38,8 @@ public class ScientificNumberFormatterTest extends TestFmwk { "1.23456×10⁻⁷⁸", superscript.format(1.23456e-78)); } - - + + @Test public void TestFarsi() { ScientificNumberFormatter fmt = ScientificNumberFormatter.getMarkupInstance( @@ -54,14 +57,14 @@ public class ScientificNumberFormatterTest extends TestFmwk { decfmt.applyPattern("0.00E+0"); ScientificNumberFormatter fmt = ScientificNumberFormatter.getMarkupInstance( decfmt, "", ""); - + assertEquals( "", "6.02×10+23", fmt.format(6.02e23)); } - + @Test public void TestPlusSignInExponentSuperscript() { DecimalFormat decfmt = (DecimalFormat) NumberFormat.getScientificInstance(ULocale.ENGLISH); @@ -73,7 +76,7 @@ public class ScientificNumberFormatterTest extends TestFmwk { "6.02×10⁺²³", fmt.format(6.02e23)); } - + @Test public void TestFixedDecimalMarkup() { DecimalFormat decfmt = (DecimalFormat) NumberFormat.getInstance(ULocale.ENGLISH); @@ -84,7 +87,7 @@ public class ScientificNumberFormatterTest extends TestFmwk { "123,456", fmt.format(123456.0)); } - + @Test public void TestFixedDecimalSuperscript() { DecimalFormat decfmt = (DecimalFormat) NumberFormat.getInstance(ULocale.ENGLISH); diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/SelectFormatAPITest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/SelectFormatAPITest.java index 304376ee603..55cb178c67e 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/SelectFormatAPITest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/SelectFormatAPITest.java @@ -4,7 +4,7 @@ ******************************************************************************* * Copyright (c) 2004-2011, International Business Machines * Corporation and others. All Rights Reserved. - * Copyright (C) 2010 , Yahoo! Inc. + * Copyright (C) 2010 , Yahoo! Inc. ******************************************************************************* */ package com.ibm.icu.dev.test.format; @@ -13,16 +13,19 @@ import java.text.FieldPosition; import java.text.ParsePosition; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.SelectFormat; /** - * @author kirtig + * @author kirtig * This class tests the API functionality of the SelectFormat */ +@RunWith(JUnit4.class) public class SelectFormatAPITest extends TestFmwk { - + static final String SIMPLE_PATTERN1 = "feminine {feminineVerbValue1} other{otherVerbValue1}"; static final String SIMPLE_PATTERN2 = "feminine {feminineVerbValue2} other{otherVerbValue2}"; @@ -33,7 +36,7 @@ public class SelectFormatAPITest extends TestFmwk { public void TestConstructors() { SelectFormat selFmt = new SelectFormat(SIMPLE_PATTERN1); assertNotNull("Error: TestConstructors - SelectFormat object constructed " - + "with argument constructor is null" , selFmt ); + + "with argument constructor is null" , selFmt ); } /** @@ -46,19 +49,19 @@ public class SelectFormatAPITest extends TestFmwk { //Check equality for pattern constructed SelectFormats selFmt1 = new SelectFormat(SIMPLE_PATTERN1); SelectFormat selFmt2 = new SelectFormat(SIMPLE_PATTERN1); - assertTrue("Equals test failed while checking equality for " - + "pattern constructed SelectFormats ." - , selFmt1.equals(selFmt2) ); + assertTrue("Equals test failed while checking equality for " + + "pattern constructed SelectFormats ." + , selFmt1.equals(selFmt2) ); - //Check equality for 2 objects + //Check equality for 2 objects Object selFmt3 = new SelectFormat(SIMPLE_PATTERN1); Object selFmt4 = new SelectFormat(SIMPLE_PATTERN1); Object selFmt5 = new SelectFormat(SIMPLE_PATTERN2); - assertTrue("Equals test failed while checking equality for object 1." + assertTrue("Equals test failed while checking equality for object 1." , selFmt3.equals(selFmt4) ); - assertTrue("Equals test failed while checking equality for object 2." + assertTrue("Equals test failed while checking equality for object 2." , selFmt1.equals(selFmt3) ); - assertFalse("Equals test failed while checking equality for object 3." + assertFalse("Equals test failed while checking equality for object 3." , selFmt3.equals(selFmt5) ); } @@ -134,7 +137,7 @@ public class SelectFormatAPITest extends TestFmwk { SelectFormat selFmt1 = new SelectFormat(SIMPLE_PATTERN1); String expected = "feminineVerbValue1"; assertEquals("Failed in TestFormat with unexpected output 1" - , expected + , expected , selFmt1.format("feminine") ); //Check format with appendTo for pattern constructed object @@ -143,7 +146,7 @@ public class SelectFormatAPITest extends TestFmwk { assertEquals("Failed in TestFormat with unexpected output 2" , expected , (selFmt1.format("other", strBuf, new FieldPosition(0))).toString()); - + //Check format throws exception on invalid argument. boolean threwException = false; try { diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/SelectFormatUnitTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/SelectFormatUnitTest.java index 7330294e04a..e8b770c3ade 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/SelectFormatUnitTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/SelectFormatUnitTest.java @@ -4,22 +4,25 @@ ******************************************************************************* * Copyright (c) 2004-2011, International Business Machines * Corporation and others. All Rights Reserved. - * Copyright (C) 2010 , Yahoo! Inc. + * Copyright (C) 2010 , Yahoo! Inc. ******************************************************************************* */ package com.ibm.icu.dev.test.format; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.SelectFormat; /** - * @author kirtig + * @author kirtig * This class does the unit testing for the SelectFormat */ +@RunWith(JUnit4.class) public class SelectFormatUnitTest extends TestFmwk { - + static final String SIMPLE_PATTERN = "feminine {feminineVerbValue} other{otherVerbValue}"; /** @@ -33,8 +36,8 @@ public class SelectFormatUnitTest extends TestFmwk { "odd{foo},other{bar}", "od d{foo} other{bar}", "odd{foo}{foobar}other{foo}", - "odd{foo1}other{foo2}}", - "odd{foo1}other{{foo2}", + "odd{foo1}other{foo2}}", + "odd{foo1}other{{foo2}", "odd{fo{o1}other{foo2}}" }; @@ -59,7 +62,7 @@ public class SelectFormatUnitTest extends TestFmwk { } /** - * Unit tests for invalid keywords + * Unit tests for invalid keywords */ @Test public void TestInvalidKeyword() { @@ -86,7 +89,7 @@ public class SelectFormatUnitTest extends TestFmwk { + "for keyword: " + keywords[i] ); } catch (IllegalArgumentException e){ assertEquals("Error:TestInvalidKeyword failed with unexpected " - +"error message for keyword: " + keywords[i] + +"error message for keyword: " + keywords[i] , expected , e.getMessage() ); continue; } @@ -137,7 +140,7 @@ public class SelectFormatUnitTest extends TestFmwk { }; log("SelectFormat Unit test: Testing applyPattern() and format() ..."); - SelectFormat selFmt = new SelectFormat(SIMPLE_PATTERN); + SelectFormat selFmt = new SelectFormat(SIMPLE_PATTERN); for (int i=0; iPreferences>Java>Code Generation. */ +@RunWith(JUnit4.class) public class TestUCharacterIterator extends TestFmwk{ // constructor ----------------------------------------------------- - + /** * Constructor */ public TestUCharacterIterator() { } - + // public methods -------------------------------------------------- - + /** * Testing cloning */ @@ -70,7 +73,7 @@ public class TestUCharacterIterator extends TestFmwk{ errln("getText failed for iterator"); } } - + /** * Testing iteration */ @@ -81,18 +84,18 @@ public class TestUCharacterIterator extends TestFmwk{ ITERATION_STRING_); UCharacterIterator iterator2 = UCharacterIterator.getInstance( ITERATION_STRING_); - iterator.setToStart(); + iterator.setToStart(); if (iterator.current() != ITERATION_STRING_.charAt(0)) { errln("Iterator failed retrieving first character"); } - iterator.setToLimit(); + iterator.setToLimit(); if (iterator.previous() != ITERATION_STRING_.charAt( ITERATION_STRING_.length() - 1)) { errln("Iterator failed retrieving last character"); - } + } if (iterator.getLength() != ITERATION_STRING_.length()) { errln("Iterator failed determining begin and end index"); - } + } iterator2.setIndex(0); iterator.setIndex(0); int ch = 0; @@ -100,9 +103,9 @@ public class TestUCharacterIterator extends TestFmwk{ int index = iterator2.getIndex(); ch = iterator2.nextCodePoint(); if (index != ITERATION_SUPPLEMENTARY_INDEX) { - if (ch != (int)iterator.next() && + if (ch != iterator.next() && ch != UCharacterIterator.DONE) { - errln("Error mismatch in next() and nextCodePoint()"); + errln("Error mismatch in next() and nextCodePoint()"); } } else { @@ -119,14 +122,14 @@ public class TestUCharacterIterator extends TestFmwk{ int index = iterator2.getIndex(); ch = iterator2.previousCodePoint(); if (index != ITERATION_SUPPLEMENTARY_INDEX) { - if (ch != (int)iterator.previous() && + if (ch != iterator.previous() && ch != UCharacterIterator.DONE) { errln("Error mismatch in previous() and " + - "previousCodePoint()"); + "previousCodePoint()"); } } else { - if (UTF16.getLeadSurrogate(ch) != iterator.previous() || + if (UTF16.getLeadSurrogate(ch) != iterator.previous() || UTF16.getTrailSurrogate(ch) != iterator.previous()) { errln("Error mismatch in previous and " + "previousCodePoint for supplementary characters"); @@ -134,8 +137,8 @@ public class TestUCharacterIterator extends TestFmwk{ } } } - - //Tests for new API for utf-16 support + + //Tests for new API for utf-16 support @Test public void TestIterationUChar32() { String text="\u0061\u0062\ud841\udc02\u20ac\ud7ff\ud842\udc06\ud801\udc00\u0061"; @@ -143,15 +146,15 @@ public class TestUCharacterIterator extends TestFmwk{ int i; { UCharacterIterator iter = UCharacterIterator.getInstance(text); - + String iterText = iter.getText(); if (!iterText.equals(text)) errln("iter.getText() failed"); - + iter.setIndex(1); if (iter.currentCodePoint() != UTF16.charAt(text,1)) errln("Iterator didn't start out in the right place."); - + iter.setToStart(); c=iter.currentCodePoint(); i=0; @@ -159,12 +162,12 @@ public class TestUCharacterIterator extends TestFmwk{ c=iter.currentCodePoint(); if(c != UTF16.charAt(text,1) || i!=1) errln("moveCodePointIndex(1) didn't work correctly expected "+ hex(c) +" got "+hex(UTF16.charAt(text,1)) + " i= " + i); - + i=iter.moveCodePointIndex(2); c=iter.currentCodePoint(); if(c != UTF16.charAt(text,4) || i!=4) errln("moveCodePointIndex(2) didn't work correctly expected "+ hex(c) +" got "+hex(UTF16.charAt(text,4)) + " i= " + i); - + i=iter.moveCodePointIndex(-2); c=iter.currentCodePoint(); if(c != UTF16.charAt(text,1) || i!=1) @@ -175,11 +178,11 @@ public class TestUCharacterIterator extends TestFmwk{ c=iter.currentCodePoint(); if(c != UTF16.charAt(text,(text.length()-3)) || i!=(text.length()-3)) errln("moveCodePointIndex(-2) didn't work correctly expected "+ hex(c) +" got "+hex(UTF16.charAt(text,(text.length()-3)) ) + " i= " + i); - + iter.setToStart(); c = iter.currentCodePoint(); i = 0; - + //testing first32PostInc, nextCodePointPostInc, setTostart i = 0; iter.setToStart(); @@ -188,24 +191,24 @@ public class TestUCharacterIterator extends TestFmwk{ errln("first32PostInc failed. Expected->"+hex(UTF16.charAt(text,i))+" Got-> "+hex(c)); if(iter.getIndex() != UTF16.getCharCount(c) + i) errln("getIndex() after first32PostInc() failed"); - + iter.setToStart(); i=0; if (iter.getIndex() != 0) errln("setToStart failed"); - + logln("Testing forward iteration..."); do { if (c != UCharacterIterator.DONE) c = iter.nextCodePoint(); - + if(c != UTF16.charAt(text,i)) errln("Character mismatch at position "+i+", iterator has "+hex(c)+", string has "+hex(UTF16.charAt(text,i))); - + i+=UTF16.getCharCount(c); if(iter.getIndex() != i) errln("getIndex() aftr nextCodePointPostInc() isn't working right"); - c = iter.currentCodePoint(); + c = iter.currentCodePoint(); if( c!=UCharacterIterator.DONE && c != UTF16.charAt(text,i)) errln("current() after nextCodePointPostInc() isn't working right"); @@ -213,20 +216,20 @@ public class TestUCharacterIterator extends TestFmwk{ c=iter.nextCodePoint(); if(c!= UCharacterIterator.DONE) errln("nextCodePointPostInc() didn't return DONE at the beginning"); - - + + } - } - + } + class UCharIterator { - + public UCharIterator(int[] src, int len, int index){ - + s=src; length=len; i=index; } - + public int current() { if(i0) { return s[--i]; @@ -250,11 +253,11 @@ public class TestUCharacterIterator extends TestFmwk{ return -1; } } - + public int getIndex() { return i; } - + private int[] s; private int length, i; } @@ -318,37 +321,37 @@ public class TestUCharacterIterator extends TestFmwk{ 0xc4, 0x1ed0 }; - + // expected src indexes corresponding to expect indexes int expectIndex[]={ 0,0, 1,1, 2, 3, - 4 //needed + 4 //needed }; - + // initial indexes into the src and expect strings - + final int SRC_MIDDLE=4; final int EXPECT_MIDDLE=2; - - + + // movement vector // - for previous(), 0 for current(), + for next() // not const so that we can terminate it below for the error message String moves="0+0+0--0-0-+++0--+++++++0--------"; - - - UCharIterator iter32 = new UCharIterator(expect, expect.length, + + + UCharIterator iter32 = new UCharIterator(expect, expect.length, EXPECT_MIDDLE); - + int c1, c2; char m; - + // initially set the indexes into the middle of the strings iter.setIndex(SRC_MIDDLE); - + // move around and compare the iteration code points with // the expected ones int movesIndex =0; @@ -360,11 +363,11 @@ public class TestUCharacterIterator extends TestFmwk{ } else if(m=='0') { c1=iter.currentCodePoint(); c2=iter32.current(); - } else {// m=='+' + } else {// m=='+' c1=iter.nextCodePoint(); c2=iter32.next(); } - + // compare results if(c1!=c2) { // copy the moves until the current (m) move, and terminate @@ -373,7 +376,7 @@ public class TestUCharacterIterator extends TestFmwk{ +"got c1= " + hex(c1) +" != expected c2= "+ hex(c2)); break; } - + // compare indexes if(expectIndex[iter.getIndex()]!=iter32.getIndex()) { // copy the moves until the current (m) move, and terminate @@ -397,7 +400,7 @@ public class TestUCharacterIterator extends TestFmwk{ int c1, c2; char m; int movesIndex =0; - + while(movesIndex=0) or returned to the caller (with an * input expectCount<0). */ diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/lang/UnicodeSetTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/lang/UnicodeSetTest.java index 1229ab40f8b..5ebaa91b70e 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/lang/UnicodeSetTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/lang/UnicodeSetTest.java @@ -25,6 +25,8 @@ import java.util.SortedSet; import java.util.TreeSet; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.dev.util.CollectionUtilities; @@ -51,6 +53,7 @@ import com.ibm.icu.util.OutputInt; * @test * @summary General test of UnicodeSet */ +@RunWith(JUnit4.class) public class UnicodeSetTest extends TestFmwk { static final String NOT = "%%%%"; diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/normalizer/BasicTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/normalizer/BasicTest.java index 107ee60eed9..0e7f9aef1b3 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/normalizer/BasicTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/normalizer/BasicTest.java @@ -13,6 +13,8 @@ import java.text.StringCharacterIterator; import java.util.Random; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.Norm2AllModes; @@ -31,6 +33,7 @@ import com.ibm.icu.text.UnicodeSet; import com.ibm.icu.text.UnicodeSetIterator; +@RunWith(JUnit4.class) public class BasicTest extends TestFmwk { String[][] canonTests = { // Input Decomposed Composed diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/normalizer/ConformanceTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/normalizer/ConformanceTest.java index 75924f023ad..7513cb05db8 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/normalizer/ConformanceTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/normalizer/ConformanceTest.java @@ -15,6 +15,8 @@ import java.text.StringCharacterIterator; import org.junit.Ignore; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.dev.test.TestUtil; @@ -23,6 +25,7 @@ import com.ibm.icu.text.Normalizer; import com.ibm.icu.text.UTF16; import com.ibm.icu.text.UnicodeSet; +@RunWith(JUnit4.class) public class ConformanceTest extends TestFmwk { Normalizer normalizer; diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/normalizer/NormalizationMonkeyTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/normalizer/NormalizationMonkeyTest.java index 685edbf82a4..17b6caa5870 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/normalizer/NormalizationMonkeyTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/normalizer/NormalizationMonkeyTest.java @@ -12,6 +12,8 @@ package com.ibm.icu.dev.test.normalizer; import java.util.Random; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.lang.UCharacter; @@ -19,6 +21,7 @@ import com.ibm.icu.lang.UCharacterCategory; import com.ibm.icu.text.Normalizer; import com.ibm.icu.text.UTF16; +@RunWith(JUnit4.class) public class NormalizationMonkeyTest extends TestFmwk { int loopCount = 100; int maxCharCount = 20; @@ -28,10 +31,10 @@ public class NormalizationMonkeyTest extends TestFmwk { UnicodeNormalizer unicode_NFC; UnicodeNormalizer unicode_NFKD; UnicodeNormalizer unicode_NFKC; - + public NormalizationMonkeyTest() { } - + @Test public void TestNormalize() { if (unicode_NFD == null) { @@ -81,11 +84,11 @@ public class NormalizationMonkeyTest extends TestFmwk { if (!uncodeNorm.equals(icuNorm)) { errln("NFKC: Unicode sample output => " + uncodeNorm + "; icu4j output=> " + icuNorm); } - + i++; } } - + String getTestSource() { if (random == null) { random = createRandom(); // use test framework's random seed diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/normalizer/NormalizerRegressionTests.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/normalizer/NormalizerRegressionTests.java index 089d6ae4be9..fea43638634 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/normalizer/NormalizerRegressionTests.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/normalizer/NormalizerRegressionTests.java @@ -10,10 +10,13 @@ package com.ibm.icu.dev.test.normalizer; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.Normalizer; +@RunWith(JUnit4.class) public class NormalizerRegressionTests extends TestFmwk { @Test public void TestJB4472() { diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/normalizer/TestCanonicalIterator.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/normalizer/TestCanonicalIterator.java index ee0bb23d808..2c484e0bf5f 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/normalizer/TestCanonicalIterator.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/normalizer/TestCanonicalIterator.java @@ -15,6 +15,8 @@ import java.util.SortedSet; import java.util.TreeSet; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.Utility; @@ -26,8 +28,9 @@ import com.ibm.icu.text.UTF16; // TODO: fit into test framework +@RunWith(JUnit4.class) public class TestCanonicalIterator extends TestFmwk { - + static final boolean SHOW_NAMES = false; static final String testArray[][] = { @@ -67,19 +70,19 @@ public class TestCanonicalIterator extends TestFmwk { characterTest(s + "\u0345", i, it); } } - + public int TestSpeed() { // skip unless verbose if (!isVerbose()) return 0; String s = "\uAC01\u0345"; - + CanonicalIterator it = new CanonicalIterator(s); double start, end; int x = 0; // just to keep code from optimizing away. int iterations = 10000; double slowDelta = 0; - + /* CanonicalIterator slowIt = new CanonicalIterator(s); slowIt.SKIP_ZEROS = false; @@ -110,14 +113,14 @@ public class TestCanonicalIterator extends TestFmwk { end = System.currentTimeMillis(); double fastDelta = (end-start) / iterations; logln("Fast iteration: " + fastDelta + (slowDelta != 0 ? ", " + (fastDelta/slowDelta) : "")); - - + + return x; } - + @Test public void TestBasic() { -// This is not interesting anymore as the data is already built +// This is not interesting anymore as the data is already built // beforehand // check build @@ -128,14 +131,14 @@ public class TestCanonicalIterator extends TestFmwk { // new UnicodeSet("[\u00E0-\u00E5\u0101\u0103\u0105\u01CE\u01DF\u01E1\u01FB" // + "\u0201\u0203\u0227\u1E01\u1EA1\u1EA3\u1EA5\u1EA7\u1EA9\u1EAB\u1EAD\u1EAF\u1EB1\u1EB3\u1EB5\u1EB7]") // ); - + // check permute // NOTE: we use a TreeSet below to sort the output, which is not guaranteed to be sorted! - + Set results = new TreeSet(); CanonicalIterator.permute("ABC", false, results); expectEqual("Simple permutation ", "", collectionToString(results), "ABC, ACB, BAC, BCA, CAB, CBA"); - + // try samples SortedSet set = new TreeSet(); for (int i = 0; i < testArray.length; ++i) { @@ -164,7 +167,7 @@ public class TestCanonicalIterator extends TestFmwk { } } } - + private void expectEqual(String message, String item, Object a, Object b) { if (!a.equals(b)) { errln("FAIL: " + message + getReadable(item)); @@ -176,10 +179,10 @@ public class TestCanonicalIterator extends TestFmwk { logln("\t" + getReadable(b)); } } - + //Transliterator name = null; //Transliterator hex = null; - + public String getReadable(Object obj) { if (obj == null) return "null"; String s = obj.toString(); @@ -189,7 +192,7 @@ public class TestCanonicalIterator extends TestFmwk { //if (hex == null) hex = Transliterator.getInstance("[^\\ -\\u007F] hex"); return "[" + (SHOW_NAMES ? hex(s) + "; " : "") + hex(s) + "]"; } - + private void characterTest(String s, int ch, CanonicalIterator it) { int mixedCounter = 0; @@ -199,11 +202,11 @@ public class TestCanonicalIterator extends TestFmwk { boolean gotSource = false; String decomp = Normalizer.decompose(s, false); String comp = Normalizer.compose(s, false); - + // skip characters that don't have either decomp. // need quick test for this! if (s.equals(decomp) && s.equals(comp)) return; - + it.setSource(s); while (true) { @@ -225,7 +228,7 @@ public class TestCanonicalIterator extends TestFmwk { } } - + // check that zeros optimization doesn't mess up. /* if (true) { @@ -248,7 +251,7 @@ public class TestCanonicalIterator extends TestFmwk { } } */ - + mixedCounter++; if (!gotSource || !gotDecomp || !gotComp) { errln("FAIL CanonicalIterator: " + s + " decomp: " +decomp+" comp: "+comp); @@ -256,10 +259,10 @@ public class TestCanonicalIterator extends TestFmwk { for(String item=it.next();item!=null;item=it.next()){ err(item + " "); } - errln(""); + errln(""); } } - + static String collectionToString(Collection col) { StringBuffer result = new StringBuffer(); Iterator it = col.iterator(); diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/normalizer/TestDeprecatedNormalizerAPI.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/normalizer/TestDeprecatedNormalizerAPI.java index c6156059cfb..43ba1b35322 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/normalizer/TestDeprecatedNormalizerAPI.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/normalizer/TestDeprecatedNormalizerAPI.java @@ -9,6 +9,8 @@ package com.ibm.icu.dev.test.normalizer; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.Utility; @@ -18,8 +20,9 @@ import com.ibm.icu.text.ComposedCharIter; import com.ibm.icu.text.Normalizer; import com.ibm.icu.text.StringCharacterIterator; +@RunWith(JUnit4.class) public class TestDeprecatedNormalizerAPI extends TestFmwk -{ +{ public TestDeprecatedNormalizerAPI() { } @@ -33,17 +36,17 @@ public class TestDeprecatedNormalizerAPI extends TestFmwk Normalizer norm = new Normalizer(iter, Normalizer.NFC,0); if(norm.next()!=0xe4) { errln("error in Normalizer(CharacterIterator).next()"); - } + } Normalizer norm2 = new Normalizer(s,Normalizer.NFC,0); if(norm2.next()!=0xe4) { errln("error in Normalizer(CharacterIterator).next()"); - } + } // test clone(), ==, and hashCode() Normalizer clone=(Normalizer)norm.clone(); if(clone.getBeginIndex()!= norm.getBeginIndex()){ errln("error in Normalizer.getBeginIndex()"); } - + if(clone.getEndIndex()!= norm.getEndIndex()){ errln("error in Normalizer.getEndIndex()"); } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/normalizer/UTS46Test.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/normalizer/UTS46Test.java index 174ce578f0e..c33a911d96b 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/normalizer/UTS46Test.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/normalizer/UTS46Test.java @@ -18,6 +18,8 @@ import java.util.TreeMap; import java.util.regex.Pattern; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.dev.test.TestUtil; @@ -30,6 +32,7 @@ import com.ibm.icu.text.IDNA; * @author Markus Scherer * @since 2010jul10 */ +@RunWith(JUnit4.class) public class UTS46Test extends TestFmwk { public UTS46Test() { int commonOptions= diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/normalizer/UnicodeNormalizerConformanceTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/normalizer/UnicodeNormalizerConformanceTest.java index fc79989f96b..62bc0a6a71c 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/normalizer/UnicodeNormalizerConformanceTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/normalizer/UnicodeNormalizerConformanceTest.java @@ -14,6 +14,8 @@ import java.io.IOException; import org.junit.Ignore; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.dev.test.TestUtil; @@ -21,6 +23,7 @@ import com.ibm.icu.text.UTF16; import com.ibm.icu.text.UnicodeSet; +@RunWith(JUnit4.class) public class UnicodeNormalizerConformanceTest extends TestFmwk { UnicodeNormalizer normalizer_C, normalizer_D, normalizer_KC, normalizer_KD; @@ -32,13 +35,13 @@ public class UnicodeNormalizerConformanceTest extends TestFmwk { normalizer_D = new UnicodeNormalizer(UnicodeNormalizer.D, false); normalizer_KC = new UnicodeNormalizer(UnicodeNormalizer.KC, false); normalizer_KD = new UnicodeNormalizer(UnicodeNormalizer.KD, false); - + } // more interesting conformance test cases, not in the unicode.org NormalizationTest.txt static String[] moreCases ={ // Markus 2001aug30 "0061 0332 0308;00E4 0332;0061 0332 0308;00E4 0332;0061 0332 0308; # Markus 0", - + // Markus 2001oct26 - test edge case for iteration: U+0f73.cc==0 but decomposition.lead.cc==129 "0061 0301 0F73;00E1 0F71 0F72;0061 0F71 0F72 0301;00E1 0F71 0F72;0061 0F71 0F72 0301; # Markus 1" }; @@ -82,10 +85,10 @@ public class UnicodeNormalizerConformanceTest extends TestFmwk { // Parse out the fields hexsplit(line, ';', fields, buf); - + // Remove a single code point from the "other" UnicodeSet if(fields[0].length()==UTF16.moveCodePointOffset(fields[0],0, 1)) { - c=UTF16.charAt(fields[0],0); + c=UTF16.charAt(fields[0],0); if(0xac20<=c && c<=0xd73f) { // not an exhaustive test run: skip most Hangul syllables if(c==0xac20) { @@ -126,7 +129,7 @@ public class UnicodeNormalizerConformanceTest extends TestFmwk { logln("Total: " + passCount + " lines passed"); } } - + /** * Verify the conformance of the given line of the Unicode * normalization (UTR 15) test suite file. For each line, @@ -151,26 +154,26 @@ public class UnicodeNormalizerConformanceTest extends TestFmwk { if (i<3) { out = normalizer_C.normalize(field[i]); pass &= assertEqual("C", field[i], out, field[1], "c2!=C(c" + (i+1)); - + out = normalizer_D.normalize(field[i]); pass &= assertEqual("D", field[i], out, field[2], "c3!=D(c" + (i+1)); - + } out = normalizer_KC.normalize(field[i]); pass &= assertEqual("KC", field[i], out, field[3], "c4!=KC(c" + (i+1)); out = normalizer_KD.normalize(field[i]); pass &= assertEqual("KD", field[i], out, field[4], "c5!=KD(c" + (i+1)); - + } - + if (!pass) { errln("FAIL: " + line); - } - + } + return pass; } - + /** * @param op name of normalization form, e.g., "KC" * @param s string being normalized @@ -211,7 +214,7 @@ public class UnicodeNormalizerConformanceTest extends TestFmwk { } // Our field is from pos..delim-1. buf.setLength(0); - + String toHex = s.substring(pos,delim); pos = delim; int index = 0; @@ -230,7 +233,7 @@ public class UnicodeNormalizerConformanceTest extends TestFmwk { index = spacePos+1; } } - + if (buf.length() < 1) { throw new IllegalArgumentException("Empty field " + i + " in " + s); } @@ -244,13 +247,13 @@ public class UnicodeNormalizerConformanceTest extends TestFmwk { throw new IllegalArgumentException("Out of range hex " + hex + " in " + s); }else if (hex > 0xFFFF){ - buf.append((char)((hex>>10)+0xd7c0)); + buf.append((char)((hex>>10)+0xd7c0)); buf.append((char)((hex&0x3ff)|0xdc00)); }else{ buf.append((char) hex); } } - + // Specific tests for debugging. These are generally failures // taken from the conformance file, but culled out to make // debugging easier. These can be eliminated without affecting @@ -268,6 +271,6 @@ public class UnicodeNormalizerConformanceTest extends TestFmwk { hexsplit(line, ';', fields, buf); checkConformance(fields, line); } - + } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/number/FormatQuantityTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/number/FormatQuantityTest.java index baadfdca31d..4ff797f7e66 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/number/FormatQuantityTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/number/FormatQuantityTest.java @@ -11,6 +11,8 @@ import java.util.List; import java.util.Random; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.number.Endpoint; @@ -24,6 +26,7 @@ import com.ibm.icu.impl.number.Properties; import com.ibm.icu.text.CompactDecimalFormat.CompactStyle; /** TODO: This is a temporary name for this class. Suggestions for a better name? */ +@RunWith(JUnit4.class) public class FormatQuantityTest extends TestFmwk { @Test diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/rbbi/AbstractBreakIteratorTests.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/rbbi/AbstractBreakIteratorTests.java index 0ba50e8e941..5f471cb1d57 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/rbbi/AbstractBreakIteratorTests.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/rbbi/AbstractBreakIteratorTests.java @@ -6,6 +6,8 @@ import java.text.CharacterIterator; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.BreakIterator; @@ -14,6 +16,7 @@ import com.ibm.icu.text.BreakIterator; * @author sgill * */ +@RunWith(JUnit4.class) public class AbstractBreakIteratorTests extends TestFmwk { private class AbstractBreakIterator extends BreakIterator { diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/rbbi/BreakIteratorRegTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/rbbi/BreakIteratorRegTest.java index ef848d35b62..3b8860280c1 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/rbbi/BreakIteratorRegTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/rbbi/BreakIteratorRegTest.java @@ -13,10 +13,13 @@ import java.util.Arrays; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.BreakIterator; +@RunWith(JUnit4.class) public class BreakIteratorRegTest extends TestFmwk { @Test @@ -39,7 +42,7 @@ public class BreakIteratorRegTest extends TestFmwk Object key0 = BreakIterator.registerInstance((BreakIterator)twbi.clone(), foo_locale, BreakIterator.KIND_WORD); Object key1 = BreakIterator.registerInstance(sbi, Locale.US, BreakIterator.KIND_WORD); Object key2 = BreakIterator.registerInstance((BreakIterator)twbi.clone(), Locale.US, BreakIterator.KIND_WORD); - + { BreakIterator test0 = BreakIterator.getWordInstance(Locale.JAPAN); BreakIterator test1 = BreakIterator.getWordInstance(Locale.US); @@ -55,7 +58,7 @@ public class BreakIteratorRegTest extends TestFmwk } //Locale[] locales = BreakIterator.getAvailableLocales(); - + assertTrue(BreakIterator.unregister(key2), "unregister us word (thai word)"); assertTrue(!BreakIterator.unregister(key2), "unregister second time"); boolean error = false; @@ -78,7 +81,7 @@ public class BreakIteratorRegTest extends TestFmwk assertTrue(BreakIterator.unregister(key0), "unregister foo word (thai word)"); assertTrue(!Arrays.asList(BreakIterator.getAvailableLocales()).contains(foo_locale), "no foo_locale"); assertEqual(BreakIterator.getWordInstance(Locale.US), usbi, "us word == us sentence"); - + assertTrue(BreakIterator.unregister(key1), "unregister us word (us sentence)"); { BreakIterator test0 = BreakIterator.getWordInstance(Locale.JAPAN); diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/rbbi/BreakIteratorTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/rbbi/BreakIteratorTest.java index 3e497ecf23b..074c56494b3 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/rbbi/BreakIteratorTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/rbbi/BreakIteratorTest.java @@ -15,12 +15,15 @@ import java.util.Locale; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.BreakIterator; import com.ibm.icu.text.FilteredBreakIteratorBuilder; import com.ibm.icu.util.ULocale; +@RunWith(JUnit4.class) public class BreakIteratorTest extends TestFmwk { private BreakIterator characterBreak; diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/rbbi/RBBIAPITest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/rbbi/RBBIAPITest.java index a71613bb64b..05ede18660b 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/rbbi/RBBIAPITest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/rbbi/RBBIAPITest.java @@ -23,6 +23,8 @@ import java.util.List; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.BreakIterator; @@ -32,7 +34,8 @@ import com.ibm.icu.util.ULocale; /** * API Test the RuleBasedBreakIterator class */ -public class RBBIAPITest extends com.ibm.icu.dev.test.TestFmwk { +@RunWith(JUnit4.class) +public class RBBIAPITest extends TestFmwk { /** * Tests clone() and equals() methods of RuleBasedBreakIterator **/ diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/rbbi/RBBIMonkeyTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/rbbi/RBBIMonkeyTest.java index 6feef9722e5..9ddb73bd0db 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/rbbi/RBBIMonkeyTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/rbbi/RBBIMonkeyTest.java @@ -16,6 +16,8 @@ import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.UCharacterName; @@ -31,6 +33,7 @@ import com.ibm.icu.util.ULocale; * older class RBBITestMonkey. */ +@RunWith(JUnit4.class) public class RBBIMonkeyTest extends TestFmwk { diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/rbbi/RBBITest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/rbbi/RBBITest.java index b3f6f45cf3d..9d025e7c8de 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/rbbi/RBBITest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/rbbi/RBBITest.java @@ -21,12 +21,15 @@ import java.util.ArrayList; import java.util.List; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.BreakIterator; import com.ibm.icu.text.RuleBasedBreakIterator; import com.ibm.icu.util.ULocale; +@RunWith(JUnit4.class) public class RBBITest extends TestFmwk { public RBBITest() { } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/rbbi/RBBITestExtended.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/rbbi/RBBITestExtended.java index 422770ded1f..8be70120ced 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/rbbi/RBBITestExtended.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/rbbi/RBBITestExtended.java @@ -15,6 +15,8 @@ import java.io.InputStreamReader; import java.util.Arrays; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.Utility; @@ -31,6 +33,7 @@ import com.ibm.icu.util.ULocale; * See the data file for a description of the tests. * */ +@RunWith(JUnit4.class) public class RBBITestExtended extends TestFmwk { public RBBITestExtended() { } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/rbbi/RBBITestMonkey.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/rbbi/RBBITestMonkey.java index a93a8623e90..d508f88e13a 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/rbbi/RBBITestMonkey.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/rbbi/RBBITestMonkey.java @@ -19,6 +19,8 @@ import java.util.List; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.lang.UCharacter; @@ -39,6 +41,7 @@ import com.ibm.icu.text.UnicodeSet; * Ported from ICU4C, original code in file source/test/intltest/rbbitst.cpp * */ +@RunWith(JUnit4.class) public class RBBITestMonkey extends TestFmwk { // // class RBBIMonkeyKind diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/shaping/ArabicShapingRegTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/shaping/ArabicShapingRegTest.java index 2abb4fbb31a..a71aaba8880 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/shaping/ArabicShapingRegTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/shaping/ArabicShapingRegTest.java @@ -12,6 +12,8 @@ package com.ibm.icu.dev.test.shaping; import java.lang.reflect.Method; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.ArabicShaping; @@ -19,6 +21,7 @@ import com.ibm.icu.text.ArabicShaping; /** * Regression test for Arabic shaping. */ +@RunWith(JUnit4.class) public class ArabicShapingRegTest extends TestFmwk { /* constants copied from ArabicShaping for convenience */ diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/stringprep/IDNAConformanceTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/stringprep/IDNAConformanceTest.java index ad0f65ac663..5dcd8d91c8b 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/stringprep/IDNAConformanceTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/stringprep/IDNAConformanceTest.java @@ -20,6 +20,8 @@ import java.util.Set; import java.util.TreeMap; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.dev.test.TestUtil; @@ -29,14 +31,15 @@ import com.ibm.icu.text.UTF16; /** * @author limaoyu - * + * */ +@RunWith(JUnit4.class) public class IDNAConformanceTest extends TestFmwk { @Test public void TestConformance() { TreeMap inputData = null; - + try { inputData = ReadInput.getInputData(); } catch (UnsupportedEncodingException e) { @@ -46,7 +49,7 @@ public class IDNAConformanceTest extends TestFmwk { errln(e.getMessage()); return; } - + Set keyMap = inputData.keySet(); for (Iterator iter = keyMap.iterator(); iter.hasNext();) { Long element = (Long) iter.next(); @@ -70,7 +73,7 @@ public class IDNAConformanceTest extends TestFmwk { boolean failed = false; if ("toascii".equals(tempHash.get("type"))) { - + //get the result try { //by default STD3 rules are not used, but if the description @@ -87,12 +90,12 @@ public class IDNAConformanceTest extends TestFmwk { //errln(e2.getMessage()); failed = true; } - - + + if ("pass".equals(passfail)) { if (!namezone.equals(result)) { printInfo(desc, namebase, nameutf8, namezone, - failzone1, failzone2, result, type, passfail); + failzone1, failzone2, result, type, passfail); errln("\t pass fail standard is pass, but failed"); } else { printInfo(desc, namebase, nameutf8, namezone, @@ -108,7 +111,7 @@ public class IDNAConformanceTest extends TestFmwk { logln("passed"); } else { printInfo(desc, namebase, nameutf8, namezone, - failzone1, failzone2, result, type, passfail); + failzone1, failzone2, result, type, passfail); errln("\t pass fail standard is fail, but no exception thrown out"); } } @@ -132,11 +135,11 @@ public class IDNAConformanceTest extends TestFmwk { if (!namezone.equals(result)) { printInfo(desc, namebase, nameutf8, namezone, failzone1, failzone2, result, type, passfail); - + errln("\t Did not get the expected result. Expected: " + prettify(namezone) + " Got: " + prettify(result)); } else { printInfo(desc, namebase, nameutf8, namezone, - failzone1, failzone2, result, type, passfail); + failzone1, failzone2, result, type, passfail); logln("\tpassed"); } } @@ -145,12 +148,12 @@ public class IDNAConformanceTest extends TestFmwk { if (failed || namebase.equals(result)) { printInfo(desc, namebase, nameutf8, namezone, failzone1, failzone2, result, type, passfail); - + logln("\tpassed"); } else { printInfo(desc, namebase, nameutf8, namezone, failzone1, failzone2, result, type, passfail); - + errln("\t pass fail standard is fail, but no exception thrown out"); } } @@ -220,7 +223,7 @@ public class IDNAConformanceTest extends TestFmwk { String utf16String = UTF16.valueOf(toBeInserted); char[] charsTemp = utf16String.toCharArray(); for (int j = 0; j < charsTemp.length; j++) { - result.append((char) charsTemp[j]); + result.append(charsTemp[j]); } } } else if ('>' == chars[i]) {//end when met with '>' @@ -235,9 +238,9 @@ public class IDNAConformanceTest extends TestFmwk { /** * This class is used to read test data from TestInput file. - * + * * @author limaoyu - * + * */ public static class ReadInput { diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/stringprep/TestIDNA.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/stringprep/TestIDNA.java index f05f32ec0b1..f18bffacd20 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/stringprep/TestIDNA.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/stringprep/TestIDNA.java @@ -12,6 +12,8 @@ import java.util.Random; import org.junit.Ignore; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.Utility; @@ -24,6 +26,7 @@ import com.ibm.icu.text.UTF16; /** * @author ram */ +@RunWith(JUnit4.class) public class TestIDNA extends TestFmwk { private StringPrepParseException unassignedException = new StringPrepParseException("",StringPrepParseException.UNASSIGNED_ERROR); diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/stringprep/TestIDNARef.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/stringprep/TestIDNARef.java index 9bb859b6d44..40260e8d4e5 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/stringprep/TestIDNARef.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/stringprep/TestIDNARef.java @@ -9,6 +9,8 @@ package com.ibm.icu.dev.test.stringprep; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.StringPrepParseException; @@ -20,6 +22,7 @@ import com.ibm.icu.text.UCharacterIterator; * To change the template for this generated type comment go to * Window>Preferences>Java>Code Generation>Code and Comments */ +@RunWith(JUnit4.class) public class TestIDNARef extends TestFmwk { private StringPrepParseException unassignedException = new StringPrepParseException("",StringPrepParseException.UNASSIGNED_ERROR); @@ -30,17 +33,17 @@ public class TestIDNARef extends TestFmwk { // test StringBuffer toUnicode doTestToUnicode(TestData.asciiIn[i],new String(TestData.unicodeIn[i]),IDNAReference.DEFAULT, null); doTestToUnicode(TestData.asciiIn[i],new String(TestData.unicodeIn[i]),IDNAReference.ALLOW_UNASSIGNED, null); - //doTestToUnicode(TestData.asciiIn[i],new String(TestData.unicodeIn[i]),IDNAReference.USE_STD3_RULES, null); - //doTestToUnicode(TestData.asciiIn[i],new String(TestData.unicodeIn[i]),IDNAReference.USE_STD3_RULES|IDNAReference.ALLOW_UNASSIGNED, null); - + //doTestToUnicode(TestData.asciiIn[i],new String(TestData.unicodeIn[i]),IDNAReference.USE_STD3_RULES, null); + //doTestToUnicode(TestData.asciiIn[i],new String(TestData.unicodeIn[i]),IDNAReference.USE_STD3_RULES|IDNAReference.ALLOW_UNASSIGNED, null); + } }catch(java.lang.ExceptionInInitializerError ex){ warnln("Could not load NamePrepTransform data"); }catch(java.lang.NoClassDefFoundError ex){ warnln("Could not load NamePrepTransform data"); - } + } } - + @Test public void TestToASCII() throws Exception{ try{ @@ -48,17 +51,17 @@ public class TestIDNARef extends TestFmwk { // test StringBuffer toUnicode doTestToASCII(new String(TestData.unicodeIn[i]),TestData.asciiIn[i],IDNAReference.DEFAULT, null); doTestToASCII(new String(TestData.unicodeIn[i]),TestData.asciiIn[i],IDNAReference.ALLOW_UNASSIGNED, null); - //doTestToUnicode(TestData.asciiIn[i],new String(TestData.unicodeIn[i]),IDNAReference.USE_STD3_RULES, null); - //doTestToUnicode(TestData.asciiIn[i],new String(TestData.unicodeIn[i]),IDNAReference.USE_STD3_RULES|IDNAReference.ALLOW_UNASSIGNED, null); - + //doTestToUnicode(TestData.asciiIn[i],new String(TestData.unicodeIn[i]),IDNAReference.USE_STD3_RULES, null); + //doTestToUnicode(TestData.asciiIn[i],new String(TestData.unicodeIn[i]),IDNAReference.USE_STD3_RULES|IDNAReference.ALLOW_UNASSIGNED, null); + } }catch(java.lang.ExceptionInInitializerError ex){ warnln("Could not load NamePrepTransform data"); }catch(java.lang.NoClassDefFoundError ex){ warnln("Could not load NamePrepTransform data"); - } + } } - + @Test public void TestIDNToASCII() throws Exception{ try{ @@ -68,19 +71,19 @@ public class TestIDNARef extends TestFmwk { doTestIDNToASCII(TestData.domainNames[i],TestData.domainNames[i],IDNAReference.USE_STD3_RULES, null); doTestIDNToASCII(TestData.domainNames[i],TestData.domainNames[i],IDNAReference.ALLOW_UNASSIGNED|IDNAReference.USE_STD3_RULES, null); } - + for(int i=0; i Long.MIN_VALUE) { try { result = UniversalTimeScale.from(fromMin - 1, scale); @@ -147,14 +150,14 @@ public class TimeScaleAPITest extends TestFmwk logln("PASS: UniversalTimeScale.from failed as expected"); } } - + try { result = UniversalTimeScale.from(fromMax, scale); logln("from(fromMax, " + scale + ") returned " + result); } catch (IllegalArgumentException iae) { errln("from(fromMax, " + scale + ") threw IllegalArgumentException."); } - + if (fromMax < Long.MAX_VALUE) { try { result = UniversalTimeScale.from(fromMax + 1, scale); @@ -164,7 +167,7 @@ public class TimeScaleAPITest extends TestFmwk } } } - + try { result = UniversalTimeScale.from(0L, UniversalTimeScale.MAX_SCALE); errln("from(0L, MAX_SCALE) did not throw IllegalArgumetException."); @@ -172,26 +175,26 @@ public class TimeScaleAPITest extends TestFmwk logln("PASS: UniversalTimeScale.from failed as expected"); } } - + @Test public void TestGetTimeScale() { long value; - + try { value = UniversalTimeScale.getTimeScaleValue(-1, 0); errln("getTimeScaleValue(-1, 0) did not throw IllegalArgumentException."); } catch (IllegalArgumentException iae) { logln("PASS: UniversalTimeScale.getTimeScaleValue failed as expected"); } - + try { value = UniversalTimeScale.getTimeScaleValue(0, -1); errln("getTimeScaleValue(0, -1) did not throw IllegalArgumentException."); } catch (IllegalArgumentException iae) { logln("PASS: UniversalTimeScale.getTimeScaleValue failed as expected"); } - + for (int scale = 0; scale < UniversalTimeScale.MAX_SCALE; scale += 1) { try { value = UniversalTimeScale.getTimeScaleValue(scale, 0); @@ -200,14 +203,14 @@ public class TimeScaleAPITest extends TestFmwk errln("getTimeScaleValue(" + scale + ", 0) threw IllegalArgumentException."); } } - + try { value = UniversalTimeScale.getTimeScaleValue(UniversalTimeScale.MAX_SCALE, 0); errln("getTimeScaleValue(MAX_SCALE, 0) did not throw IllegalArgumentException"); } catch (IllegalArgumentException iae) { logln("PASS: UniversalTimeScale.getTimeScaleValue failed as expected"); } - + try { value = UniversalTimeScale.getTimeScaleValue(0, UniversalTimeScale.MAX_SCALE_VALUE); errln("getTimeScaleValue(0, MAX_SCALE_VALUE) did not throw IllegalArgumentException"); @@ -215,19 +218,19 @@ public class TimeScaleAPITest extends TestFmwk logln("PASS: UniversalTimeScale.getTimeScaleValue failed as expected"); } } - + @Test public void TestToBigDecimalFromBigDecimal() { BigDecimal bigZero = new BigDecimal(0); - + try { UniversalTimeScale.toBigDecimal(bigZero, -1); errln("toBigDecimal(bigZero, -1) did not throw IllegalArgumentException."); } catch (IllegalArgumentException iae) { logln("PASS: UniversalTimeScale.toBigDecimal failed as expected"); } - + for (int scale = 0; scale < UniversalTimeScale.MAX_SCALE; scale += 1) { try { UniversalTimeScale.toBigDecimal(bigZero, scale); @@ -235,7 +238,7 @@ public class TimeScaleAPITest extends TestFmwk errln("toBigDecimal(bigZero, " + scale + ") threw IllegalArgumentException."); } } - + try { UniversalTimeScale.toBigDecimal(bigZero, UniversalTimeScale.MAX_SCALE); errln("toBigDecimal(bigZero, MAX_SCALE) did not throw IllegalArgumetException."); @@ -248,14 +251,14 @@ public class TimeScaleAPITest extends TestFmwk public void TestToBigDecimalTrunc() { BigDecimal bigZero = new BigDecimal(0); - + try { UniversalTimeScale.toBigDecimalTrunc(bigZero, -1); errln("toBigDecimalTrunc(bigZero, -1) did not throw IllegalArgumentException."); } catch (IllegalArgumentException iae) { logln("PASS: UniversalTimeScale.toBigDecimalTrunc failed as expected"); } - + for (int scale = 0; scale < UniversalTimeScale.MAX_SCALE; scale += 1) { try { UniversalTimeScale.toBigDecimalTrunc(bigZero, scale); @@ -263,7 +266,7 @@ public class TimeScaleAPITest extends TestFmwk errln("toBigDecimalTrunc(bigZero, " + scale + ") threw IllegalArgumentException."); } } - + try { UniversalTimeScale.toBigDecimalTrunc(bigZero, UniversalTimeScale.MAX_SCALE); errln("toBigDecimalTrunc(bigZero, MAX_SCALE) did not throw IllegalArgumetException."); @@ -271,7 +274,7 @@ public class TimeScaleAPITest extends TestFmwk logln("PASS: UniversalTimeScale.toBigDecimalTrunc failed as expected"); } } - + @Test public void TestToBigDecimalFromLong() { @@ -281,7 +284,7 @@ public class TimeScaleAPITest extends TestFmwk } catch (IllegalArgumentException iae) { logln("PASS: UniversalTimeScale.toBigDecimal failed as expected"); } - + for (int scale = 0; scale < UniversalTimeScale.MAX_SCALE; scale += 1) { try { UniversalTimeScale.toBigDecimal(0L, scale); @@ -289,7 +292,7 @@ public class TimeScaleAPITest extends TestFmwk errln("toBigDecimal(0L, " + scale + ") threw IllegalArgumentException."); } } - + try { UniversalTimeScale.toBigDecimal(0L, UniversalTimeScale.MAX_SCALE); errln("toBigDecimal(0L, MAX_SCALE) did not throw IllegalArgumetException."); @@ -297,37 +300,37 @@ public class TimeScaleAPITest extends TestFmwk logln("PASS: UniversalTimeScale.toBigDecimal failed as expected"); } } - + @Test public void TestToLong() { long result; - + try { result = UniversalTimeScale.toLong(0L, -1); errln("toLong(0L, -1) did not throw IllegalArgumentException."); } catch (IllegalArgumentException iae) { logln("PASS: UniversalTimeScale.toLong failed as expected"); } - + for (int scale = 0; scale < UniversalTimeScale.MAX_SCALE; scale += 1) { long toMin = UniversalTimeScale.getTimeScaleValue(scale, UniversalTimeScale.TO_MIN_VALUE); long toMax = UniversalTimeScale.getTimeScaleValue(scale, UniversalTimeScale.TO_MAX_VALUE); - + try { result = UniversalTimeScale.toLong(0L, scale); logln("toLong(0L, " + scale + ") returned " + result); } catch (IllegalArgumentException iae) { errln("toLong(0L, " + scale + ") threw IllegalArgumentException."); } - + try { result = UniversalTimeScale.toLong(toMin, scale); logln("toLong(toMin, " + scale + ") returned " + result); } catch (IllegalArgumentException iae) { errln("toLong(toMin, " + scale + ") threw IllegalArgumentException."); } - + if (toMin > Long.MIN_VALUE) { try { result = UniversalTimeScale.toLong(toMin - 1, scale); @@ -336,14 +339,14 @@ public class TimeScaleAPITest extends TestFmwk logln("PASS: UniversalTimeScale.toLong failed as expected"); } } - + try { result = UniversalTimeScale.toLong(toMax, scale); logln("toLong(toMax, " + scale + ") returned " + result); } catch (IllegalArgumentException iae) { errln("toLong(toMax, " + scale + ") threw IllegalArgumentException."); } - + if (toMax < Long.MAX_VALUE) { try { result = UniversalTimeScale.toLong(toMax + 1, scale); @@ -353,7 +356,7 @@ public class TimeScaleAPITest extends TestFmwk } } } - + try { result = UniversalTimeScale.toLong(0L, UniversalTimeScale.MAX_SCALE); errln("toLong(0L, MAX_SCALE) did not throw IllegalArgumetException."); diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/timescale/TimeScaleDataTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/timescale/TimeScaleDataTest.java index dc6d12dc6a4..de8d697c4aa 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/timescale/TimeScaleDataTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/timescale/TimeScaleDataTest.java @@ -14,6 +14,8 @@ import java.util.Date; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.util.GregorianCalendar; @@ -27,6 +29,7 @@ import com.ibm.icu.util.UniversalTimeScale; * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ +@RunWith(JUnit4.class) public class TimeScaleDataTest extends TestFmwk { @@ -36,63 +39,63 @@ public class TimeScaleDataTest extends TestFmwk public TimeScaleDataTest() { } - + private void roundTripTest(long value, int scale) { long rt = UniversalTimeScale.toLong(UniversalTimeScale.from(value, scale), scale); - + if (rt != value) { errln("Round-trip error: time scale = " + scale + ", value = " + value + ", round-trip = " + rt); } } - + private void toLimitTest(long toLimit, long fromLimit, int scale) { long result = UniversalTimeScale.toLong(toLimit, scale); - + if (result != fromLimit) { errln("toLimit failure: scale = " + scale + ", toLimit = " + toLimit + ", toLong(toLimit, scale) = " + result + ", fromLimit = " + fromLimit); } } - + private void epochOffsetTest(long epochOffset, long units, int scale) { long universalEpoch = epochOffset * units; long local = UniversalTimeScale.toLong(universalEpoch, scale); - + if (local != 0) { errln("toLong(epochOffset, scale): scale = " + scale + ", epochOffset = " + universalEpoch + ", result = " + local); } - + local = UniversalTimeScale.toLong(0, scale); - + if (local != -epochOffset) { errln("toLong(0, scale): scale = " + scale + ", result = " + local); } - + long universal = UniversalTimeScale.from(-epochOffset, scale); - + if (universal != 0) { errln("from(-epochOffest, scale): scale = " + scale + ", epochOffset = " + epochOffset + ", result = " + universal); } - + universal = UniversalTimeScale.from(0, scale); - + if (universal != universalEpoch) { errln("from(0, scale): scale = " + scale + ", result = " + universal); } } - + @Test public void TestEpochOffsets() { for (int scale = 0; scale < UniversalTimeScale.MAX_SCALE; scale += 1) { long units = UniversalTimeScale.getTimeScaleValue(scale, UniversalTimeScale.UNITS_VALUE); long epochOffset = UniversalTimeScale.getTimeScaleValue(scale, UniversalTimeScale.EPOCH_OFFSET_VALUE); - + epochOffsetTest(epochOffset, units, scale); } } @@ -103,12 +106,12 @@ public class TimeScaleDataTest extends TestFmwk for (int scale = 0; scale < UniversalTimeScale.MAX_SCALE; scale += 1) { long fromMin = UniversalTimeScale.getTimeScaleValue(scale, UniversalTimeScale.FROM_MIN_VALUE); long fromMax = UniversalTimeScale.getTimeScaleValue(scale, UniversalTimeScale.FROM_MAX_VALUE); - + roundTripTest(fromMin, scale); roundTripTest(fromMax, scale); } } - + @Test public void TestToLimits() { @@ -117,7 +120,7 @@ public class TimeScaleDataTest extends TestFmwk long fromMax = UniversalTimeScale.getTimeScaleValue(scale, UniversalTimeScale.FROM_MAX_VALUE); long toMin = UniversalTimeScale.getTimeScaleValue(scale, UniversalTimeScale.TO_MIN_VALUE); long toMax = UniversalTimeScale.getTimeScaleValue(scale, UniversalTimeScale.TO_MAX_VALUE); - + toLimitTest(toMin, fromMin, scale); toLimitTest(toMax, fromMax, scale); } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/timescale/TimeScaleMonkeyTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/timescale/TimeScaleMonkeyTest.java index 4191012332c..5f4b24152c5 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/timescale/TimeScaleMonkeyTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/timescale/TimeScaleMonkeyTest.java @@ -13,6 +13,8 @@ package com.ibm.icu.dev.test.timescale; import java.util.Random; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.math.BigDecimal; @@ -23,6 +25,7 @@ import com.ibm.icu.util.UniversalTimeScale; * generating ramdon values in range and making sure * that they round-trip correctly. */ +@RunWith(JUnit4.class) public class TimeScaleMonkeyTest extends TestFmwk { @@ -32,54 +35,54 @@ public class TimeScaleMonkeyTest extends TestFmwk public TimeScaleMonkeyTest() { } - + private static final int LOOP_COUNT = 1000; private static final BigDecimal longMax = new BigDecimal(Long.MAX_VALUE); - + private Random ran = null; - + private long ranInt; private long ranMin; private long ranMax; - + private void initRandom(long min, long max) { BigDecimal interval = new BigDecimal(max).subtract(new BigDecimal(min)); - + ranMin = min; ranMax = max; ranInt = 0; - + if (ran == null) { ran = createRandom(); } - + if (interval.compareTo(longMax) < 0) { ranInt = interval.longValue(); } } - + private final long randomInRange() { long value; - + if (ranInt != 0) { value = ran.nextLong() % ranInt; - + if (value < 0) { value = -value; } - + value += ranMin; } else { do { value = ran.nextLong(); } while (value < ranMin || value > ranMax); } - + return value; } - + @Test public void TestRoundTrip() { @@ -87,18 +90,18 @@ public class TimeScaleMonkeyTest extends TestFmwk long fromMin = UniversalTimeScale.getTimeScaleValue(scale, UniversalTimeScale.FROM_MIN_VALUE); long fromMax = UniversalTimeScale.getTimeScaleValue(scale, UniversalTimeScale.FROM_MAX_VALUE); int i = 0; - + initRandom(fromMin, fromMax); - + while (i < LOOP_COUNT) { long value = randomInRange(); - + long rt = UniversalTimeScale.toLong(UniversalTimeScale.from(value, scale), scale); - + if (rt != value) { errln("Round-trip error: time scale = " + scale + ", value = " + value + ", round-trip = " + rt); } - + i += 1; } } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/timezone/TimeZoneAliasTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/timezone/TimeZoneAliasTest.java index 54bcb820f90..becd08fe0d6 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/timezone/TimeZoneAliasTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/timezone/TimeZoneAliasTest.java @@ -25,6 +25,8 @@ import java.util.TreeSet; import org.junit.Ignore; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.util.TimeZone; @@ -32,8 +34,9 @@ import com.ibm.icu.util.TimeZone; /** * Class for testing TimeZones for consistency * @author Davis - * + * */ +@RunWith(JUnit4.class) public class TimeZoneAliasTest extends TestFmwk { /** * There are two things to check aliases for:
@@ -51,7 +54,7 @@ public class TimeZoneAliasTest extends TestFmwk { if (id.indexOf('/') < 0 && (id.endsWith("ST") || id.endsWith("DT"))) { if (zone.minRecentOffset != zone.maxRecentOffset) { errln( - "Standard or Daylight Time not constant: " + id + "Standard or Daylight Time not constant: " + id + ": " + Zone.formatHours(zone.minRecentOffset) + " != " + Zone.formatHours(zone.maxRecentOffset)); } @@ -69,7 +72,7 @@ public class TimeZoneAliasTest extends TestFmwk { errln( "Aliases Unsymmetric: " + id + " => " + Zone.bf.join(aliasesSet) - + "; " + + "; " + otherId + " => " + Zone.bf.join(otherAliases)); } if (zone.findOffsetOrdering(otherZone, seconds) != 0) { @@ -79,7 +82,7 @@ public class TimeZoneAliasTest extends TestFmwk { } } } - + /** * We check to see that every timezone that is not an alias is actually different! */ @@ -88,14 +91,14 @@ public class TimeZoneAliasTest extends TestFmwk { @Test public void TestDifferences() { Zone last = null; - Zone.Seconds diffDate = new Zone.Seconds(); + Zone.Seconds diffDate = new Zone.Seconds(); for (Iterator it = Zone.getZoneSet().iterator(); it.hasNext();) { Zone testZone = (Zone)it.next(); if (last != null) { String common = testZone + "\tvs " + last + ":\t"; int diff = testZone.findOffsetOrdering(last, diffDate); if (diff != 0) { - logln("\t" + common + "difference at: " + diffDate + logln("\t" + common + "difference at: " + diffDate + ", " + Zone.formatHours(diff) + "hr"); } else if (testZone.isRealAlias(last)) { logln("\t" + common + "alias, no difference"); @@ -106,7 +109,7 @@ public class TimeZoneAliasTest extends TestFmwk { last = testZone; } } - + /** * Utility for printing out zones to be translated. */ @@ -117,7 +120,7 @@ public class TimeZoneAliasTest extends TestFmwk { System.out.println(zone.toString(count++)); } } - + /** Utility; ought to be someplace common */ // remove dependency on bagformatter for now @@ -138,7 +141,7 @@ public class TimeZoneAliasTest extends TestFmwk { } } - + /** * The guts is in this subclass. It sucks in all the data from the zones, * and analyses it. It constructs some mappings for the unique ids, @@ -165,7 +168,7 @@ public class TimeZoneAliasTest extends TestFmwk { static private final long endDate2 = getDate((currentYear+1),6,1).getTime(); static private final long recentLimit = getDate((currentYear-1),6,1).getTime(); static private final long startDate = getDate(1905,0,1).getTime(); - + static private final Map idToZone = new HashMap(); static private final Set zoneSet = new TreeSet(); static private final Set uniqueZoneSet = new TreeSet(); @@ -179,7 +182,7 @@ public class TimeZoneAliasTest extends TestFmwk { } Zone last = null; Zone.Seconds diffDate = new Zone.Seconds(); - String lastUnique = ""; + String lastUnique = ""; for (Iterator it = Zone.getZoneSet().iterator(); it.hasNext();) { Zone testZone = (Zone)it.next(); if (last == null) { @@ -202,11 +205,11 @@ public class TimeZoneAliasTest extends TestFmwk { last = testZone; } } - + static public Set getZoneSet() { return zoneSet; } - + public static Set getUniqueZoneSet() { return uniqueZoneSet; } @@ -218,20 +221,21 @@ public class TimeZoneAliasTest extends TestFmwk { idToZone.put(id, result); return result; } - + static public String formatHours(int hours) { return nf.format(hours/DHOUR); } - + // utility class for date return, because Date is clunky. public static class Seconds { public long seconds = Long.MIN_VALUE; + @Override public String toString() { if (seconds == Long.MIN_VALUE) return "n/a"; return df.format(new Date(seconds)); } } - + // instance fields // we keep min/max offsets not only over all time (that we care about) // but also separate ones for recent years. @@ -244,11 +248,11 @@ public class TimeZoneAliasTest extends TestFmwk { private int maxRecentOffset; private List inflectionPoints = new ArrayList(); private Set purportedAliases = new TreeSet(); - + private Zone(String id) { // for interal use only; use make instead! zone = TimeZone.getTimeZone(id); this.id = id; - + // get aliases int equivCount = TimeZone.countEquivalentIDs(id); for (int j = 0; j < equivCount; ++j) { @@ -265,7 +269,7 @@ public class TimeZoneAliasTest extends TestFmwk { inflectionPoints.add(new Long(lastDate)); int lastOffset = zone.getOffset(endDate); long lastInflection = endDate; - + // we do a gross search, then narrow in when we find a difference from the last one for (long currentDate = endDate; currentDate >= startDate; currentDate -= GROSS_PERIOD) { int currentOffset = zone.getOffset(currentDate); @@ -294,7 +298,7 @@ public class TimeZoneAliasTest extends TestFmwk { } inflectionPoints.add(new Long(startDate)); // just to cap it off for comparisons. } - + // we assume that places will not convert time zones then back within one day // so we go first by half public int findOffsetOrdering(Zone other, Seconds dateDiffFound) { @@ -317,14 +321,14 @@ public class TimeZoneAliasTest extends TestFmwk { if (result != 0) { seconds = myIP; break main; - } + } if (myIP == otherIP) continue; // test other if different myIP = otherIP; result = zone.getOffset(myIP) - other.zone.getOffset(myIP); if (result != 0) { seconds = myIP; break main; - } + } } // if they are equal so far, we don't care about the rest result = 0; @@ -335,10 +339,11 @@ public class TimeZoneAliasTest extends TestFmwk { if (dateDiffFound != null) dateDiffFound.seconds = seconds; return result; } - + // internal buffer to avoid creation all the time. private Seconds diffDateReturn = new Seconds(); - + + @Override public int compareTo(Object o) { Zone other = (Zone)o; // first order by max and min offsets @@ -358,55 +363,56 @@ public class TimeZoneAliasTest extends TestFmwk { } return id.compareTo(other.id); } - + public Set getPurportedAliases() { return new TreeSet(purportedAliases); // clone for safety } - + public boolean isPurportedAlias(String zoneID) { return purportedAliases.contains(zoneID); } - + public boolean isRealAlias(Zone z) { return purportedAliases.contains(z.id); } - + public String getPurportedAliasesAsString() { Set s = getPurportedAliases(); if (s.size() == 0) return ""; return " " + bf.join(s); } - + public String getRealAliasesAsString() { Set s = (Set)idToRealAliases.get(id); if (s == null) return ""; return " *" + bf.join(s); } - + public String getCity() { int pos = id.lastIndexOf(('/')); String city = id.substring(pos+1); return city.replace('_',' '); } + @Override public String toString() { return toString(-1); } - + /** * Where count > 0, returns string that is set up for translation */ public String toString(int count) { String city = getCity(); String hours = formatHours(minRecentOffset) - + (minRecentOffset != maxRecentOffset - ? "," + formatHours(maxRecentOffset) + + (minRecentOffset != maxRecentOffset + ? "," + formatHours(maxRecentOffset) : ""); if (count < 0) { return id + getPurportedAliasesAsString() + " (" + hours + ")"; - } + } // for getting template for translation - return "\t{\t\"" + id + "\"\t// [" + count + "] " + hours + return "\t{\t\"" + id + "\"\t// [" + count + "] " + hours + getRealAliasesAsString() + "\r\n" + "\t\t// translate the following!!\r\n" + (minRecentOffset != maxRecentOffset diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/timezone/TimeZoneBoundaryTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/timezone/TimeZoneBoundaryTest.java index 106126d9bd4..a5fa09dc98d 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/timezone/TimeZoneBoundaryTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/timezone/TimeZoneBoundaryTest.java @@ -10,6 +10,8 @@ package com.ibm.icu.dev.test.timezone; import java.util.Date; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.dev.test.TestUtil; @@ -23,6 +25,7 @@ import com.ibm.icu.util.TimeZone; * A test which discovers the boundaries of DST programmatically and verifies * that they are correct. */ +@RunWith(JUnit4.class) public class TimeZoneBoundaryTest extends TestFmwk { static final int ONE_SECOND = 1000; @@ -181,7 +184,7 @@ public class TimeZoneBoundaryTest extends TestFmwk logln(tz.getID() + " After: " + showDate(max, tz)); long mindelta = expectedBoundary - min; - // not used long maxdelta = max - expectedBoundary; + // not used long maxdelta = max - expectedBoundary; DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG); fmt.setTimeZone(tz); if (mindelta >= 0 && mindelta <= INTERVAL && @@ -200,10 +203,10 @@ public class TimeZoneBoundaryTest extends TestFmwk { java.util.Calendar cal = java.util.Calendar.getInstance(); cal.setTime(d); - return "" + (cal.get(Calendar.YEAR) - 1900) + "/" + - showNN(cal.get(Calendar.MONTH) + 1) + "/" + - showNN(cal.get(Calendar.DAY_OF_MONTH)) + " " + - showNN(cal.get(Calendar.HOUR_OF_DAY)) + ":" + return "" + (cal.get(Calendar.YEAR) - 1900) + "/" + + showNN(cal.get(Calendar.MONTH) + 1) + "/" + + showNN(cal.get(Calendar.DAY_OF_MONTH)) + " " + + showNN(cal.get(Calendar.HOUR_OF_DAY)) + ":" + showNN(cal.get(Calendar.MINUTE)) + " \"" + d + "\" = " + d.getTime(); } @@ -219,10 +222,10 @@ public class TimeZoneBoundaryTest extends TestFmwk fmt.setTimeZone(zone); java.util.Calendar cal = java.util.Calendar.getInstance(); cal.setTime(d); - return "" + (cal.get(Calendar.YEAR) - 1900) + "/" + - showNN(cal.get(Calendar.MONTH) + 1) + "/" + - showNN(cal.get(Calendar.DAY_OF_MONTH)) + " " + - showNN(cal.get(Calendar.HOUR_OF_DAY)) + ":" + + return "" + (cal.get(Calendar.YEAR) - 1900) + "/" + + showNN(cal.get(Calendar.MONTH) + 1) + "/" + + showNN(cal.get(Calendar.DAY_OF_MONTH)) + " " + + showNN(cal.get(Calendar.HOUR_OF_DAY)) + ":" + showNN(cal.get(Calendar.MINUTE)) + " \"" + d + "\" = " + fmt.format(d) + " = " + d.getTime(); } @@ -397,7 +400,7 @@ public class TimeZoneBoundaryTest extends TestFmwk verifyMapping(tempcal, 1997, Calendar.APRIL, 6, 0, 238976.0); verifyMapping(tempcal, 1997, Calendar.APRIL, 6, 1, 238977.0); verifyMapping(tempcal, 1997, Calendar.APRIL, 6, 3, 238978.0); - + TimeZone utc = safeGetTimeZone("UTC"); Calendar utccal = Calendar.getInstance(utc); verifyMapping(utccal, 1997, Calendar.APRIL, 6, 0, 238968.0); diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/timezone/TimeZoneOffsetLocalTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/timezone/TimeZoneOffsetLocalTest.java index 08b5c324466..05c4c9b2dba 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/timezone/TimeZoneOffsetLocalTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/timezone/TimeZoneOffsetLocalTest.java @@ -11,6 +11,8 @@ package com.ibm.icu.dev.test.timezone; import java.util.Date; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.DateFormat; @@ -27,6 +29,7 @@ import com.ibm.icu.util.TimeZone; /** * Testing getOffset APIs using local time */ +@RunWith(JUnit4.class) public class TimeZoneOffsetLocalTest extends TestFmwk { /* * Testing getOffset APIs around rule transition by local standard/wall time. @@ -66,7 +69,7 @@ public class TimeZoneOffsetLocalTest extends TestFmwk { -8*HOUR, }; - + // Expected offsets by getOffset(long time, boolean local, int[] offsets) with local = true // or getOffsetFromLocal(long time, int nonExistingTimeOpt, int duplicatedTimeOpt, int[] offsets) // with nonExistingTimeOpt = LOCAL_STD/duplicatedTimeOpt = LOCAL_STD diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/timezone/TimeZoneRegressionTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/timezone/TimeZoneRegressionTest.java index 2e9acb91f45..d1433400615 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/timezone/TimeZoneRegressionTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/timezone/TimeZoneRegressionTest.java @@ -24,6 +24,8 @@ import java.util.Date; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.DateFormat; @@ -34,6 +36,7 @@ import com.ibm.icu.util.SimpleTimeZone; import com.ibm.icu.util.TimeZone; import com.ibm.icu.util.ULocale; +@RunWith(JUnit4.class) public class TimeZoneRegressionTest extends TestFmwk { @Test public void Test4052967() { @@ -77,7 +80,7 @@ public class TimeZoneRegressionTest extends TestFmwk { Date d1 = tempcal.getTime(); if (z.inDaylightTime(d1)) { errln("Fail: DST not working as expected"); - } + } tempcal.set(1997, Calendar.MARCH, 1); Date d2 = tempcal.getTime(); @@ -89,7 +92,7 @@ public class TimeZoneRegressionTest extends TestFmwk { Date d3 = tempcal.getTime(); if (z.inDaylightTime(d3)) { errln("Fail: DST not working as expected"); - } + } } /** @@ -712,7 +715,7 @@ public class TimeZoneRegressionTest extends TestFmwk { public void Test4162593() { SimpleDateFormat fmt = new SimpleDateFormat("z", Locale.US); final int ONE_HOUR = 60*60*1000; - final float H = (float) ONE_HOUR; + final float H = ONE_HOUR; TimeZone initialZone = TimeZone.getDefault(); SimpleDateFormat sdf = new SimpleDateFormat("MMM dd yyyy HH:mm z"); @@ -903,7 +906,7 @@ public class TimeZoneRegressionTest extends TestFmwk { */ // Current orgnaization of data in zoneinfor.res allows negative // values from DOM so comment these tests out - + @Test public void Test4184229() { SimpleTimeZone zone = null; @@ -934,7 +937,7 @@ public class TimeZoneRegressionTest extends TestFmwk { // Make a valid constructor call for subsequent tests. zone = new SimpleTimeZone(0, "A", 0, 1, 0, 0, 0, 1, 0, 0); - + try { zone.setStartRule(0, -1, 0, 0); errln("Failed. No exception has been thrown for DOM -1 setStartRule +savings"); @@ -959,7 +962,7 @@ public class TimeZoneRegressionTest extends TestFmwk { } catch(IllegalArgumentException e) { logln("(h) " + e.getMessage()); } - + } /** @@ -1039,7 +1042,7 @@ public class TimeZoneRegressionTest extends TestFmwk { @Test public void TestJ5134() { GregorianCalendar testCal = (GregorianCalendar)Calendar.getInstance(); - TimeZone icuEastern = TimeZone.getTimeZone("America/New_York"); + TimeZone icuEastern = TimeZone.getTimeZone("America/New_York"); testCal.setTimeZone(icuEastern); testCal.set(1900, Calendar.JANUARY, 1, 0, 0, 0); long time = testCal.getTimeInMillis(); @@ -1168,7 +1171,7 @@ public class TimeZoneRegressionTest extends TestFmwk { + tzid + ") [13-arg constructor]"); } } - + // test bug #4265 @Test public void TestJohannesburg() { @@ -1176,8 +1179,8 @@ public class TimeZoneRegressionTest extends TestFmwk { TimeZone johannesburg = TimeZone.getTimeZone(j_id); final int ONE_HOUR = 60*60*1000; int expectedOffset = ONE_HOUR*2; // GMT+2 - NO DST - int offset = johannesburg.getOffset(GregorianCalendar.AD,2007,Calendar.JULY,5,Calendar.THURSDAY,0); - + int offset = johannesburg.getOffset(GregorianCalendar.AD,2007,Calendar.JULY,5,Calendar.THURSDAY,0); + if(offset != expectedOffset) { errln("FAIL: zone " + j_id +" returned offset in July " + offset +", expected "+expectedOffset); } else { @@ -1198,6 +1201,7 @@ public class TimeZoneRegressionTest extends TestFmwk { Thread[] workers = new Thread[20]; for (int i = 0 ; i < workers.length; i++) { workers[i] = new Thread(new Runnable() { + @Override public void run() { for (int j = 0; j < 10000; j++) { try { @@ -1216,7 +1220,7 @@ public class TimeZoneRegressionTest extends TestFmwk { try { wk.join(); } catch (InterruptedException ie) { - + } } } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/timezone/TimeZoneRuleTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/timezone/TimeZoneRuleTest.java index aee97ac18f6..70f5d902cd4 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/timezone/TimeZoneRuleTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/timezone/TimeZoneRuleTest.java @@ -18,6 +18,8 @@ import java.io.StringWriter; import java.util.Date; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.util.AnnualTimeZoneRule; @@ -38,6 +40,7 @@ import com.ibm.icu.util.VTimeZone; /** * Test cases for TimeZoneRule and RuleBasedTimeZone */ +@RunWith(JUnit4.class) public class TimeZoneRuleTest extends TestFmwk { private static final int HOUR = 60 * 60 * 1000; @@ -61,7 +64,7 @@ public class TimeZoneRuleTest extends TestFmwk { "RBTZ_Initial", // Initial time Name -1*HOUR, // Raw offset 1*HOUR); // DST saving amount - + // RBTZ RuleBasedTimeZone rbtz1 = new RuleBasedTimeZone("RBTZ1", ir); dtr = new DateTimeRule(Calendar.SEPTEMBER, 30, Calendar.SATURDAY, false, @@ -151,7 +154,7 @@ public class TimeZoneRuleTest extends TestFmwk { if (offsets[0] != -3600000) { errln("FAIL: Invalid time zone raw offset: " + offsets[0] + " /expected: -3600000"); } - if (offsets[1] != 3600000) { + if (offsets[1] != 3600000) { errln("FAIL: Invalid DST amount: " + offsets[1] + " /expected: 3600000"); } @@ -172,7 +175,7 @@ public class TimeZoneRuleTest extends TestFmwk { if (offsets[0] != -3600000) { errln("FAIL: Invalid time zone raw offset: " + offsets[0] + " /expected: -3600000"); } - if (offsets[1] != 0) { + if (offsets[1] != 0) { errln("FAIL: Invalid DST amount: " + offsets[1] + " /expected: 0"); } @@ -240,7 +243,7 @@ public class TimeZoneRuleTest extends TestFmwk { 2*HOUR, DateTimeRule.WALL_TIME); // January 6, at 2AM wall time tzr = new AnnualTimeZoneRule("EDT", -5*HOUR, 1*HOUR, dtr, 1974, 1974); rbtz.addTransitionRule(tzr); - + dtr = new DateTimeRule(Calendar.FEBRUARY, 23, 2*HOUR, DateTimeRule.WALL_TIME); // February 23, at 2AM wall time tzr = new AnnualTimeZoneRule("EDT", -5*HOUR, 1*HOUR, dtr, 1975, 1975); @@ -264,7 +267,7 @@ public class TimeZoneRuleTest extends TestFmwk { // hasEquivalentTransitions long jan1_1950 = getUTCMillis(1950, Calendar.JANUARY, 1); long jan1_1967 = getUTCMillis(1971, Calendar.JANUARY, 1); - long jan1_2010 = getUTCMillis(2010, Calendar.JANUARY, 1); + long jan1_2010 = getUTCMillis(2010, Calendar.JANUARY, 1); if (!(((BasicTimeZone)ny).hasEquivalentTransitions(rbtz, jan1_1967, jan1_2010))) { errln("FAIL: The RBTZ must be equivalent to America/New_York between 1967 and 2010"); @@ -379,7 +382,7 @@ public class TimeZoneRuleTest extends TestFmwk { // Descending/inclusive compareTransitionsDescending(tz, rbtz, startTime + 1, until, true); } - + } } @@ -399,7 +402,7 @@ public class TimeZoneRuleTest extends TestFmwk { long jan1_2006 = getUTCMillis(2006, Calendar.JANUARY, 1); long jan1_2007 = getUTCMillis(2007, Calendar.JANUARY, 1); long jan1_2011 = getUTCMillis(2010, Calendar.JANUARY, 1); - + if (((BasicTimeZone)newyork).hasEquivalentTransitions(indianapolis, jan1_2005, jan1_2011)) { errln("FAIL: New_York is not equivalent to Indianapolis between 2005 and 2010, but returned true"); } @@ -690,7 +693,7 @@ public class TimeZoneRuleTest extends TestFmwk { } catch (IOException ioe) { errln("FAIL: IO error while writing/reading VTIMEZONE data"); } - + } /* @@ -743,7 +746,7 @@ public class TimeZoneRuleTest extends TestFmwk { } /* - * API coverage tests for TimeZoneRule + * API coverage tests for TimeZoneRule */ @Test public void TestTimeZoneRuleCoverage() { @@ -766,11 +769,11 @@ public class TimeZoneRuleTest extends TestFmwk { 2000, AnnualTimeZoneRule.MAX_YEAR); AnnualTimeZoneRule a3 = new AnnualTimeZoneRule("a3", -3*HOUR, 1*HOUR, dtr1, 2000, 2010); - + InitialTimeZoneRule i1 = new InitialTimeZoneRule("i1", -3*HOUR, 0); InitialTimeZoneRule i2 = new InitialTimeZoneRule("i2", -3*HOUR, 0); InitialTimeZoneRule i3 = new InitialTimeZoneRule("i3", -3*HOUR, 1*HOUR); - + long[] emptytimes = {}; long[] trtimes1 = {0}; long[] trtimes2 = {0, 10000000}; @@ -787,7 +790,7 @@ public class TimeZoneRuleTest extends TestFmwk { if (t0 != null) { errln("FAIL: TimeArrayTimeZoneRule constructor did not throw IllegalArgumentException for null times"); } - + try { // Try to construct TimeArrayTimeZoneRule with empty transition times t0 = new TimeArrayTimeZoneRule("nulltimes", -3*HOUR, 0, @@ -810,7 +813,7 @@ public class TimeZoneRuleTest extends TestFmwk { if (!a1.getRule().equals(a2.getRule())) { errln("FAIL: The same DateTimeRule must be returned from AnnualTimeZoneRule a1 and a2"); } - + // AnnualTimeZoneRule#getStartYear int startYear = a1.getStartYear(); if (startYear != 2000) { @@ -826,7 +829,7 @@ public class TimeZoneRuleTest extends TestFmwk { if (endYear != 2010) { errln("FAIL: The start year of AnnualTimeZoneRule a3 must be 2010 - returned: " + endYear); } - + // AnnualTimeZone#getStartInYear Date d1 = a1.getStartInYear(2005, -3*HOUR, 0); Date d2 = a3.getStartInYear(2005, -3*HOUR, 0); @@ -950,8 +953,8 @@ public class TimeZoneRuleTest extends TestFmwk { } else { logln("InitialTimeZoneRule i1 : " + str); } - - + + // TimeArrayTimeZoneRule#getStartTimes long[] times = t1.getStartTimes(); if (times == null || times.length == 0 || times[0] != 0) { @@ -1123,7 +1126,7 @@ public class TimeZoneRuleTest extends TestFmwk { errln("FAIL: Bad transition returned by SimpleTimeZone#getNextTransition"); } } - + /* * API coverage test for VTimeZone */ @@ -1229,7 +1232,7 @@ public class TimeZoneRuleTest extends TestFmwk { if (rulesetAll.length < ruleset1.length || ruleset1.length < ruleset2.length) { errln("FAIL: Number of rules returned by getRules is invalid"); } - + int[] offsets_vtzc = new int[2]; VTimeZone vtzc = VTimeZone.create("PST"); vtzc.getOffsetFromLocal(Calendar.getInstance(vtzc).getTimeInMillis(), VTimeZone.LOCAL_STD, VTimeZone.LOCAL_STD, offsets_vtzc); @@ -1271,10 +1274,10 @@ public class TimeZoneRuleTest extends TestFmwk { if (offsets[0] != 9*HOUR || offsets[1] != 0) { errln("FAIL: Bad offsets returned by a VTimeZone created for Tokyo"); } - } + } // Create VTimeZone from VTIMEZONE data - String fooData = + String fooData = "BEGIN:VCALENDAR\r\n" + "BEGIN:VTIMEZONE\r\n" + "TZID:FOO\r\n" + @@ -1353,7 +1356,7 @@ public class TimeZoneRuleTest extends TestFmwk { "END:VCALENDAR"; // Single final rule, no overlapping with another - String finalNonOverlap = + String finalNonOverlap = "BEGIN:VCALENDAR\r\n" + "BEGIN:VTIMEZONE\r\n" + "TZID:FinalNonOverlap\r\n" + @@ -1458,7 +1461,7 @@ public class TimeZoneRuleTest extends TestFmwk { + tzt.getTime() + " Expected: " + expectedPrev); } } - + @Test public void TestBasicTimeZoneCoverage() { TimeZone tz = TimeZone.getTimeZone("PST"); @@ -1511,7 +1514,7 @@ public class TimeZoneRuleTest extends TestFmwk { (tzt0.getTo().getRawOffset() != tzt.getFrom().getRawOffset() || tzt0.getTo().getDSTSavings() != tzt.getFrom().getDSTSavings())) { errln("FAIL: TO rule of the previous transition does not match FROM rule of this transtion at " - + time + " for " + icutz.getID()); + + time + " for " + icutz.getID()); } tzt0 = tzt; } @@ -1539,7 +1542,7 @@ public class TimeZoneRuleTest extends TestFmwk { (tzt0.getFrom().getRawOffset() != tzt.getTo().getRawOffset() || tzt0.getFrom().getDSTSavings() != tzt.getTo().getDSTSavings())) { errln("FAIL: TO rule of the next transition does not match FROM rule in this transtion at " - + time + " for " + icutz.getID()); + + time + " for " + icutz.getID()); } tzt0 = tzt; } @@ -1710,7 +1713,7 @@ public class TimeZoneRuleTest extends TestFmwk { * delta range. */ private static boolean hasEquivalentTransitions(BasicTimeZone tz1, BasicTimeZone tz2, - long start, long end, + long start, long end, boolean ignoreDstAmount, int maxTransitionTimeDelta) { if (tz1.hasSameRules(tz2)) { return true; diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/timezone/TimeZoneTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/timezone/TimeZoneTest.java index ac018375bd2..25089080133 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/timezone/TimeZoneTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/timezone/TimeZoneTest.java @@ -22,6 +22,8 @@ import java.util.Locale; import java.util.Set; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.ICUData; @@ -49,6 +51,7 @@ import com.ibm.icu.util.VersionInfo; * @summary test TimeZone * @build TimeZoneTest */ +@RunWith(JUnit4.class) public class TimeZoneTest extends TestFmwk { static final int millisPerHour = 3600000; @@ -70,7 +73,7 @@ public class TimeZoneTest extends TestFmwk * * Bug 4130885 * Certain short zone IDs, used since 1.1.x, are incorrect. - * + * * The worst of these is: * * "CAT" (Central African Time) should be GMT+2:00, but instead returns a @@ -226,6 +229,7 @@ public class TimeZoneTest extends TestFmwk public String getID() { return id; } + @Override public boolean equals(Object o) { ZoneDescriptor that = (ZoneDescriptor)o; return that != null && @@ -234,6 +238,7 @@ public class TimeZoneTest extends TestFmwk daylight == that.daylight; } + @Override public String toString() { int min = offset; char sign = '+'; @@ -343,7 +348,7 @@ public class TimeZoneTest extends TestFmwk // THE FOLLOWING LINES MUST BE UPDATED IF THE LOCALE DATA CHANGES //***************************************************************** - // Test to allow the user to choose to get all the forms + // Test to allow the user to choose to get all the forms // (z, zzzz, Z, ZZZZ, v, vvvv) // todo: check to see whether we can test for all of pst, pdt, pt Object[] DATA = { @@ -356,7 +361,7 @@ public class TimeZoneTest extends TestFmwk Boolean.FALSE, new Integer(TimeZone.SHORT_GENERIC), "PT", Boolean.TRUE, new Integer(TimeZone.SHORT_GENERIC), "PT", Boolean.FALSE, new Integer(TimeZone.LONG_GENERIC), "Pacific Time", - Boolean.TRUE, new Integer(TimeZone.LONG_GENERIC), "Pacific Time", + Boolean.TRUE, new Integer(TimeZone.LONG_GENERIC), "Pacific Time", // z and ZZZZ Boolean.FALSE, new Integer(TimeZone.SHORT_GMT), "-0800", Boolean.TRUE, new Integer(TimeZone.SHORT_GMT), "-0700", @@ -405,7 +410,7 @@ public class TimeZoneTest extends TestFmwk // If not, we expect the en fallback behavior. // in icu4j 2.1 we know we have the zh_CN locale data, though it's incomplete -// /"DateFormatZoneData", +// /"DateFormatZoneData", UResourceBundle enRB = UResourceBundle.getBundleInstance(ICUData.ICU_BASE_NAME,Locale.ENGLISH); UResourceBundle mtRB = UResourceBundle.getBundleInstance(ICUData.ICU_BASE_NAME, mt_MT); boolean noZH = enRB == mtRB; @@ -415,7 +420,7 @@ public class TimeZoneTest extends TestFmwk if (!name.equals("Pacific Standard Time")) errln("Fail: Expected Pacific Standard Time for PST in mt_MT but got "); } - // dlf - we will use generic time, or if unavailable, GMT for standard time in the zone + // dlf - we will use generic time, or if unavailable, GMT for standard time in the zone // - we now (3.4.1) have localizations for this zone, so change test string else if(!name.equals("\u0126in ta\u2019 Los Angeles") && !name.equals("GMT-08:00") && @@ -428,7 +433,7 @@ public class TimeZoneTest extends TestFmwk "THE ABOVE FAILURE MAY JUST MEAN THE LOCALE DATA HAS CHANGED\n" + "************************************************************"); } - + // Now try a non-existent zone zone2 = new SimpleTimeZone(90*60*1000, "xyzzy"); name = zone2.getDisplayName(Locale.ENGLISH); @@ -438,7 +443,7 @@ public class TimeZoneTest extends TestFmwk !name.equals("GMT+0130") && !name.equals("GMT+130")) errln("Fail: Expected GMT+01:30 or something similar"); - + // cover getDisplayName() - null arg ULocale save = ULocale.getDefault(); ULocale.setDefault(ULocale.US); @@ -448,9 +453,9 @@ public class TimeZoneTest extends TestFmwk !name.equals("GMT+1:30") && !name.equals("GMT+0130") && !name.equals("GMT+130")) - errln("Fail: Expected GMT+01:30 or something similar"); + errln("Fail: Expected GMT+01:30 or something similar"); ULocale.setDefault(save); - + } @@ -479,7 +484,7 @@ public class TimeZoneTest extends TestFmwk displayName0 = tz.getDisplayName(true, TimeZone.LONG_GENERIC, locale); } if (!displayName1.equals(displayName0)) { - errln(locale.getDisplayName() + ", " + tz.getID() + + errln(locale.getDisplayName() + ", " + tz.getID() + ": expected " + displayName1 + " but got: " + displayName0); } } @@ -1084,7 +1089,7 @@ public class TimeZoneTest extends TestFmwk // hack so test compiles and runs in both JDK 1.3 and JDK 1.4 final Object[] args = new Object[0]; final Class[] argtypes = new Class[0]; - java.lang.reflect.Method m = tz_java.getClass().getMethod("getDSTSavings", argtypes); + java.lang.reflect.Method m = tz_java.getClass().getMethod("getDSTSavings", argtypes); dst_java = ((Integer) m.invoke(tz_java, args)).intValue(); if (dst_java <= 0 || dst_java >= 3600000) { // didn't get the fractional time zone we wanted errln("didn't get fractional time zone!"); @@ -1104,13 +1109,13 @@ public class TimeZoneTest extends TestFmwk warnln(e.getMessage()); return; } - + com.ibm.icu.util.TimeZone tz_icu = com.ibm.icu.util.TimeZone.getTimeZone(tzName); int dst_icu = tz_icu.getDSTSavings(); if (dst_java != dst_icu) { warnln("java reports dst savings of " + dst_java + - " but icu reports " + dst_icu + + " but icu reports " + dst_icu + " for tz " + tz_icu.getID()); } else { logln("both java and icu report dst savings of " + dst_java + " for tz " + tz_icu.getID()); @@ -1139,7 +1144,7 @@ public class TimeZoneTest extends TestFmwk // jb4484 @Test - public void TestSimpleTimeZoneSerialization() + public void TestSimpleTimeZoneSerialization() { SimpleTimeZone stz0 = new SimpleTimeZone(32400000, "MyTimeZone"); SimpleTimeZone stz1 = new SimpleTimeZone(32400000, "Asia/Tokyo"); @@ -1155,7 +1160,7 @@ public class TimeZoneTest extends TestFmwk SimpleTimeZone stz5 = new SimpleTimeZone(32400000, "Asia/Tokyo"); stz5.setStartRule(2, 3, 4, 360000); stz5.setEndRule(6, 3, 4, 360000); - + SimpleTimeZone[] stzs = { stz0, stz1, stz2, stz3, stz4, stz5, }; for (int i = 0; i < stzs.length; ++i) { @@ -1355,7 +1360,7 @@ public class TimeZoneTest extends TestFmwk } } } - + @Test public void TestCoverage(){ class StubTimeZone extends TimeZone{ @@ -1363,12 +1368,17 @@ public class TimeZoneTest extends TestFmwk * For serialization */ private static final long serialVersionUID = 8658654217433379343L; + @Override public int getOffset(int era, int year, int month, int day, int dayOfWeek, int milliseconds) {return 0;} + @Override public void setRawOffset(int offsetMillis) {} + @Override public int getRawOffset() {return 0;} + @Override public boolean useDaylightTime() {return false;} + @Override public boolean inDaylightTime(Date date) {return false;} - } + } StubTimeZone stub = new StubTimeZone(); StubTimeZone stub2 = (StubTimeZone) stub.clone(); if (stub.getDSTSavings() != 0){ @@ -1376,7 +1386,7 @@ public class TimeZoneTest extends TestFmwk } if (!stub.hasSameRules(stub2)){ errln("TimeZone.clone() object should hasSameRules"); - + } } @Test @@ -1964,7 +1974,7 @@ public class TimeZoneTest extends TestFmwk } // cloneAsThawed - TimeZone thawed = (TimeZone)thawedZones[i].cloneAsThawed(); + TimeZone thawed = thawedZones[i].cloneAsThawed(); if (thawed.isFrozen() || !thawedZones[i].equals(thawed)) { errln("Fail: " + zaName + "[" + i + "] - cloneAsThawed does not work."); } @@ -2071,7 +2081,7 @@ public class TimeZoneTest extends TestFmwk } // cloneAsThawed - TimeZone thawed = (TimeZone)frozenZones[i].cloneAsThawed(); + TimeZone thawed = frozenZones[i].cloneAsThawed(); if (thawed.isFrozen() || !frozenZones[i].equals(thawed)) { errln("Fail: " + zaName + "[" + i + "] - cloneAsThawed does not work."); } @@ -2210,7 +2220,7 @@ public class TimeZoneTest extends TestFmwk } } } - + @Test public void Test11619_UnrecognizedTimeZoneID() { VTimeZone vzone = VTimeZone.create("ABadTimeZoneId"); diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/BytesTrieTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/BytesTrieTest.java index a09c48e1e8d..d3f88494f8e 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/BytesTrieTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/BytesTrieTest.java @@ -16,12 +16,15 @@ import java.nio.ByteBuffer; import java.util.NoSuchElementException; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.util.BytesTrie; import com.ibm.icu.util.BytesTrieBuilder; import com.ibm.icu.util.StringTrieBuilder; +@RunWith(JUnit4.class) public class BytesTrieTest extends TestFmwk { public BytesTrieTest() {} diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/CharsTrieTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/CharsTrieTest.java index efff2e28409..6654e7ebbbc 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/CharsTrieTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/CharsTrieTest.java @@ -15,6 +15,8 @@ package com.ibm.icu.dev.test.util; import java.util.NoSuchElementException; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.UnicodeSet; @@ -23,6 +25,7 @@ import com.ibm.icu.util.CharsTrie; import com.ibm.icu.util.CharsTrieBuilder; import com.ibm.icu.util.StringTrieBuilder; +@RunWith(JUnit4.class) public class CharsTrieTest extends TestFmwk { public CharsTrieTest() {} diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/CompactArrayTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/CompactArrayTest.java index a2119afb20d..fbe27c39472 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/CompactArrayTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/CompactArrayTest.java @@ -9,6 +9,8 @@ package com.ibm.icu.dev.test.util; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.Utility; @@ -18,8 +20,9 @@ import com.ibm.icu.util.CompactCharArray; /** * @since release 2.2 */ -public final class CompactArrayTest extends TestFmwk -{ +@RunWith(JUnit4.class) +public final class CompactArrayTest extends TestFmwk +{ @Test public void TestByteArrayCoverage() { CompactByteArray cba = new CompactByteArray(); @@ -52,7 +55,7 @@ public final class CompactArrayTest extends TestFmwk logln("equals: " + cba4.equals(cba5)); logln("equals: " + cba.equals(cba4)); - + cba4.compact(false); logln("equals: " + cba4.equals(cba5)); @@ -132,17 +135,17 @@ public final class CompactArrayTest extends TestFmwk cca3.setElementAt((char)0x405, (char)0xee); // different modification logln("different mod equals: " + cca.equals(cca3)); - + // after setElementAt isCompact is set to false cca3.compact(true); logln("different mod equals: " + cca.equals(cca3)); - + cca3.setElementAt((char)0x405, (char)0xee); // different modification logln("different mod equals: " + cca.equals(cca3)); // after setElementAt isCompact is set to false cca3.compact(); logln("different mod equals: " + cca.equals(cca3)); - + // v1.8 fails with extensive compaction, and defaults extensive, so don't compact // cca.compact(); CompactCharArray cca6 = (CompactCharArray)cca.clone(); diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/CurrencyTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/CurrencyTest.java index 5416194be85..9e4347feb76 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/CurrencyTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/CurrencyTest.java @@ -21,6 +21,8 @@ import java.util.Locale; import java.util.Set; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.dev.test.TestUtil; @@ -42,6 +44,7 @@ import com.ibm.icu.util.ULocale; * @test * @summary General test of Currency */ +@RunWith(JUnit4.class) public class CurrencyTest extends TestFmwk { /** * Test of basic API. diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/DebugUtilitiesTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/DebugUtilitiesTest.java index 5dc8a953663..b6665020a4f 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/DebugUtilitiesTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/DebugUtilitiesTest.java @@ -9,6 +9,8 @@ package com.ibm.icu.dev.test.util; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; @@ -16,6 +18,7 @@ import com.ibm.icu.dev.test.TestFmwk; * @author srl * */ +@RunWith(JUnit4.class) public class DebugUtilitiesTest extends TestFmwk { @Test diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/DisplayNameTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/DisplayNameTest.java index 4be9459b078..cd61579a87d 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/DisplayNameTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/DisplayNameTest.java @@ -20,6 +20,8 @@ import java.util.TreeSet; import org.junit.Ignore; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.ICUResourceBundle; @@ -32,9 +34,10 @@ import com.ibm.icu.util.UResourceBundle; // TODO(junit): test is broken in main branch +@RunWith(JUnit4.class) public class DisplayNameTest extends TestFmwk { static final boolean SHOW_ALL = false; - + interface DisplayNameGetter { public String get(ULocale locale, String code, Object context); } @@ -43,12 +46,12 @@ public class DisplayNameTest extends TestFmwk { { for (int k = 0; k < codeToName.length; ++k) codeToName[k] = new HashMap(); } - + static final Object[] zoneFormats = {new Integer(0), new Integer(1), new Integer(2), new Integer(3), new Integer(4), new Integer(5), new Integer(6), new Integer(7)}; static final Object[] currencyFormats = {new Integer(Currency.SYMBOL_NAME), new Integer(Currency.LONG_NAME)}; static final Object[] NO_CONTEXT = {null}; - + static final Date JAN1; static final Date JULY1; @@ -100,23 +103,27 @@ public class DisplayNameTest extends TestFmwk { private void checkLocale(ULocale locale) { logln("Checking " + locale); check("Language", locale, languages, null, new DisplayNameGetter() { + @Override public String get(ULocale loc, String code, Object context) { return ULocale.getDisplayLanguage(code, loc); } }); check("Script", locale, scripts, null, new DisplayNameGetter() { + @Override public String get(ULocale loc, String code, Object context) { // TODO This is kinda a hack; ought to be direct way. return ULocale.getDisplayScript("en_"+code, loc); } }); check("Country", locale, countries, null, new DisplayNameGetter() { + @Override public String get(ULocale loc, String code, Object context) { // TODO This is kinda a hack; ought to be direct way. return ULocale.getDisplayCountry("en_"+code, loc); } }); check("Currencies", locale, currencies, currencyFormats, new DisplayNameGetter() { + @Override public String get(ULocale loc, String code, Object context) { Currency s = Currency.getInstance(code); return s.getName(loc, ((Integer)context).intValue(), new boolean[1]); @@ -127,15 +134,16 @@ public class DisplayNameTest extends TestFmwk { check("Zones", locale, zones, zoneFormats, new DisplayNameGetter() { // TODO replace once we have real API + @Override public String get(ULocale loc, String code, Object context) { return getZoneString(loc, code, ((Integer)context).intValue()); } }); } - + Map zoneData = new HashMap(); - + private String getZoneString(ULocale locale, String olsonID, int item) { Map data = (Map)zoneData.get(locale); if (data == null) { @@ -163,7 +171,7 @@ public class DisplayNameTest extends TestFmwk { if (strings == null || item >= strings.length) return olsonID; return strings[item]; } - + static String[][] zonesAliases = { {"America/Atka", "America/Atka"}, {"America/Ensenada", "America/Ensenada"}, @@ -351,9 +359,9 @@ public class DisplayNameTest extends TestFmwk { System.arraycopy(strings,0,result,2,strings.length); return result; } - + Map bogusZones = null; - + private Map getAliasMap() { if (bogusZones == null) { bogusZones = new TreeMap(); @@ -365,7 +373,7 @@ public class DisplayNameTest extends TestFmwk { } - private void check(String type, ULocale locale, + private void check(String type, ULocale locale, String[] codes, Object[] contextList, DisplayNameGetter getter) { if (contextList == null) contextList = NO_CONTEXT; for (int k = 0; k < contextList.length; ++k) codeToName[k].clear(); @@ -381,7 +389,7 @@ public class DisplayNameTest extends TestFmwk { + ":\t" + locale + " [" + locale.getDisplayName(ULocale.ENGLISH) + "]" + "\t" + code + " [" + getter.get(ULocale.ENGLISH, code, context) + "]" ); - continue; + continue; } String otherCode = (String) codeToName[k].get(name); if (otherCode != null) { @@ -395,11 +403,11 @@ public class DisplayNameTest extends TestFmwk { } else { codeToName[k].put(name, code); if (SHOW_ALL) logln( - type + type + " (" + ((context != null) ? context : "") + ")" + "\t" + locale + " [" + locale.getDisplayName(ULocale.ENGLISH) + "]" + "\t" + code + "[" + getter.get(ULocale.ENGLISH, code, context) + "]" - + "\t=> " + name + + "\t=> " + name ); } } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/GenderInfoTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/GenderInfoTest.java index 9f263a4d074..cd1ca030dea 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/GenderInfoTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/GenderInfoTest.java @@ -12,12 +12,15 @@ import java.util.Arrays; import java.util.List; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.util.GenderInfo; import com.ibm.icu.util.GenderInfo.Gender; import com.ibm.icu.util.ULocale; +@RunWith(JUnit4.class) public class GenderInfoTest extends TestFmwk { public static GenderInfo NEUTRAL_LOCALE = GenderInfo.getInstance(ULocale.ENGLISH); public static GenderInfo MIXED_NEUTRAL_LOCALE = GenderInfo.getInstance(new ULocale("is")); @@ -43,7 +46,7 @@ public class GenderInfoTest extends TestFmwk { check(Gender.OTHER, Gender.MALE, Gender.MALE, Gender.MALE, Gender.MALE); check(Gender.OTHER, Gender.OTHER, Gender.MALE, Gender.MALE, Gender.FEMALE); check(Gender.OTHER, Gender.OTHER, Gender.MALE, Gender.MALE, Gender.OTHER); - + check(Gender.OTHER, Gender.OTHER, Gender.MALE, Gender.FEMALE, Gender.MALE); check(Gender.OTHER, Gender.FEMALE, Gender.FEMALE, Gender.FEMALE, Gender.FEMALE); check(Gender.OTHER, Gender.OTHER, Gender.MALE, Gender.FEMALE, Gender.OTHER); @@ -59,7 +62,7 @@ public class GenderInfoTest extends TestFmwk { assertEquals("mixed neutral " + mixed0, mixed, MIXED_NEUTRAL_LOCALE.getListGender(mixed0)); assertEquals("male taints " + mixed0, taints, MALE_TAINTS_LOCALE.getListGender(mixed0)); } - + @Test public void TestFallback() { assertEquals("Strange locale = root", GenderInfo.getInstance(ULocale.ROOT), GenderInfo.getInstance(new ULocale("xxx"))); diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ICUBinaryTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ICUBinaryTest.java index 6af7547b5f0..645a672e1ff 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ICUBinaryTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ICUBinaryTest.java @@ -13,30 +13,33 @@ import java.io.IOException; import java.nio.ByteBuffer; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.ICUBinary; /** -* Testing class for Trie. Tests here will be simple, since both CharTrie and +* Testing class for Trie. Tests here will be simple, since both CharTrie and * IntTrie are very similar and are heavily used in other parts of ICU4J. * Codes using Tries are expected to have detailed tests. * @author Syn Wee Quek * @since release 2.1 Jan 01 2002 */ -public final class ICUBinaryTest extends TestFmwk -{ +@RunWith(JUnit4.class) +public final class ICUBinaryTest extends TestFmwk +{ // constructor --------------------------------------------------- - + /** * Constructor */ public ICUBinaryTest() { } - + // public methods ----------------------------------------------- - + /** * Testing the constructors of the Tries */ @@ -71,6 +74,7 @@ public final class ICUBinaryTest extends TestFmwk ByteBuffer bytes = ByteBuffer.wrap(array); ICUBinary.Authenticate authenticate = new ICUBinary.Authenticate() { + @Override public boolean isDataVersionAcceptable(byte version[]) { return version[0] == 1; diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ICUResourceBundleTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ICUResourceBundleTest.java index 60f1f9572a5..28f77b7dc8e 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ICUResourceBundleTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ICUResourceBundleTest.java @@ -24,6 +24,8 @@ import java.util.TreeSet; import java.util.jar.JarEntry; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.ICUData; @@ -38,6 +40,7 @@ import com.ibm.icu.util.UResourceBundle; import com.ibm.icu.util.UResourceBundleIterator; import com.ibm.icu.util.UResourceTypeMismatchException; +@RunWith(JUnit4.class) public final class ICUResourceBundleTest extends TestFmwk { private static final ClassLoader testLoader = ICUResourceBundleTest.class.getClassLoader(); diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ICUServiceTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ICUServiceTest.java index e081e66906d..cd00d29c60f 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ICUServiceTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ICUServiceTest.java @@ -23,6 +23,8 @@ import java.util.Set; import java.util.SortedMap; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.ICULocaleService; @@ -40,6 +42,7 @@ import com.ibm.icu.impl.ICUService.SimpleFactory; import com.ibm.icu.impl.LocaleUtility; import com.ibm.icu.util.ULocale; +@RunWith(JUnit4.class) public class ICUServiceTest extends TestFmwk { private String lrmsg(String message, Object lhs, Object rhs) { @@ -99,6 +102,7 @@ public class ICUServiceTest extends TestFmwk super("Test Service"); } + @Override public Key createKey(String id) { return LocaleKey.createWithCanonicalFallback(id, null); // no fallback locale } @@ -197,13 +201,16 @@ public class ICUServiceTest extends TestFmwk // an anonymous factory than handles all ids { Factory factory = new Factory() { + @Override public Object create(Key key, ICUService unusedService) { return new ULocale(key.currentID()); } + @Override public void updateVisibleIDs(Map unusedResult) { } + @Override public String getDisplayName(String id, ULocale l) { return null; } @@ -420,7 +427,8 @@ public class ICUServiceTest extends TestFmwk { logln("display names in reverse order: " + service.getDisplayNames(ULocale.US, new Comparator() { - public int compare(Object lhs, Object rhs) { + @Override + public int compare(Object lhs, Object rhs) { return -String.CASE_INSENSITIVE_ORDER.compare((String)lhs, (String)rhs); } })); @@ -478,6 +486,7 @@ public class ICUServiceTest extends TestFmwk ICULocaleService ls = new ICULocaleService(); ServiceListener l1 = new ServiceListener() { private int n; + @Override public void serviceChanged(ICUService s) { logln("listener 1 report " + n++ + " service changed: " + s); } @@ -485,6 +494,7 @@ public class ICUServiceTest extends TestFmwk ls.addListener(l1); ServiceListener l2 = new ServiceListener() { private int n; + @Override public void serviceChanged(ICUService s) { logln("listener 2 report " + n++ + " service changed: " + s); } @@ -517,6 +527,7 @@ public class ICUServiceTest extends TestFmwk // since in a separate thread, we can callback and not deadlock ServiceListener l3 = new ServiceListener() { private int n; + @Override public void serviceChanged(ICUService s) { logln("listener 3 report " + n++ + " service changed..."); if (s.get("en_BOINK") == null) { // don't recurse on ourselves!!! @@ -549,10 +560,12 @@ public class ICUServiceTest extends TestFmwk this.factoryID = factoryID + ": "; } + @Override protected Object handleCreate(ULocale loc, int kind, ICUService service) { return factoryID + loc.toString(); } + @Override protected Set getSupportedIDs() { return ids; } @@ -624,10 +637,12 @@ public class ICUServiceTest extends TestFmwk supportedIDs = Collections.unmodifiableSet(result); } + @Override public Set getSupportedIDs() { return supportedIDs; } + @Override public String getDisplayName(String id, ULocale locale) { String prefix = ""; String suffix = ""; @@ -770,6 +785,7 @@ public class ICUServiceTest extends TestFmwk { SortedMap map = service.getDisplayNames(ULocale.US, new Comparator() { + @Override public int compare(Object lhs, Object rhs) { return -String.CASE_INSENSITIVE_ORDER.compare((String)lhs, (String)rhs); } @@ -791,6 +807,7 @@ public class ICUServiceTest extends TestFmwk logln("test one: " + service.get(greetingID)); class WrapFactory implements Factory { + @Override public Object create(Key key, ICUService serviceArg) { if (key.currentID().equals(greetingID)) { Object previous = serviceArg.getKey(key, null, this); @@ -799,10 +816,12 @@ public class ICUServiceTest extends TestFmwk return null; } + @Override public void updateVisibleIDs(Map result) { result.put("greeting", this); } + @Override public String getDisplayName(String id, ULocale locale) { return "wrap '" + id + "'"; } @@ -991,11 +1010,13 @@ public class ICUServiceTest extends TestFmwk } static class ICUNSubclass extends ICUNotifier { + @Override public boolean acceptsListener(EventListener l) { return l instanceof MyListener; } - + // not used, just needed to implement abstract base + @Override public void notifyListener(EventListener l) { } } @@ -1005,6 +1026,7 @@ public class ICUServiceTest extends TestFmwk super(visible ? VISIBLE : INVISIBLE); } + @Override protected Set getSupportedIDs() { return Collections.EMPTY_SET; } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ICUServiceThreadTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ICUServiceThreadTest.java index 81f9f08b3d7..c5405e283d0 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ICUServiceThreadTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ICUServiceThreadTest.java @@ -25,6 +25,8 @@ import java.util.Set; import java.util.SortedMap; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.ICULocaleService; @@ -33,6 +35,7 @@ import com.ibm.icu.impl.ICUService.Factory; import com.ibm.icu.impl.ICUService.SimpleFactory; import com.ibm.icu.util.ULocale; +@RunWith(JUnit4.class) public class ICUServiceThreadTest extends TestFmwk { private static final boolean PRINTSTATS = false; @@ -52,10 +55,12 @@ public class ICUServiceThreadTest extends TestFmwk super(new ULocale(id), id, true); } + @Override public String getDisplayName(String idForDisplay, ULocale locale) { return (visible && idForDisplay.equals(this.id)) ? "(" + locale.toString() + ") " + idForDisplay : null; } + @Override public String toString() { return "Factory_" + id; } @@ -121,6 +126,7 @@ public class ICUServiceThreadTest extends TestFmwk this.setDaemon(true); } + @Override public void run() { while (WAIT) { Thread.yield(); @@ -189,6 +195,7 @@ public class ICUServiceThreadTest extends TestFmwk super("REG " + name, service, delay); } + @Override protected void iterate() { Factory f = new TestFactory(getCLV()); service.registerFactory(f); @@ -207,6 +214,7 @@ public class ICUServiceThreadTest extends TestFmwk factories = service.factories(); } + @Override public void iterate() { int s = factories.size(); if (s == 0) { @@ -230,6 +238,7 @@ public class ICUServiceThreadTest extends TestFmwk this.factories = factories; } + @Override public void iterate() { if (n < factories.length) { Factory f = factories[n++]; @@ -245,6 +254,7 @@ public class ICUServiceThreadTest extends TestFmwk super("VIS " + name, service, delay); } + @Override protected void iterate() { Set ids = service.getVisibleIDs(); Iterator iter = ids.iterator(); @@ -266,6 +276,7 @@ public class ICUServiceThreadTest extends TestFmwk this.locale = locale; } + @Override protected void iterate() { Map names = getDisplayNames(service,locale); Iterator iter = names.entrySet().iterator(); @@ -298,6 +309,7 @@ public class ICUServiceThreadTest extends TestFmwk actualID = new String[1]; } + @Override protected void iterate() { String id = getCLV(); Object o = service.get(id, actualID); @@ -317,6 +329,7 @@ public class ICUServiceThreadTest extends TestFmwk this.list = list; } + @Override protected void iterate() { if (--n < 0) { n = list.length - 1; @@ -420,6 +433,7 @@ public class ICUServiceThreadTest extends TestFmwk Factory[] factories = (Factory[])fc.toArray(new Factory[fc.size()]); Comparator comp = new Comparator() { + @Override public int compare(Object lhs, Object rhs) { return lhs.toString().compareTo(rhs.toString()); } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/LocaleAliasTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/LocaleAliasTest.java index 4c17cceece9..2c7934920d9 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/LocaleAliasTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/LocaleAliasTest.java @@ -18,6 +18,8 @@ import java.util.HashMap; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.ICUData; @@ -26,6 +28,7 @@ import com.ibm.icu.util.Calendar; import com.ibm.icu.util.ULocale; import com.ibm.icu.util.UResourceBundle; +@RunWith(JUnit4.class) public class LocaleAliasTest extends TestFmwk { private static final ULocale[][] _LOCALES = { @@ -35,7 +38,7 @@ public class LocaleAliasTest extends TestFmwk { {new ULocale("iw"), new ULocale("he")}, {new ULocale("iw", "IL"), new ULocale("he", "IL")}, {new ULocale("ji"), new ULocale("yi")}, - + {new ULocale("en", "BU"), new ULocale("en", "MM")}, {new ULocale("en", "DY"), new ULocale("en", "BJ")}, {new ULocale("en", "HV"), new ULocale("en", "BF")}, @@ -43,15 +46,15 @@ public class LocaleAliasTest extends TestFmwk { {new ULocale("en", "TP"), new ULocale("en", "TL")}, {new ULocale("en", "ZR"), new ULocale("en", "CD")} }; - + private static final int _LOCALE_NUMBER = _LOCALES.length; private static ULocale[] available = null; private HashMap availableMap = new HashMap(); private static final ULocale _DEFAULT_LOCALE = ULocale.US; - + public LocaleAliasTest() { } - + @Before public void init() { available = ULocale.getAvailableLocales(); @@ -82,7 +85,7 @@ public class LocaleAliasTest extends TestFmwk { // +firstDayOfWeek1+" new:"+firstDayOfWeek2); // pass = false; // } - + //Test function "getLocale(ULocale.VALID_LOCALE)" ULocale l1 = c1.getLocale(ULocale.VALID_LOCALE); ULocale l2 = c2.getLocale(ULocale.VALID_LOCALE); @@ -95,11 +98,11 @@ public class LocaleAliasTest extends TestFmwk { if(!c1.equals(c2)){ errln("CalendarTest: c1!=c2. newLoc= "+newLoc +" oldLoc= "+oldLoc); } - logln("Calendar(getLocale) old:"+l1+" new:"+l2); + logln("Calendar(getLocale) old:"+l1+" new:"+l2); } ULocale.setDefault(defLoc); } - + @Test public void TestDateFormat() { ULocale defLoc = ULocale.getDefault(); @@ -113,7 +116,7 @@ public class LocaleAliasTest extends TestFmwk { } DateFormat df1 = DateFormat.getDateInstance(DateFormat.FULL, oldLoc); DateFormat df2 = DateFormat.getDateInstance(DateFormat.FULL, newLoc); - + //Test function "getLocale" ULocale l1 = df1.getLocale(ULocale.VALID_LOCALE); ULocale l2 = df2.getLocale(ULocale.VALID_LOCALE); @@ -127,7 +130,7 @@ public class LocaleAliasTest extends TestFmwk { errln("DateFormatTest: df1!=df2: newLoc= "+newLoc +" oldLoc= "+oldLoc); } TestFmwk.logln("DateFormat(getLocale) old:"+l1+" new:"+l2); - + //Test function "format" // Date d = new Date(); // String d1 = df1.format(d); @@ -139,7 +142,7 @@ public class LocaleAliasTest extends TestFmwk { } ULocale.setDefault(defLoc); } - + @Test public void TestULocale() { ULocale defLoc = ULocale.getDefault(); @@ -153,7 +156,7 @@ public class LocaleAliasTest extends TestFmwk { } ULocale ul1 = new ULocale(oldLoc.toString()); ULocale ul2 = new ULocale(newLoc.toString()); - + String name1 = ul1.getDisplayName(); String name2 = ul2.getDisplayName(); if (!name1.equals(name2)) { @@ -163,7 +166,7 @@ public class LocaleAliasTest extends TestFmwk { } ULocale.setDefault(defLoc); } - + @Test public void TestDisplayName() { ULocale defLoc = ULocale.getDefault(); @@ -177,14 +180,14 @@ public class LocaleAliasTest extends TestFmwk { String newCountry = newLoc.getDisplayCountry(available[j]); String oldLang = oldLoc.getDisplayLanguage(available[j]); String newLang = newLoc.getDisplayLanguage(available[j]); - - // is there display name for the current country ID + + // is there display name for the current country ID if(!newCountry.equals(newLoc.getCountry())){ if(!oldCountry.equals(newCountry)){ errln("getCountry() failed for "+ oldLoc +" oldCountry= "+ prettify(oldCountry) +" newCountry = "+prettify(newCountry)+ " in display locale "+ available[j].toString()); } } - //there is a display name for the current lang ID + //there is a display name for the current lang ID if(!newLang.equals(newLoc.getLanguage())){ if(!oldLang.equals(newLang)){ errln("getLanguage() failed for " + oldLoc + " oldLang = "+ prettify(oldLang) +" newLang = "+prettify(newLang)+ " in display locale "+ available[j].toString()); @@ -208,11 +211,11 @@ public class LocaleAliasTest extends TestFmwk { ULocale newLoc = _LOCALES[i][1]; UResourceBundle urb1 = null; UResourceBundle urb2 = null; - + urb1 = UResourceBundle.getBundleInstance(ICUData.ICU_BASE_NAME, oldLoc); urb2 = UResourceBundle.getBundleInstance(ICUData.ICU_BASE_NAME, newLoc); ULocale l1 = urb1.getULocale(); - ULocale l2 = urb2.getULocale(); + ULocale l2 = urb2.getULocale(); if (!newLoc.equals(l1)) { errln("ResourceBundleTest: newLoc!=l1: newLoc= "+newLoc +" l1= "+l1); } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/LocaleBuilderTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/LocaleBuilderTest.java index 5c762980237..772d0eab26b 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/LocaleBuilderTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/LocaleBuilderTest.java @@ -11,6 +11,8 @@ package com.ibm.icu.dev.test.util; import java.util.Arrays; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.util.IllformedLocaleException; @@ -20,6 +22,7 @@ import com.ibm.icu.util.ULocale.Builder; /** * Test cases for ULocale.LocaleBuilder */ +@RunWith(JUnit4.class) public class LocaleBuilderTest extends TestFmwk { @Test public void TestLocaleBuilder() { @@ -178,12 +181,12 @@ public class LocaleBuilderTest extends TestFmwk { if (expected != null) { ULocale loc = bld.build(); if (!expected[1].equals(loc.toString())) { - errln("FAIL: Wrong locale ID - " + loc + + errln("FAIL: Wrong locale ID - " + loc + " for test case: " + Arrays.toString(TESTCASE[tidx])); } String langtag = loc.toLanguageTag(); if (!expected[0].equals(langtag)) { - errln("FAIL: Wrong language tag - " + langtag + + errln("FAIL: Wrong language tag - " + langtag + " for test case: " + Arrays.toString(TESTCASE[tidx])); } ULocale loc1 = ULocale.forLanguageTag(langtag); @@ -209,7 +212,7 @@ public class LocaleBuilderTest extends TestFmwk { ULocale loc2 = bld.build(); if (!loc.equals(loc2)) { errln("FAIL: Locale loc2 " + loc2 + " was returned by the builder. Expected " + loc); - } + } } catch (IllformedLocaleException e) { errln("FAIL: IllformedLocaleException: " + e.getMessage()); } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/LocaleDataTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/LocaleDataTest.java index c38a1e23f51..7c2c1472445 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/LocaleDataTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/LocaleDataTest.java @@ -13,6 +13,8 @@ import java.util.HashSet; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.ICUResourceBundle; @@ -29,17 +31,18 @@ import com.ibm.icu.util.ULocale; * To change the template for this generated type comment go to * Window>Preferences>Java>Code Generation>Code and Comments */ +@RunWith(JUnit4.class) public class LocaleDataTest extends TestFmwk{ private ULocale[] availableLocales = null; public LocaleDataTest(){ } - + @Before public void init() { availableLocales = ICUResourceBundle.getAvailableULocales(); } - + @Test public void TestPaperSize(){ for(int i = 0; i < availableLocales.length; i++){ @@ -70,7 +73,7 @@ public class LocaleDataTest extends TestFmwk{ if(paperSize.getHeight()!= 297 || paperSize.getWidth() != 210 ){ errln("PaperSize did not return the expected value for locale "+ locale + " Expected height: 297 width: 210."+ - " Got height: "+paperSize.getHeight() +" width: "+paperSize.getWidth() + " Got height: "+paperSize.getHeight() +" width: "+paperSize.getWidth() ); }else{ logln("PaperSize returned the expected values for locale " + locale); @@ -87,7 +90,7 @@ public class LocaleDataTest extends TestFmwk{ String lang = locale.getLanguage(); if(lang.equals("in")){ continue; - } + } ULocale fullLoc = ULocale.addLikelySubtags(locale); if(fullLoc.toString().indexOf("_US") >= 0 || fullLoc.toString().indexOf("_MM") >= 0 || fullLoc.toString().indexOf("_LR") >= 0){ if(ms == LocaleData.MeasurementSystem.US){ @@ -106,7 +109,7 @@ public class LocaleDataTest extends TestFmwk{ logln("Got the expected measurement system for locale: " + locale); }else{ errln("Did not get the expected measurement system for locale: "+ locale); - } + } } } } @@ -177,13 +180,15 @@ public class LocaleDataTest extends TestFmwk{ set = s; scs = scriptCodes; } + @Override public int hashCode() { int hash = 0; for (int i=0; i containedRegions = r.getContainedRegions(); for (Region cr : containedRegions ) { if ( cr.getContainingRegion() != r) { - errln("Region: " + r.toString() + " contains region: " + cr.toString() + ". Expected containing region of this region to be the original region, but got: " + + errln("Region: " + r.toString() + " contains region: " + cr.toString() + ". Expected containing region of this region to be the original region, but got: " + ( cr.getContainingRegion() == null ? "NULL" : cr.getContainingRegion().toString())); } } @@ -456,7 +459,7 @@ public class RegionTest extends TestFmwk { } @Test - public void TestGetContainedRegionsWithType() { + public void TestGetContainedRegionsWithType() { for (String [] rd : knownRegions ) { try { Region r = Region.getInstance(rd[0]); @@ -466,7 +469,7 @@ public class RegionTest extends TestFmwk { Set containedRegions = r.getContainedRegions(Region.RegionType.TERRITORY); for (Region cr : containedRegions ) { if ( cr.getContainingRegion(Region.RegionType.CONTINENT) != r) { - errln("Continent: " + r.toString() + " contains territory: " + cr.toString() + ". Expected containing continent of this region to be the original continent, but got: " + + errln("Continent: " + r.toString() + " contains territory: " + cr.toString() + ". Expected containing continent of this region to be the original continent, but got: " + ( cr.getContainingRegion() == null ? "NULL" : cr.getContainingRegion().toString())); } } @@ -477,17 +480,17 @@ public class RegionTest extends TestFmwk { } @Test - public void TestGetContainingRegionWithType() { + public void TestGetContainingRegionWithType() { for (String [] rd : knownRegions ) { try { Region r = Region.getInstance(rd[0]); Region c = r.getContainingRegion(Region.RegionType.CONTINENT); - if (rd[4] == null) { + if (rd[4] == null) { if ( c != null) { errln("Containing continent for " + r.toString() + " should have been NULL. Got: " + c.toString()); } } else { - Region p = Region.getInstance(rd[4]); + Region p = Region.getInstance(rd[4]); if ( !p.equals(c)) { errln("Expected containing continent of region " + r.toString() + " to be " + p.toString() + ". Got: " + ( c == null ? "NULL" : c.toString()) ); } @@ -499,17 +502,17 @@ public class RegionTest extends TestFmwk { } @Test - public void TestGetContainingRegion() { + public void TestGetContainingRegion() { for (String [] rd : knownRegions ) { try { Region r = Region.getInstance(rd[0]); Region c = r.getContainingRegion(); - if (rd[2] == null) { + if (rd[2] == null) { if ( c != null) { errln("Containing region for " + r.toString() + " should have been NULL. Got: " + c.toString()); } } else { - Region p = Region.getInstance(rd[2]); + Region p = Region.getInstance(rd[2]); if ( !p.equals(c)) { errln("Expected containing region of region " + r.toString() + " to be " + p.toString() + ". Got: " + ( c == null ? "NULL" : c.toString()) ); } @@ -545,7 +548,7 @@ public class RegionTest extends TestFmwk { } } catch (IllegalArgumentException ex ) { errln("Known region " + data[i] + " was not recognized."); - } + } } } catch (IllegalArgumentException ex ) { errln("Known region " + inputID + " was not recognized."); @@ -554,7 +557,7 @@ public class RegionTest extends TestFmwk { } @Test - public void TestContains() { + public void TestContains() { for (String [] rd : knownRegions ) { try { Region r = Region.getInstance(rd[0]); diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/SimpleFormatterTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/SimpleFormatterTest.java index e65c7aadede..23a525c7d2d 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/SimpleFormatterTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/SimpleFormatterTest.java @@ -9,12 +9,15 @@ package com.ibm.icu.dev.test.util; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.MessageFormat; import com.ibm.icu.text.SimpleFormatter; import com.ibm.icu.util.ULocale; +@RunWith(JUnit4.class) public class SimpleFormatterTest extends TestFmwk { /** @@ -23,9 +26,9 @@ public class SimpleFormatterTest extends TestFmwk { public SimpleFormatterTest() { } - + // public methods ----------------------------------------------- - + @Test public void TestWithNoArguments() { SimpleFormatter fmt = SimpleFormatter.compile("This doesn''t have templates '{0}"); @@ -102,7 +105,7 @@ public class SimpleFormatterTest extends TestFmwk { SimpleFormatter.compile( "Templates {1}{2} and {3} are here.").getTextWithNoArguments()); } - + @Test public void TestTooFewArgumentValues() { SimpleFormatter fmt = SimpleFormatter.compile( @@ -128,7 +131,7 @@ public class SimpleFormatterTest extends TestFmwk { // Expected } } - + @Test public void TestWithArguments() { SimpleFormatter fmt = SimpleFormatter.compile( @@ -136,12 +139,12 @@ public class SimpleFormatterTest extends TestFmwk { assertEquals( "getArgumentLimit", 5, - fmt.getArgumentLimit()); + fmt.getArgumentLimit()); assertEquals( "toString", "Templates {2}{1} and {4} are out of order.", fmt.toString()); - int[] offsets = new int[6]; + int[] offsets = new int[6]; assertEquals( "format", "123456: Templates frogtommy and {0} are out of order.", @@ -149,11 +152,11 @@ public class SimpleFormatterTest extends TestFmwk { new StringBuilder("123456: "), offsets, "freddy", "tommy", "frog", "leg", "{0}").toString()); - + int[] expectedOffsets = {-1, 22, 18, -1, 32, -1}; verifyOffsets(expectedOffsets, offsets); } - + @Test public void TestFormatUseAppendToAsArgument() { SimpleFormatter fmt = SimpleFormatter.compile( @@ -166,7 +169,7 @@ public class SimpleFormatterTest extends TestFmwk { // expected. } } - + @Test public void TestFormatReplaceNoOptimization() { SimpleFormatter fmt = SimpleFormatter.compile("{2}, {0}, {1} and {3}"); @@ -179,12 +182,12 @@ public class SimpleFormatterTest extends TestFmwk { result, offsets, result, "freddy", "frog", "by").toString()); - + int[] expectedOffsets = {6, 16, 0, 27}; verifyOffsets(expectedOffsets, offsets); } - - + + @Test public void TestFormatReplaceNoOptimizationLeadingText() { SimpleFormatter fmt = SimpleFormatter.compile("boo {2}, {0}, {1} and {3}"); @@ -197,11 +200,11 @@ public class SimpleFormatterTest extends TestFmwk { result, offsets, "freddy", "frog", result, "by").toString()); - + int[] expectedOffsets = {14, 22, 4, 31}; verifyOffsets(expectedOffsets, offsets); } - + @Test public void TestFormatReplaceOptimization() { SimpleFormatter fmt = SimpleFormatter.compile("{2}, {0}, {1} and {3}"); @@ -214,11 +217,11 @@ public class SimpleFormatterTest extends TestFmwk { result, offsets, "freddy", "frog", result, "by").toString()); - + int[] expectedOffsets = {10, 18, 0, 27}; - verifyOffsets(expectedOffsets, offsets); + verifyOffsets(expectedOffsets, offsets); } - + @Test public void TestFormatReplaceOptimizationNoOffsets() { SimpleFormatter fmt = SimpleFormatter.compile("{2}, {0}, {1} and {3}"); @@ -230,9 +233,9 @@ public class SimpleFormatterTest extends TestFmwk { result, null, "freddy", "frog", result, "by").toString()); - + } - + @Test public void TestFormatReplaceNoOptimizationNoOffsets() { SimpleFormatter fmt = SimpleFormatter.compile( @@ -243,7 +246,7 @@ public class SimpleFormatterTest extends TestFmwk { "Arguments previous: and frog", fmt.formatAndReplace(result, null, result, "frog").toString()); } - + @Test public void TestFormatReplaceNoOptimizationLeadingArgumentUsedTwice() { SimpleFormatter fmt = SimpleFormatter.compile( @@ -276,7 +279,7 @@ public class SimpleFormatterTest extends TestFmwk { if (expected[i] != actual[i]) { errln("Expected "+expected[i]+", got " + actual[i]); } - } + } } - + } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/StringTokenizerTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/StringTokenizerTest.java index f3201eedfc7..30cd5ad85d8 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/StringTokenizerTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/StringTokenizerTest.java @@ -10,6 +10,8 @@ package com.ibm.icu.dev.test.util; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.Utility; @@ -22,19 +24,20 @@ import com.ibm.icu.util.StringTokenizer; * @author Syn Wee Quek * @since oct 26 2002 */ +@RunWith(JUnit4.class) public final class StringTokenizerTest extends TestFmwk -{ +{ // constructor =================================================== - + /** * Constructor */ public StringTokenizerTest() { } - + // public methods -------------------------------------------------------- - + /** * Testing constructors */ @@ -43,7 +46,7 @@ public final class StringTokenizerTest extends TestFmwk { String str = "this\tis\na\rstring\ftesting\tStringTokenizer\nconstructors!"; String delimiter = " \t\n\r\f"; - String expected[] = {"this", "is", "a", "string", "testing", + String expected[] = {"this", "is", "a", "string", "testing", "StringTokenizer", "constructors!"}; StringTokenizer defaultst = new StringTokenizer(str); StringTokenizer stdelimiter = new StringTokenizer(str, delimiter); @@ -51,11 +54,11 @@ public final class StringTokenizerTest extends TestFmwk false); UnicodeSet delimiterset = new UnicodeSet("[" + delimiter + "]", false); StringTokenizer stdelimiterset = new StringTokenizer(str, delimiterset); - StringTokenizer stdelimitersetreturn = new StringTokenizer(str, + StringTokenizer stdelimitersetreturn = new StringTokenizer(str, delimiterset, false); for (int i = 0; i < expected.length; i ++) { - if (!(defaultst.nextElement().equals(expected[i]) + if (!(defaultst.nextElement().equals(expected[i]) && stdelimiter.nextElement().equals(expected[i]) && stdelimiterreturn.nextElement().equals(expected[i]) && stdelimiterset.nextElement().equals(expected[i]) @@ -63,13 +66,13 @@ public final class StringTokenizerTest extends TestFmwk errln("Constructor with default delimiter gives wrong results"); } } - + UnicodeSet delimiterset1 = new UnicodeSet("[" + delimiter + "]", true); StringTokenizer stdelimiterset1 = new StringTokenizer(str, delimiterset1); if(!(stdelimiterset1.nextElement().equals(str))) errln("Constructor with a UnicodeSet to ignoreWhiteSpace is " + "to return the same string."); - + String expected1[] = {"this", "\t", "is", "\n", "a", "\r", "string", "\f", "testing", "\t", "StringTokenizer", "\n", "constructors!"}; @@ -81,34 +84,34 @@ public final class StringTokenizerTest extends TestFmwk errln("Constructor with default delimiter and delimiter tokens gives wrong results"); } } - + stdelimiter = new StringTokenizer(str, (String)null); stdelimiterreturn = new StringTokenizer(str, (String)null, false); delimiterset = null; stdelimiterset = new StringTokenizer(str, delimiterset); stdelimitersetreturn = new StringTokenizer(str, delimiterset, false); - + if (!(stdelimiter.nextElement().equals(str) && stdelimiterreturn.nextElement().equals(str) && stdelimiterset.nextElement().equals(str) && stdelimitersetreturn.nextElement().equals(str))) { errln("Constructor with null delimiter gives wrong results"); } - + delimiter = ""; stdelimiter = new StringTokenizer(str, delimiter); stdelimiterreturn = new StringTokenizer(str, delimiter, false); delimiterset = new UnicodeSet(); stdelimiterset = new StringTokenizer(str, delimiterset); stdelimitersetreturn = new StringTokenizer(str, delimiterset, false); - + if (!(stdelimiter.nextElement().equals(str) && stdelimiterreturn.nextElement().equals(str) && stdelimiterset.nextElement().equals(str) && stdelimitersetreturn.nextElement().equals(str))) { errln("Constructor with empty delimiter gives wrong results"); } - + try { defaultst = new StringTokenizer(null); errln("null string should throw an exception"); @@ -141,7 +144,7 @@ public final class StringTokenizerTest extends TestFmwk logln("PASS: Constructor with null string failed as expected"); } } - + /** * Testing supplementary */ @@ -151,7 +154,7 @@ public final class StringTokenizerTest extends TestFmwk String str = "bmp string \ud800 with a unmatched surrogate character"; String delimiter = "\ud800\udc00"; String expected[] = {str}; - + StringTokenizer tokenizer = new StringTokenizer(str, delimiter); if (!tokenizer.nextElement().equals(expected[0])) { errln("Error parsing \"" + Utility.hex(str) + "\""); @@ -160,7 +163,7 @@ public final class StringTokenizerTest extends TestFmwk errln("Number of tokens exceeded expected"); } delimiter = "\ud800"; - String expected1[] = {"bmp string ", + String expected1[] = {"bmp string ", " with a unmatched surrogate character"}; tokenizer = new StringTokenizer(str, delimiter); int i = 0; @@ -172,7 +175,7 @@ public final class StringTokenizerTest extends TestFmwk if (tokenizer.hasMoreElements()) { errln("Number of tokens exceeded expected"); } - + str = "string \ud800\udc00 with supplementary character"; delimiter = "\ud800"; String expected2[] = {str}; @@ -183,7 +186,7 @@ public final class StringTokenizerTest extends TestFmwk if (tokenizer.hasMoreElements()) { errln("Number of tokens exceeded expected"); } - + delimiter = "\ud800\udc00"; String expected3[] = {"string ", " with supplementary character"}; tokenizer = new StringTokenizer(str, delimiter); @@ -196,7 +199,7 @@ public final class StringTokenizerTest extends TestFmwk if (tokenizer.hasMoreElements()) { errln("Number of tokens exceeded expected"); } - + str = "\ud800 \ud800\udc00 \ud800 \ud800\udc00"; delimiter = "\ud800"; String expected4[] = {" \ud800\udc00 ", " \ud800\udc00"}; @@ -209,7 +212,7 @@ public final class StringTokenizerTest extends TestFmwk if (tokenizer.hasMoreElements()) { errln("Number of tokens exceeded expected"); } - + delimiter = "\ud800\udc00"; String expected5[] = {"\ud800 ", " \ud800 "}; i = 0; @@ -222,7 +225,7 @@ public final class StringTokenizerTest extends TestFmwk errln("Number of tokens exceeded expected"); } } - + /** * Testing next api */ @@ -230,10 +233,10 @@ public final class StringTokenizerTest extends TestFmwk public void TestNextNonDelimiterToken() { String str = " , 1 2 3 AHHHHH! 5.5 6 7 , 8\n"; - String expected[] = {",", "1", "2", "3", "AHHHHH!", "5.5", "6", "7", + String expected[] = {",", "1", "2", "3", "AHHHHH!", "5.5", "6", "7", ",", "8\n"}; String delimiter = " "; - + StringTokenizer tokenizer = new StringTokenizer(str, delimiter); int currtoken = 0; while (tokenizer.hasMoreElements()) { @@ -246,7 +249,7 @@ public final class StringTokenizerTest extends TestFmwk if (currtoken != expected.length) { errln("Didn't get correct number of tokens"); } - + tokenizer = new StringTokenizer("", delimiter); if (tokenizer.hasMoreElements()) { errln("Empty string should not have any tokens"); @@ -257,7 +260,7 @@ public final class StringTokenizerTest extends TestFmwk } catch (Exception e) { logln("PASS: empty string failed as expected"); } - + tokenizer = new StringTokenizer(", ,", ", "); if (tokenizer.hasMoreElements()) { errln("String with only delimiters should not have any tokens"); @@ -275,7 +278,7 @@ public final class StringTokenizerTest extends TestFmwk } if (!tokenizer.nextElement().equals("q")) { errln("String that does not begin with delimiters should have some tokens"); - } + } try { tokenizer.nextElement(); errln("String has only one token"); @@ -335,7 +338,7 @@ public final class StringTokenizerTest extends TestFmwk "AHHHHH!", " ", "5.5", " ", "6", " ", "7", " ", ",", " ", "8\n"}; String delimiter = " "; - + StringTokenizer tokenizer = new StringTokenizer(str, delimiter, true, true); int currtoken = 0; @@ -349,7 +352,7 @@ public final class StringTokenizerTest extends TestFmwk if (currtoken != expected.length) { errln("Didn't get correct number of tokens"); } - + tokenizer = new StringTokenizer("", delimiter, true); if (tokenizer.hasMoreElements()) { errln("Empty string should not have any tokens"); @@ -360,7 +363,7 @@ public final class StringTokenizerTest extends TestFmwk } catch (Exception e) { logln("PASS: Empty string failed as expected"); } - + tokenizer = new StringTokenizer(", ,", ", ", true, true); if (!tokenizer.hasMoreElements()) { errln("String with only delimiters should have tokens when delimiter is treated as tokens"); @@ -370,14 +373,14 @@ public final class StringTokenizerTest extends TestFmwk } tokenizer = new StringTokenizer("q, ,", ", ", true, true); - + if (!tokenizer.hasMoreElements()) { errln("String should have some tokens"); } - if (!tokenizer.nextElement().equals("q") + if (!tokenizer.nextElement().equals("q") || !tokenizer.nextElement().equals(", ,")) { errln("String tokens do not match expected results"); - } + } try { tokenizer = new StringTokenizer(null, delimiter, true); @@ -391,7 +394,7 @@ public final class StringTokenizerTest extends TestFmwk errln("Should have recieved the same string when there are no delimiters"); } } - + /** * Testing count tokens */ @@ -400,10 +403,10 @@ public final class StringTokenizerTest extends TestFmwk { String str = "this\tis\na\rstring\ftesting\tStringTokenizer\nconstructors!"; String delimiter = " \t\n\r\f"; - String expected[] = {"this", "is", "a", "string", "testing", + String expected[] = {"this", "is", "a", "string", "testing", "StringTokenizer", "constructors!"}; - String expectedreturn[] = {"this", "\t", "is", "\n", "a", "\r", - "string", "\f", "testing", "\t", + String expectedreturn[] = {"this", "\t", "is", "\n", "a", "\r", + "string", "\f", "testing", "\t", "StringTokenizer", "\n", "constructors!"}; StringTokenizer st = new StringTokenizer(str, delimiter); StringTokenizer streturn = new StringTokenizer(str, delimiter, true); @@ -424,9 +427,9 @@ public final class StringTokenizerTest extends TestFmwk || streturn.countTokens() != expectedreturn.length - i - 1) { errln("CountTokens with default delimiter and delimiter tokens gives wrong results"); } - } + } } - + /** * Next token with new delimiters */ @@ -448,15 +451,15 @@ public final class StringTokenizerTest extends TestFmwk if (!st.nextToken(delimiter[j]).equals(expected[j][i])) { errln("nextToken() with delimiters error " + i + " " + j); } - if (st.countTokens() != expected[j].length - i) { + if (st.countTokens() != expected[j].length - i) { errln("countTokens() after nextToken() with delimiters error" + i + " " + j); } } - } + } st = new StringTokenizer(str); String delimiter1[] = {"0", "2", "4"}; - String expected1[] = {"abc", "def1ghi", "jkl3mno", "pqr", "stu1vwx", + String expected1[] = {"abc", "def1ghi", "jkl3mno", "pqr", "stu1vwx", "yza3bcd", "efg", "hij1klm", "nop3qrs", "tuv"}; for (int i = 0; i < expected1.length; i ++) { if (!st.nextToken(delimiter1[i % delimiter1.length]).equals( @@ -465,7 +468,7 @@ public final class StringTokenizerTest extends TestFmwk } } } - + @Test public void TestBug4423() { @@ -474,7 +477,7 @@ public final class StringTokenizerTest extends TestFmwk String s1 = "This is a test"; StringTokenizer tzr = new StringTokenizer(s1); int tokenCount = 0; - + int t = tzr.countTokens(); if (t!= 4) { errln("tzr.countTokens() returned " + t + ". Expected 4"); @@ -489,7 +492,7 @@ public final class StringTokenizerTest extends TestFmwk if (tokenCount != 4) { errln("Incorrect number of tokens found = " + tokenCount); } - + // Precomputed tokens arrays can grow. Check for edge cases around // boundary where growth is forced. Array grows in increments of 100 tokens. String s2 = ""; @@ -517,7 +520,7 @@ public final class StringTokenizerTest extends TestFmwk break; } } - + } @Test @@ -561,13 +564,13 @@ public final class StringTokenizerTest extends TestFmwk } catch(Exception e){ errln("UnicodeSet._generatePattern is not suppose to return an exception."); } - + try{ us._generatePattern(null, true); errln("UnicodeSet._generatePattern is suppose to return an exception."); } catch(Exception e){} } - + /* Tests the method * public int matches(Replaceable text, int[] offset, int limit, boolean incremental) */ @@ -577,20 +580,20 @@ public final class StringTokenizerTest extends TestFmwk ReplaceableString rs = new ReplaceableString("dummy"); UnicodeSet us = new UnicodeSet(0,100000); // Create a large Unicode set us.add("dummy"); - + int[] offset = {0}; int limit = 0; - + if(us.matches(null, offset, limit, true) != UnicodeSet.U_PARTIAL_MATCH){ errln("UnicodeSet.matches is suppose to return " + UnicodeSet.U_PARTIAL_MATCH + " but got " + us.matches(null, offset, limit, true)); } - + if(us.matches(null, offset, limit, false) != UnicodeSet.U_MATCH){ errln("UnicodeSet.matches is suppose to return " + UnicodeSet.U_MATCH + " but got " + us.matches(null, offset, limit, false)); } - + // Tests when "int maxLen = forward ? limit-offset[0] : offset[0]-limit;" is true and false try{ offset[0] = 0; // Takes the letter "d" @@ -600,10 +603,10 @@ public final class StringTokenizerTest extends TestFmwk } catch(Exception e) { errln("UnicodeSet.matches is not suppose to return an exception"); } - + // TODO: Tests when "if (forward && length < highWaterLength)" is true } - + /* Tests the method * private static int matchRest (Replaceable text, int start, int limit, String s) * from public int matches(Replaceable text, ... @@ -612,26 +615,26 @@ public final class StringTokenizerTest extends TestFmwk public void TestMatchRest(){ // TODO: Tests when "if (maxLen > slen) maxLen = slen;" is true and false } - + /* Tests the method * public int matchesAt(CharSequence text, int offset) */ @Test public void TestMatchesAt(){ UnicodeSet us = new UnicodeSet(); // Empty set - us.matchesAt((CharSequence)"dummy", 0); + us.matchesAt("dummy", 0); us.add("dummy"); // Add an item - - us.matchesAt((CharSequence)"dummy", 0); + + us.matchesAt("dummy", 0); us.add("dummy2"); // Add another item - - us.matchesAt((CharSequence)"yummy", 0); //charAt(0) > - us.matchesAt((CharSequence)"amy", 0); //charAt(0) < - + + us.matchesAt("yummy", 0); //charAt(0) > + us.matchesAt("amy", 0); //charAt(0) < + UnicodeSet us1 = new UnicodeSet(0,100000); // Increase the set - us1.matchesAt((CharSequence)"dummy", 0); + us1.matchesAt("dummy", 0); } - + /* Tests the method * public int indexOf(int c) */ @@ -641,9 +644,9 @@ public final class StringTokenizerTest extends TestFmwk UnicodeSet us = new UnicodeSet(); int[] invalid = {UnicodeSet.MIN_VALUE-1, UnicodeSet.MIN_VALUE-2, UnicodeSet.MAX_VALUE+1, UnicodeSet.MAX_VALUE+2}; - int[] valid = {UnicodeSet.MIN_VALUE, UnicodeSet.MIN_VALUE+1, + int[] valid = {UnicodeSet.MIN_VALUE, UnicodeSet.MIN_VALUE+1, UnicodeSet.MAX_VALUE, UnicodeSet.MAX_VALUE-1}; - + for(int i=0; i < invalid.length; i++){ try{ us.indexOf(invalid[i]); @@ -651,7 +654,7 @@ public final class StringTokenizerTest extends TestFmwk "for a value of " + invalid[i]); } catch(Exception e){} } - + for(int i=0; i < valid.length; i++){ try{ us.indexOf(valid[i]); @@ -661,14 +664,14 @@ public final class StringTokenizerTest extends TestFmwk } } } - + /* Tests the method * public int charAt(int index) */ @Test public void TestCharAt(){ UnicodeSet us = new UnicodeSet(); - + // Test when "if (index >= 0)" is false int[] invalid = {-100,-10,-5,-2,-1}; for(int i=0; i < invalid.length; i++){ @@ -678,7 +681,7 @@ public final class StringTokenizerTest extends TestFmwk } } } - + /* Tests the method * private UnicodeSet add_unchecked(int start, int end) * from public UnicodeSet add(int start, int end) @@ -688,7 +691,7 @@ public final class StringTokenizerTest extends TestFmwk UnicodeSet us = new UnicodeSet(); int[] invalid = {UnicodeSet.MIN_VALUE-1, UnicodeSet.MIN_VALUE-2, UnicodeSet.MAX_VALUE+1, UnicodeSet.MAX_VALUE+2}; - + // Tests when "if (start < MIN_VALUE || start > MAX_VALUE)" is true for(int i=0; i < invalid.length; i++){ try{ @@ -698,7 +701,7 @@ public final class StringTokenizerTest extends TestFmwk + invalid[i]); } catch (Exception e){} } - + // Tests when "if (end < MIN_VALUE || end > MAX_VALUE)" is true for(int i=0; i < invalid.length; i++){ try{ @@ -708,19 +711,19 @@ public final class StringTokenizerTest extends TestFmwk + invalid[i]); } catch (Exception e){} } - + // Tests when "else if (start == end)" is false if(!(us.add(UnicodeSet.MIN_VALUE+1, UnicodeSet.MIN_VALUE).equals(us))) errln("UnicodeSet.add(int start, int end) was suppose to return " + "the same object because start of value " + (UnicodeSet.MIN_VALUE+1) + " is greater than end of value " + UnicodeSet.MIN_VALUE); - + if(!(us.add(UnicodeSet.MAX_VALUE, UnicodeSet.MAX_VALUE-1).equals(us))) errln("UnicodeSet.add(int start, int end) was suppose to return " + "the same object because start of value " + UnicodeSet.MAX_VALUE + " is greater than end of value " + (UnicodeSet.MAX_VALUE-1)); } - + /* Tests the method * private final UnicodeSet add_unchecked(int c) * from public final UnicodeSet add(int c) @@ -730,7 +733,7 @@ public final class StringTokenizerTest extends TestFmwk UnicodeSet us = new UnicodeSet(); int[] invalid = {UnicodeSet.MIN_VALUE-1, UnicodeSet.MIN_VALUE-2, UnicodeSet.MAX_VALUE+1, UnicodeSet.MAX_VALUE+2}; - + // Tests when "if (c < MIN_VALUE || c > MAX_VALUE)" is true for(int i=0; i < invalid.length; i++){ try{ @@ -740,11 +743,11 @@ public final class StringTokenizerTest extends TestFmwk + invalid[i]); } catch (Exception e){} } - + // Tests when "if (c == MAX_VALUE)" is true // TODO: Check comment in UnicodeSet.java } - + /* Tests the method * private static int getSingleCP(String s) * from public final boolean contains(String s) @@ -758,15 +761,15 @@ public final class StringTokenizerTest extends TestFmwk errln("UnicodeSet.getSingleCP is suppose to give an exception for " + "an empty string."); } catch (Exception e){} - + try{ us.contains((String)null); errln("UnicodeSet.getSingleCP is suppose to give an exception for " + "a null string."); } catch (Exception e){} - + // Tests when "if (cp > 0xFFFF)" is true - String[] cases = {"\uD811\uDC00","\uD811\uDC11","\uD811\uDC22"}; + String[] cases = {"\uD811\uDC00","\uD811\uDC11","\uD811\uDC22"}; for(int i=0; i MAX_VALUE)" is true for(int i=0; i < invalid.length; i++){ try{ @@ -810,7 +813,7 @@ public final class StringTokenizerTest extends TestFmwk + invalid[i]); } catch (Exception e){} } - + // Tests when "if (end < MIN_VALUE || end > MAX_VALUE)" is true for(int i=0; i < invalid.length; i++){ try{ @@ -820,7 +823,7 @@ public final class StringTokenizerTest extends TestFmwk + invalid[i]); } catch (Exception e){} } - + // Tests when "if (start <= end)" is false try{ us.retain(UnicodeSet.MIN_VALUE+1, UnicodeSet.MIN_VALUE); @@ -828,7 +831,7 @@ public final class StringTokenizerTest extends TestFmwk errln("UnicodeSet.retain(int start, int end) was not suppose to give " + "an exception."); } - + try{ us.retain(UnicodeSet.MAX_VALUE, UnicodeSet.MAX_VALUE-1); } catch(Exception e){ @@ -836,7 +839,7 @@ public final class StringTokenizerTest extends TestFmwk + "an exception."); } } - + /* Tests the method * public final UnicodeSet retain(String s) */ @@ -850,7 +853,7 @@ public final class StringTokenizerTest extends TestFmwk "same UnicodeSet since the string was found in the original."); } } - + /* Tests the method * public UnicodeSet remove(int start, int end) */ @@ -859,7 +862,7 @@ public final class StringTokenizerTest extends TestFmwk UnicodeSet us = new UnicodeSet(); int[] invalid = {UnicodeSet.MIN_VALUE-1, UnicodeSet.MIN_VALUE-2, UnicodeSet.MAX_VALUE+1, UnicodeSet.MAX_VALUE+2}; - + // Tests when "if (start < MIN_VALUE || start > MAX_VALUE)" is true for(int i=0; i < invalid.length; i++){ try{ @@ -869,7 +872,7 @@ public final class StringTokenizerTest extends TestFmwk + invalid[i]); } catch (Exception e){} } - + // Tests when "if (end < MIN_VALUE || end > MAX_VALUE)" is true for(int i=0; i < invalid.length; i++){ try{ @@ -879,7 +882,7 @@ public final class StringTokenizerTest extends TestFmwk + invalid[i]); } catch (Exception e){} } - + // Tests when "if (start <= end)" is false try{ us.remove(UnicodeSet.MIN_VALUE+1, UnicodeSet.MIN_VALUE); @@ -887,7 +890,7 @@ public final class StringTokenizerTest extends TestFmwk errln("UnicodeSet.remove(int start, int end) was not suppose to give " + "an exception."); } - + try{ us.remove(UnicodeSet.MAX_VALUE, UnicodeSet.MAX_VALUE-1); } catch(Exception e){ @@ -895,7 +898,7 @@ public final class StringTokenizerTest extends TestFmwk + "an exception."); } } - + /* Tests the method * public UnicodeSet complement(int start, int end) */ @@ -904,7 +907,7 @@ public final class StringTokenizerTest extends TestFmwk UnicodeSet us = new UnicodeSet(); int[] invalid = {UnicodeSet.MIN_VALUE-1, UnicodeSet.MIN_VALUE-2, UnicodeSet.MAX_VALUE+1, UnicodeSet.MAX_VALUE+2}; - + // Tests when "if (start < MIN_VALUE || start > MAX_VALUE)" is true for(int i=0; i < invalid.length; i++){ try{ @@ -914,7 +917,7 @@ public final class StringTokenizerTest extends TestFmwk + invalid[i]); } catch (Exception e){} } - + // Tests when "if (end < MIN_VALUE || end > MAX_VALUE)" is true for(int i=0; i < invalid.length; i++){ try{ @@ -924,7 +927,7 @@ public final class StringTokenizerTest extends TestFmwk + invalid[i]); } catch (Exception e){} } - + // Tests when "if (start <= end)" is false try{ us.complement(UnicodeSet.MIN_VALUE+1, UnicodeSet.MIN_VALUE); @@ -932,7 +935,7 @@ public final class StringTokenizerTest extends TestFmwk errln("UnicodeSet.complement(int start, int end) was not suppose to give " + "an exception."); } - + try{ us.complement(UnicodeSet.MAX_VALUE, UnicodeSet.MAX_VALUE-1); } catch(Exception e){ @@ -940,7 +943,7 @@ public final class StringTokenizerTest extends TestFmwk + "an exception."); } } - + /* Tests the method * public final UnicodeSet complement(String s) */ @@ -955,7 +958,7 @@ public final class StringTokenizerTest extends TestFmwk errln("UnicodeSet.complement(String s) was not suppose to give " + "an exception for 'dummy'."); } - + // Tests when "if (strings.contains(s))" is true us = new UnicodeSet(); us.add("\uDC11"); @@ -966,7 +969,7 @@ public final class StringTokenizerTest extends TestFmwk + "an exception for '\uDC11'."); } } - + /* Tests the method * public boolean contains(int c) */ @@ -975,7 +978,7 @@ public final class StringTokenizerTest extends TestFmwk UnicodeSet us = new UnicodeSet(); int[] invalid = {UnicodeSet.MIN_VALUE-1, UnicodeSet.MIN_VALUE-2, UnicodeSet.MAX_VALUE+1, UnicodeSet.MAX_VALUE+2}; - + // Tests when "if (c < MIN_VALUE || c > MAX_VALUE)" is true for(int i=0; i < invalid.length; i++){ try{ @@ -986,7 +989,7 @@ public final class StringTokenizerTest extends TestFmwk } catch (Exception e){} } } - + /* Tests the method * public boolean contains(int start, int end) */ @@ -995,7 +998,7 @@ public final class StringTokenizerTest extends TestFmwk UnicodeSet us = new UnicodeSet(); int[] invalid = {UnicodeSet.MIN_VALUE-1, UnicodeSet.MIN_VALUE-2, UnicodeSet.MAX_VALUE+1, UnicodeSet.MAX_VALUE+2}; - + // Tests when "if (start < MIN_VALUE || start > MAX_VALUE)" is true for(int i=0; i < invalid.length; i++){ try{ @@ -1005,7 +1008,7 @@ public final class StringTokenizerTest extends TestFmwk + invalid[i]); } catch (Exception e){} } - + // Tests when "if (end < MIN_VALUE || end > MAX_VALUE)" is true for(int i=0; i < invalid.length; i++){ try{ @@ -1016,7 +1019,7 @@ public final class StringTokenizerTest extends TestFmwk } catch (Exception e){} } } - + /* Tests the method * public String getRegexEquivalent() */ @@ -1028,7 +1031,7 @@ public final class StringTokenizerTest extends TestFmwk errln("UnicodeSet.getRegexEquivalent is suppose to return '[]' " + "but got " + res); } - + /* Tests the method * public boolean containsNone(int start, int end) */ @@ -1037,7 +1040,7 @@ public final class StringTokenizerTest extends TestFmwk UnicodeSet us = new UnicodeSet(); int[] invalid = {UnicodeSet.MIN_VALUE-1, UnicodeSet.MIN_VALUE-2, UnicodeSet.MAX_VALUE+1, UnicodeSet.MAX_VALUE+2}; - + // Tests when "if (start < MIN_VALUE || start > MAX_VALUE)" is true for(int i=0; i < invalid.length; i++){ try{ @@ -1047,7 +1050,7 @@ public final class StringTokenizerTest extends TestFmwk + invalid[i]); } catch (Exception e){} } - + // Tests when "if (end < MIN_VALUE || end > MAX_VALUE)" is true for(int i=0; i < invalid.length; i++){ try{ @@ -1057,7 +1060,7 @@ public final class StringTokenizerTest extends TestFmwk + invalid[i]); } catch (Exception e){} } - + // Tests when "if (start < list[++i])" is false try{ us.add(0); diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/TestLocaleValidity.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/TestLocaleValidity.java index 42c9f10d235..7a411b86484 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/TestLocaleValidity.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/TestLocaleValidity.java @@ -16,6 +16,8 @@ import java.util.Map.Entry; import java.util.Set; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.ValidIdentifiers; @@ -31,6 +33,7 @@ import com.ibm.icu.util.ULocale; * @author markdavis * */ +@RunWith(JUnit4.class) public class TestLocaleValidity extends TestFmwk { @Test public void testBasic() { diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/TextTrieMapTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/TextTrieMapTest.java index d95812a66bf..4266d9c37d6 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/TextTrieMapTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/TextTrieMapTest.java @@ -12,10 +12,13 @@ import java.util.Arrays; import java.util.Iterator; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.TextTrieMap; +@RunWith(JUnit4.class) public class TextTrieMapTest extends TestFmwk { private static final Integer SUN = new Integer(1); diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/Trie2Test.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/Trie2Test.java index 9d37181254b..843272aba72 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/Trie2Test.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/Trie2Test.java @@ -17,6 +17,8 @@ import java.nio.ByteBuffer; import java.util.Iterator; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.ICUBinary; @@ -25,6 +27,7 @@ import com.ibm.icu.impl.Trie2Writable; import com.ibm.icu.impl.Trie2_16; import com.ibm.icu.impl.Trie2_32; +@RunWith(JUnit4.class) public class Trie2Test extends TestFmwk { /** * Constructor @@ -32,9 +35,9 @@ public class Trie2Test extends TestFmwk { public Trie2Test() { } - + // public methods ----------------------------------------------- - + // // TestAPI. Check that all API methods can be called, and do at least some minimal // operation correctly. This is not a full test of correct behavior. @@ -42,11 +45,11 @@ public class Trie2Test extends TestFmwk { @Test public void TestTrie2API() { // Trie2.createFromSerialized() - // This function is well exercised by TestRanges(). - + // This function is well exercised by TestRanges(). + // Trie2.getVersion(InputStream is, boolean anyEndianOk) // - + try { Trie2Writable trie = new Trie2Writable(0,0); ByteArrayOutputStream os = new ByteArrayOutputStream(); @@ -54,9 +57,9 @@ public class Trie2Test extends TestFmwk { ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray()); assertEquals(null, 2, Trie2.getVersion(is, true)); } catch (IOException e) { - errln(where() + e.toString()); + errln(where() + e.toString()); } - + // Equals & hashCode // { @@ -77,28 +80,28 @@ public class Trie2Test extends TestFmwk { assertEquals("", trieA, trieB); assertEquals("", trieA.hashCode(), trieB.hashCode()); } - - // + + // // Iterator creation // { Trie2Writable trie = new Trie2Writable(17,0); Iterator it; it = trie.iterator(); - + Trie2.Range r = it.next(); assertEquals("", 0, r.startCodePoint); assertEquals("", 0x10ffff, r.endCodePoint); assertEquals("", 17, r.value); assertEquals("", false, r.leadSurrogate); - + r = it.next(); assertEquals("", 0xd800, r.startCodePoint); assertEquals("", 0xdbff, r.endCodePoint); assertEquals("", 17, r.value); assertEquals("", true, r.leadSurrogate); - - + + int i = 0; for (Trie2.Range rr: trie) { switch (i) { @@ -120,15 +123,16 @@ public class Trie2Test extends TestFmwk { i++; } } - + // Iteration with a value mapping function // { Trie2Writable trie = new Trie2Writable(0xbadfeed, 0); trie.set(0x10123, 42); - + Trie2.ValueMapper vm = new Trie2.ValueMapper() { - public int map(int v) { + @Override + public int map(int v) { if (v == 0xbadfeed) { v = 42; } @@ -142,8 +146,8 @@ public class Trie2Test extends TestFmwk { assertEquals("", 42, r.value); assertEquals("", false, r.leadSurrogate); } - - + + // Iteration over a leading surrogate range. // { @@ -155,7 +159,7 @@ public class Trie2Test extends TestFmwk { assertEquals("", 0x2f80f, r.endCodePoint); assertEquals("", 0xdefa17, r.value); assertEquals("", false, r.leadSurrogate); - + r = it.next(); assertEquals("", 0x2f810, r.startCodePoint); assertEquals("", 0x2f810, r.endCodePoint); @@ -167,22 +171,23 @@ public class Trie2Test extends TestFmwk { assertEquals("", 0x2fbff, r.endCodePoint); assertEquals("", 0xdefa17, r.value); assertEquals("", false, r.leadSurrogate); - + assertFalse("", it.hasNext()); } - + // Iteration over a leading surrogate range with a ValueMapper. // { Trie2Writable trie = new Trie2Writable(0xdefa17, 0); trie.set(0x2f810, 10); Trie2.ValueMapper m = new Trie2.ValueMapper() { - public int map(int in) { + @Override + public int map(int in) { if (in==10) { - in = 0xdefa17; + in = 0xdefa17; } return in; - } + } }; Iterator it = trie.iteratorForLeadSurrogate((char)0xd87e, m); Trie2.Range r = it.next(); @@ -193,7 +198,7 @@ public class Trie2Test extends TestFmwk { assertFalse("", it.hasNext()); } - + // Trie2.serialize() // Test the implementation in Trie2, which is used with Read Only Tries. // @@ -212,7 +217,7 @@ public class Trie2Test extends TestFmwk { Trie2 unserialized16 = Trie2.createFromSerialized(ByteBuffer.wrap(os.toByteArray())); assertEquals("", trie, unserialized16); assertEquals("", Trie2_16.class, unserialized16.getClass()); - + os.reset(); frozen32.serialize(os); Trie2 unserialized32 = Trie2.createFromSerialized(ByteBuffer.wrap(os.toByteArray())); @@ -221,26 +226,26 @@ public class Trie2Test extends TestFmwk { } catch (IOException e) { errln(where() + " Unexpected exception: " + e); } - - + + } } - - + + @Test public void TestTrie2WritableAPI() { // - // Trie2Writable methods. Check that all functions are present and + // Trie2Writable methods. Check that all functions are present and // nominally working. Not an in-depth test. // - + // Trie2Writable constructor Trie2 t1 = new Trie2Writable(6, 666); - + // Constructor from another Trie2 Trie2 t2 = new Trie2Writable(t1); assertTrue("", t1.equals(t2)); - + // Set / Get Trie2Writable t1w = new Trie2Writable(10, 666); t1w.set(0x4567, 99); @@ -248,8 +253,8 @@ public class Trie2Test extends TestFmwk { assertEquals("", 99, t1w.get(0x4567)); assertEquals("", 666, t1w.get(-1)); assertEquals("", 666, t1w.get(0x110000)); - - + + // SetRange t1w = new Trie2Writable(10, 666); t1w.setRange(13 /*start*/, 6666 /*end*/, 7788 /*value*/, false /*overwrite */); @@ -261,7 +266,7 @@ public class Trie2Test extends TestFmwk { assertEquals("", 9900, t1w.get(7000)); assertEquals("", 10, t1w.get(7001)); assertEquals("", 666, t1w.get(0x110000)); - + // setRange from a Trie2.Range // (Ranges are more commonly created by iterating over a Trie2, // but create one by hand here) @@ -276,8 +281,8 @@ public class Trie2Test extends TestFmwk { assertEquals("", 0x12345678, t1w.get(50)); assertEquals("", 0x12345678, t1w.get(52)); assertEquals("", 0, t1w.get(53)); - - + + // setForLeadSurrogateCodeUnit / getFromU16SingleLead t1w = new Trie2Writable(10, 0xbad); assertEquals("", 10, t1w.getFromU16SingleLead((char)0x0d801)); @@ -285,10 +290,10 @@ public class Trie2Test extends TestFmwk { t1w.set(0xd801, 6000); assertEquals("", 5000, t1w.getFromU16SingleLead((char)0x0d801)); assertEquals("", 6000, t1w.get(0x0d801)); - + // get(). Is covered by nearly every other test. - - + + // Trie2_16 getAsFrozen_16() t1w = new Trie2Writable(10, 666); t1w.set(42, 5555); @@ -300,7 +305,7 @@ public class Trie2Test extends TestFmwk { t1_16 = t1w.toTrie2_16(); assertTrue("", t1w.equals(t1_16)); assertEquals("", 129, t1w.get(152)); - + // Trie2_32 getAsFrozen_32() // t1w = new Trie2Writable(10, 666); @@ -314,10 +319,10 @@ public class Trie2Test extends TestFmwk { t1_32 = t1w.toTrie2_32(); assertTrue("", t1w.equals(t1_32)); assertEquals("", 129, t1w.get(152)); - - + + // serialize(OutputStream os, ValueWidth width) - // + // ByteArrayOutputStream os = new ByteArrayOutputStream(); t1w = new Trie2Writable(0, 0xbad); t1w.set(0x41, 0x100); @@ -336,7 +341,7 @@ public class Trie2Test extends TestFmwk { Trie2 t1ws16 = Trie2.createFromSerialized(ByteBuffer.wrap(os.toByteArray())); assertEquals("", t1ws16.getClass(), Trie2_16.class); assertEquals("", t1w, t1ws16); - + // Serialize to 32 bits os.reset(); serializedLen = t1w.toTrie2_32().serialize(os); @@ -349,15 +354,15 @@ public class Trie2Test extends TestFmwk { } catch (IOException e) { errln(where() + e.toString()); } - - + + } - + @Test public void TestCharSequenceIterator() { String text = "abc123\ud800\udc01 "; // Includes a Unicode supplemental character String vals = "LLLNNNX?S"; - + Trie2Writable tw = new Trie2Writable(0, 666); tw.setRange('a', 'z', 'L', false); tw.setRange('1', '9', 'N', false); @@ -365,7 +370,7 @@ public class Trie2Test extends TestFmwk { tw.set(0x10001, 'X'); Trie2.CharSequenceIterator it = tw.charSequenceIterator(text, 0); - + // Check forwards iteration. Trie2.CharSequenceValues ir; int i; @@ -380,22 +385,22 @@ public class Trie2Test extends TestFmwk { } } assertEquals("", text.length(), i); - + // Check reverse iteration, starting at an intermediate point. it.set(5); for (i=5; it.hasPrevious(); ) { ir = it.previous(); int expectedCP = Character.codePointBefore(text, i); - i -= (expectedCP < 0x10000? 1 : 2); + i -= (expectedCP < 0x10000? 1 : 2); assertEquals("" + " i="+i, expectedCP, ir.codePoint); assertEquals("" + " i="+i, i, ir.index); assertEquals("" + " i="+i, vals.charAt(i), ir.value); } assertEquals("", 0, i); - + } - - + + // // Port of Tests from ICU4C ... // @@ -407,16 +412,16 @@ public class Trie2Test extends TestFmwk { // // checkRanges array elemets are // { limit code point, value} - // + // // The expected value range is from the previous boundary's limit to before // this boundary's limit - // + // String[] trieNames = {"setRanges1", "setRanges2", "setRanges3", "setRangesEmpty", "setRangesSingleValue"}; /* set consecutive ranges, even with value 0 */ - - - + + + private static int[][] setRanges1 ={ { 0, 0, 0, 0 }, { 0, 0x40, 0, 0 }, @@ -579,14 +584,14 @@ public class Trie2Test extends TestFmwk { int i = 0; int initialValue = 0; int errorValue = 0x0bad; - + if (ranges[i][1] < 0) { errorValue = ranges[i][2]; i++; } initialValue = ranges[i++][2]; Trie2Writable trie = new Trie2Writable(initialValue, errorValue); - + for (; i map = comparisonTime == 0 ? new TreeMap(testMap) : new HashMap(testMap); long mapTime = t.timeIterations(new MyLoop() { + @Override public void time(int repeat) { for (int tt = 0; tt < repeat; ++tt) { for (Entry entry : map.entrySet()) { @@ -175,7 +179,7 @@ public class TrieMapTest extends TestFmwk { Integer value = entry.getValue(); } } - } + } }, null, map); if (comparisonTime == 0) { logln("\titeration time\tTREEMAP\tn/a\t" + t.toString(testMap.size()) + "\t\titerations=" + t.getIterations()); @@ -185,6 +189,7 @@ public class TrieMapTest extends TestFmwk { return mapTime; } else { long trieTime = t.timeIterations(new MyLoop() { + @Override public void time(int repeat) { for (int tt = 0; tt < repeat; ++tt) { for (Entry entry : trieMap) { @@ -192,7 +197,7 @@ public class TrieMapTest extends TestFmwk { Integer value = entry.getValue(); } } - } + } }, null, trieMap); logln("\titeration time\t" + style + "\tn/a\t" + t.toString(testMap.size(), comparisonTime) + "\titerations=" + t.getIterations()); if (!useSmallList && trieTime > ratioToMap * comparisonTime) { @@ -281,7 +286,7 @@ public class TrieMapTest extends TestFmwk { } while (hasMore); } while (matcher.nextStart()); assertEquals(style + "\tTrieMap matcher", expectedList, actualList); - // logln(bytes + "\tValue <" + value + "> at " + // logln(bytes + "\tValue <" + value + "> at " // + start + ".." + end + ", " // + string.substring(0, start) + "|" // + string.substring(start, end) + "|" @@ -307,32 +312,35 @@ public class TrieMapTest extends TestFmwk { if (style == null) { if (comparisonTime == 0) { long mapTime = t.timeIterations(new MyLoop() { + @Override public void time(int repeat) { for (int tt = 0; tt < repeat; ++tt) { Map map2 = new TreeMap(map); } - } + } }, null, testmap); logln("\tbuild time\tTREEMAP\tn/a\t" + t.toString(testmap.size()) + "\t\titerations=" + t.getIterations()); return mapTime; } else { long mapTime = t.timeIterations(new MyLoop() { + @Override public void time(int repeat) { for (int tt = 0; tt < repeat; ++tt) { Map map2 = new HashMap(map); } - } + } }, null, testmap); logln("\tbuild time\tHASHMAP\tn/a\t" + t.toString(testmap.size(), comparisonTime) + "\titerations=" + t.getIterations()); return mapTime; } } else { long trieTime = t.timeIterations(new MyLoop() { + @Override public void time(int repeat) { for (int tt = 0; tt < repeat; ++tt) { trieMap = TrieMap.BytesBuilder.with(style, option, map).build(); } - } + } }, null, testmap, style, option); logln("\tbuild time\t" + style + "\t" + option + "\t" + t.toString(testmap.size(), comparisonTime) + "\titerations=" + t.getIterations()); @@ -363,7 +371,7 @@ public class TrieMapTest extends TestFmwk { int mapKeyByteSize = 0; TreeMap map = new TreeMap(unicodeTestMap); for (Entry entry : map.entrySet()) { - mapKeyByteSize += 8 * (int) ((((entry.getKey().length()) * 2) + 45) / 8); + mapKeyByteSize += 8 * ((((entry.getKey().length()) * 2) + 45) / 8); } logln("\tkey byte size\tTREEMAP\tn/a\t" + nf.format(mapKeyByteSize)); return mapKeyByteSize; @@ -423,13 +431,14 @@ public class TrieMapTest extends TestFmwk { Map map = comparisonTime == 0 ? new TreeMap(testmap) : new HashMap(testmap); long mapTime = t.timeIterations(new MyLoop() { + @Override public void time(int repeat) { for (int tt = 0; tt < repeat; ++tt) { for (String key : keys) { Integer foundValue = map.get(key); } } - } + } }, keys, map); if (comparisonTime == 0) { logln("\tget() time\tTREEMAP\tn/a\t" + t.toString(keys.size()) + "\t\titerations=" + t.getIterations()); @@ -439,13 +448,14 @@ public class TrieMapTest extends TestFmwk { return mapTime; } else { long trieTime = t.timeIterations(new MyLoop() { + @Override public void time(int repeat) { for (int tt = 0; tt < repeat; ++tt) { for (String key : keys) { Integer foundValue = trieMap.get(key); } } - } + } }, keys, trieMap); // System.gc(); @@ -470,6 +480,7 @@ public class TrieMapTest extends TestFmwk { Map map; Style style; Option option; + @Override public void init(Object... params) { if (params.length > 0) { keys = (ArrayList) params[0]; @@ -488,6 +499,7 @@ public class TrieMapTest extends TestFmwk { option = (Option) params[3]; } } + @Override abstract public void time(int repeat); } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/TrieTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/TrieTest.java index 498160ca03e..5fefdb333f8 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/TrieTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/TrieTest.java @@ -10,6 +10,8 @@ package com.ibm.icu.dev.test.util; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.CharTrie; @@ -22,29 +24,30 @@ import com.ibm.icu.text.UTF16; import com.ibm.icu.util.RangeValueIterator; /** -* Testing class for Trie. Tests here will be simple, since both CharTrie and +* Testing class for Trie. Tests here will be simple, since both CharTrie and * IntTrie are very similar and are heavily used in other parts of ICU4J. * Codes using Tries are expected to have detailed tests. * @author Syn Wee Quek * @since release 2.1 Jan 01 2002 */ -public final class TrieTest extends TestFmwk -{ +@RunWith(JUnit4.class) +public final class TrieTest extends TestFmwk +{ // constructor --------------------------------------------------- - + /** * Constructor */ public TrieTest() { } - + // public methods ----------------------------------------------- - - /** + + /** * Values for setting possibly overlapping, out-of-order ranges of values */ - private static final class SetRange + private static final class SetRange { SetRange(int start, int limit, int value, boolean overwrite) { @@ -53,37 +56,38 @@ public final class TrieTest extends TestFmwk this.value = value; this.overwrite = overwrite; } - + int start, limit; int value; boolean overwrite; } - + /** * Values for testing: * value is set from the previous boundary's limit to before * this boundary's limit */ - private static final class CheckRange + private static final class CheckRange { CheckRange(int limit, int value) { this.limit = limit; this.value = value; } - + int limit; int value; } - - private static final class _testFoldedValue - implements TrieBuilder.DataManipulate + + private static final class _testFoldedValue + implements TrieBuilder.DataManipulate { public _testFoldedValue(IntTrieBuilder builder) { m_builder_ = builder; } - + + @Override public int getFoldedValue(int start, int offset) { int foldedValue = 0; @@ -92,46 +96,48 @@ public final class TrieTest extends TestFmwk int value = m_builder_.getValue(start); if (m_builder_.isInZeroBlock(start)) { start += TrieBuilder.DATA_BLOCK_LENGTH; - } + } else { foldedValue |= value; ++ start; } } - + if (foldedValue != 0) { return (offset << 16) | foldedValue; - } + } return 0; } - + private IntTrieBuilder m_builder_; } - - private static final class _testFoldingOffset - implements Trie.DataManipulate + + private static final class _testFoldingOffset + implements Trie.DataManipulate { + @Override public int getFoldingOffset(int value) { return value >>> 16; } } - + private static final class _testEnumValue extends TrieIterator { public _testEnumValue(Trie data) { super(data); } - + + @Override protected int extract(int value) { return value ^ 0x5555; } } - + private void _testTrieIteration(IntTrie trie, CheckRange checkRanges[], - int countCheckRanges) + int countCheckRanges) { // write a string int countValues = 0; @@ -154,20 +160,20 @@ public final class TrieTest extends TestFmwk p += UTF16.getCharCount(c); int value = trie.getCodePointValue(c); if (value != values[i]) { - errln("wrong value from UTRIE_NEXT(U+" - + Integer.toHexString(c) + "): 0x" + errln("wrong value from UTRIE_NEXT(U+" + + Integer.toHexString(c) + "): 0x" + Integer.toHexString(value) + " instead of 0x" + Integer.toHexString(values[i])); } // unlike the c version lead is 0 if c is non-supplementary char lead = UTF16.getLeadSurrogate(c); - char trail = UTF16.getTrailSurrogate(c); - if (lead == 0 - ? trail != s.charAt(p - 1) - : !UTF16.isLeadSurrogate(lead) - || !UTF16.isTrailSurrogate(trail) || lead != s.charAt(p - 2) + char trail = UTF16.getTrailSurrogate(c); + if (lead == 0 + ? trail != s.charAt(p - 1) + : !UTF16.isLeadSurrogate(lead) + || !UTF16.isTrailSurrogate(trail) || lead != s.charAt(p - 2) || trail != s.charAt(p - 1)) { - errln("wrong (lead, trail) from UTRIE_NEXT(U+" + errln("wrong (lead, trail) from UTRIE_NEXT(U+" + Integer.toHexString(c)); continue; } @@ -176,8 +182,8 @@ public final class TrieTest extends TestFmwk value = trie.getTrailValue(value, trail); if (value != trie.getSurrogateValue(lead, trail) && value != values[i]) { - errln("wrong value from getting supplementary " - + "values (U+" + errln("wrong value from getting supplementary " + + "values (U+" + Integer.toHexString(c) + "): 0x" + Integer.toHexString(value) + " instead of 0x" + Integer.toHexString(values[i])); @@ -186,16 +192,16 @@ public final class TrieTest extends TestFmwk ++ i; } } - - private void _testTrieRanges(SetRange setRanges[], int countSetRanges, + + private void _testTrieRanges(SetRange setRanges[], int countSetRanges, CheckRange checkRanges[], int countCheckRanges, - boolean latin1Linear) + boolean latin1Linear) { IntTrieBuilder newTrie = new IntTrieBuilder(null, 2000, - checkRanges[0].value, + checkRanges[0].value, checkRanges[0].value, latin1Linear); - + // set values from setRanges[] boolean ok = true; for (int i = 0; i < countSetRanges; ++ i) { @@ -205,7 +211,7 @@ public final class TrieTest extends TestFmwk boolean overwrite = setRanges[i].overwrite; if ((limit - start) == 1 && overwrite) { ok &= newTrie.setValue(start, value); - } + } else { ok &= newTrie.setRange(start, limit, value, overwrite); } @@ -214,70 +220,70 @@ public final class TrieTest extends TestFmwk errln("setting values into a trie failed"); return; } - + // verify that all these values are in the new Trie int start = 0; for (int i = 0; i < countCheckRanges; ++ i) { int limit = checkRanges[i].limit; int value = checkRanges[i].value; - + while (start < limit) { if (value != newTrie.getValue(start)) { - errln("newTrie [U+" - + Integer.toHexString(start) + "]==0x" - + Integer.toHexString(newTrie.getValue(start)) + errln("newTrie [U+" + + Integer.toHexString(start) + "]==0x" + + Integer.toHexString(newTrie.getValue(start)) + " instead of 0x" + Integer.toHexString(value)); } ++ start; } } - - IntTrie trie = newTrie.serialize(new _testFoldedValue(newTrie), + + IntTrie trie = newTrie.serialize(new _testFoldedValue(newTrie), new _testFoldingOffset()); - + // test linear Latin-1 range from utrie_getData() if (latin1Linear) { start = 0; for (int i = 0; i < countCheckRanges && start <= 0xff; ++ i) { int limit = checkRanges[i].limit; int value = checkRanges[i].value; - + while (start < limit && start <= 0xff) { if (value != trie.getLatin1LinearValue((char)start)) { - errln("IntTrie.getLatin1LinearValue[U+" + errln("IntTrie.getLatin1LinearValue[U+" + Integer.toHexString(start) + "]==0x" + Integer.toHexString( - trie.getLatin1LinearValue((char) start)) + trie.getLatin1LinearValue((char) start)) + " instead of 0x" + Integer.toHexString(value)); } ++ start; } } } - + if (latin1Linear != trie.isLatin1Linear()) { errln("trie serialization did not preserve " + "Latin-1-linearity"); } - + // verify that all these values are in the serialized Trie start = 0; for (int i = 0; i < countCheckRanges; ++ i) { int limit = checkRanges[i].limit; int value = checkRanges[i].value; - + if (start == 0xd800) { // skip surrogates start = limit; continue; } - + while (start < limit) { if (start <= 0xffff) { int value2 = trie.getBMPValue((char)start); if (value != value2) { errln("serialized trie.getBMPValue(U+" - + Integer.toHexString(start) + " == 0x" + + Integer.toHexString(start) + " == 0x" + Integer.toHexString(value2) + " instead of 0x" + Integer.toHexString(value)); } @@ -285,7 +291,7 @@ public final class TrieTest extends TestFmwk value2 = trie.getLeadValue((char)start); if (value != value2) { errln("serialized trie.getLeadValue(U+" - + Integer.toHexString(start) + " == 0x" + + Integer.toHexString(start) + " == 0x" + Integer.toHexString(value2) + " instead of 0x" + Integer.toHexString(value)); } @@ -294,79 +300,79 @@ public final class TrieTest extends TestFmwk int value2 = trie.getCodePointValue(start); if (value != value2) { errln("serialized trie.getCodePointValue(U+" - + Integer.toHexString(start) + ")==0x" - + Integer.toHexString(value2) + " instead of 0x" + + Integer.toHexString(start) + ")==0x" + + Integer.toHexString(value2) + " instead of 0x" + Integer.toHexString(value)); } ++ start; } } - + // enumerate and verify all ranges - + int enumRanges = 1; TrieIterator iter = new _testEnumValue(trie); RangeValueIterator.Element result = new RangeValueIterator.Element(); while (iter.next(result)) { - if (result.start != checkRanges[enumRanges -1].limit + if (result.start != checkRanges[enumRanges -1].limit || result.limit != checkRanges[enumRanges].limit || (result.value ^ 0x5555) != checkRanges[enumRanges].value) { errln("utrie_enum() delivers wrong range [U+" - + Integer.toHexString(result.start) + "..U+" - + Integer.toHexString(result.limit) + "].0x" - + Integer.toHexString(result.value ^ 0x5555) + + Integer.toHexString(result.start) + "..U+" + + Integer.toHexString(result.limit) + "].0x" + + Integer.toHexString(result.value ^ 0x5555) + " instead of [U+" - + Integer.toHexString(checkRanges[enumRanges -1].limit) - + "..U+" - + Integer.toHexString(checkRanges[enumRanges].limit) - + "].0x" + + Integer.toHexString(checkRanges[enumRanges -1].limit) + + "..U+" + + Integer.toHexString(checkRanges[enumRanges].limit) + + "].0x" + Integer.toHexString(checkRanges[enumRanges].value)); } enumRanges ++; } - + // test linear Latin-1 range if (trie.isLatin1Linear()) { for (start = 0; start < 0x100; ++ start) { - if (trie.getLatin1LinearValue((char)start) + if (trie.getLatin1LinearValue((char)start) != trie.getLeadValue((char)start)) { errln("trie.getLatin1LinearValue[U+" + Integer.toHexString(start) + "]=0x" + Integer.toHexString( trie.getLatin1LinearValue((char)start)) - + " instead of 0x" + + " instead of 0x" + Integer.toHexString( trie.getLeadValue((char)start))); } } } - + _testTrieIteration(trie, checkRanges, countCheckRanges); } - - private void _testTrieRanges2(SetRange setRanges[], - int countSetRanges, - CheckRange checkRanges[], - int countCheckRanges) + + private void _testTrieRanges2(SetRange setRanges[], + int countSetRanges, + CheckRange checkRanges[], + int countCheckRanges) { _testTrieRanges(setRanges, countSetRanges, checkRanges, countCheckRanges, false); - + _testTrieRanges(setRanges, countSetRanges, checkRanges, countCheckRanges, true); } - + private void _testTrieRanges4(SetRange setRanges[], int countSetRanges, - CheckRange checkRanges[], - int countCheckRanges) + CheckRange checkRanges[], + int countCheckRanges) { - _testTrieRanges2(setRanges, countSetRanges, checkRanges, + _testTrieRanges2(setRanges, countSetRanges, checkRanges, countCheckRanges); } - + // test data ------------------------------------------------------------ - - /** + + /** * set consecutive ranges, even with value 0 */ private static SetRange setRanges1[]={ @@ -376,7 +382,7 @@ public final class TrieTest extends TestFmwk new SetRange(0x3400, 0x9fa6, 0x6162, false), new SetRange(0x9fa6, 0xda9e, 0x3132, false), // try to disrupt _testFoldingOffset16() - new SetRange(0xdada, 0xeeee, 0x87ff, false), + new SetRange(0xdada, 0xeeee, 0x87ff, false), new SetRange(0xeeee, 0x11111, 1, false), new SetRange(0x11111, 0x44444, 0x6162, false), new SetRange(0x44444, 0x60003, 0, false), @@ -386,7 +392,7 @@ public final class TrieTest extends TestFmwk new SetRange(0xf0007, 0xf0020, 0x12, false), new SetRange(0xf0020, 0x110000, 0, false) }; - + private static CheckRange checkRanges1[]={ new CheckRange(0, 0), // dummy start range to make _testEnumRange() simpler new CheckRange(0x20, 0), @@ -405,8 +411,8 @@ public final class TrieTest extends TestFmwk new CheckRange(0xf0020,0x12), new CheckRange(0x110000, 0) }; - - /** + + /** * set some interesting overlapping ranges */ private static SetRange setRanges2[]={ @@ -419,10 +425,10 @@ public final class TrieTest extends TestFmwk new SetRange(0x2f900,0x2ffee, 1, false), new SetRange(0x2ffee,0x2ffef, 2, true) }; - + private static CheckRange checkRanges2[]={ // dummy start range to make _testEnumRange() simpler - new CheckRange(0, 0), + new CheckRange(0, 0), new CheckRange(0x21, 0), new CheckRange(0x72, 0x5555), new CheckRange(0xdd, 3), @@ -435,8 +441,8 @@ public final class TrieTest extends TestFmwk new CheckRange(0x2ffef,2), new CheckRange(0x110000, 0) }; - - /** + + /** * use a non-zero initial value */ private static SetRange setRanges3[]={ @@ -445,10 +451,10 @@ public final class TrieTest extends TestFmwk new SetRange(0x30000,0x34567,9, true), new SetRange(0x45678,0x56789,3, true) }; - + private static CheckRange checkRanges3[]={ // dummy start range, also carries the initial value - new CheckRange(0, 9), + new CheckRange(0, 9), new CheckRange(0x31, 9), new CheckRange(0xa4, 1), new CheckRange(0x3400, 9), @@ -457,19 +463,20 @@ public final class TrieTest extends TestFmwk new CheckRange(0x56789,3), new CheckRange(0x110000,9) }; - + @Test - public void TestIntTrie() + public void TestIntTrie() { - _testTrieRanges4(setRanges1, setRanges1.length, checkRanges1, + _testTrieRanges4(setRanges1, setRanges1.length, checkRanges1, checkRanges1.length); - _testTrieRanges4(setRanges2, setRanges2.length, checkRanges2, - checkRanges2.length); - _testTrieRanges4(setRanges3, setRanges3.length, checkRanges3, + _testTrieRanges4(setRanges2, setRanges2.length, checkRanges2, + checkRanges2.length); + _testTrieRanges4(setRanges3, setRanges3.length, checkRanges3, checkRanges3.length); } private static class DummyGetFoldingOffset implements Trie.DataManipulate { + @Override public int getFoldingOffset(int value) { return -1; /* never get non-initialValue data for supplementary code points */ } @@ -478,7 +485,7 @@ public final class TrieTest extends TestFmwk @Test public void TestDummyCharTrie() { CharTrie trie; - final int initialValue=0x313, leadUnitValue=0xaffe; + final int initialValue=0x313, leadUnitValue=0xaffe; int value; int c; trie=new CharTrie(initialValue, leadUnitValue, new DummyGetFoldingOffset()); @@ -503,7 +510,7 @@ public final class TrieTest extends TestFmwk @Test public void TestDummyIntTrie() { IntTrie trie; - final int initialValue=0x01234567, leadUnitValue=0x89abcdef; + final int initialValue=0x01234567, leadUnitValue=0x89abcdef; int value; int c; trie=new IntTrie(initialValue, leadUnitValue, new DummyGetFoldingOffset()); diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ULocaleTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ULocaleTest.java index d5d35a47d9f..1cb66698fa8 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ULocaleTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ULocaleTest.java @@ -25,6 +25,8 @@ import java.util.TreeMap; import java.util.TreeSet; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.dev.test.TestUtil; @@ -48,6 +50,7 @@ import com.ibm.icu.util.ULocale.Minimize; import com.ibm.icu.util.UResourceBundle; import com.ibm.icu.util.VersionInfo; +@RunWith(JUnit4.class) public class ULocaleTest extends TestFmwk { // Ticket #8078 and #11674 diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/UtilityTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/UtilityTest.java index d2f3771e26d..708c61103be 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/UtilityTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/UtilityTest.java @@ -18,6 +18,8 @@ import java.util.List; import java.util.Set; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.Assert; @@ -31,13 +33,14 @@ import com.ibm.icu.util.CaseInsensitiveString; * @test * @summary Test of internal Utility class */ +@RunWith(JUnit4.class) public class UtilityTest extends TestFmwk { @Test public void TestUnescape() { final String input = "Sch\\u00f6nes Auto: \\u20ac 11240.\\fPrivates Zeichen: \\U00102345\\e\\cC\\n \\x1b\\x{263a}"; - final String expect = + final String expect = "Sch\u00F6nes Auto: \u20AC 11240.\u000CPrivates Zeichen: \uDBC8\uDF45\u001B\u0003\012 \u001B\u263A"; String result = Utility.unescape(input); @@ -45,7 +48,7 @@ public class UtilityTest extends TestFmwk { errln("FAIL: Utility.unescape() returned " + result + ", exp. " + expect); } } - + @Test public void TestFormat() { @@ -70,7 +73,7 @@ public class UtilityTest extends TestFmwk { "\"testing weird supplementary characters \\uD800\\uDC00\"", "\"testing control characters \\001 and line breaking!! \\n are we done yet?\"" }; - + for (int i = 0; i < data.length; i ++) { assertEquals("formatForSource(\"" + data[i] + "\")", result[i], Utility.formatForSource(data[i])); @@ -80,7 +83,7 @@ public class UtilityTest extends TestFmwk { result1[i], Utility.format1ForSource(data[i])); } } - + @Test public void TestHighBit() { @@ -88,23 +91,23 @@ public class UtilityTest extends TestFmwk { byte result[] = {-1, -1, -1, 15, 12}; for (int i = 0; i < data.length; i ++) { if (Utility.highBit(data[i]) != result[i]) { - errln("Fail: Highest bit of \\u" + errln("Fail: Highest bit of \\u" + Integer.toHexString(data[i]) + " should be " + result[i]); } } } - + @Test public void TestCompareUnsigned() { - int data[] = {0, 1, 0x8fffffff, -1, Integer.MAX_VALUE, + int data[] = {0, 1, 0x8fffffff, -1, Integer.MAX_VALUE, Integer.MIN_VALUE, 2342423, -2342423}; for (int i = 0; i < data.length; i ++) { for (int j = 0; j < data.length; j ++) { - if (Utility.compareUnsigned(data[i], data[j]) + if (Utility.compareUnsigned(data[i], data[j]) != compareLongUnsigned(data[i], data[j])) { - errln("Fail: Unsigned comparison failed with " + data[i] + errln("Fail: Unsigned comparison failed with " + data[i] + " " + data[i + 1]); } } @@ -123,15 +126,15 @@ public class UtilityTest extends TestFmwk { java.nio.ByteBuffer buffer = java.nio.ByteBuffer.wrap(ba); ByteArrayWrapper x = new ByteArrayWrapper(buffer); - + ByteArrayWrapper y = new ByteArrayWrapper(ba, 3); ByteArrayWrapper z = new ByteArrayWrapper(bb, 3); - + if (!y.toString().equals("00 01 02")){ errln("FAIL: test toString : Failed!"); } - + // test equality if (!x.equals(y) || !x.equals(z)) errln("FAIL: test (operator ==): Failed!"); @@ -222,7 +225,7 @@ public class UtilityTest extends TestFmwk { logln("Assert.fail works"); } } - + @Test public void TestCaseInsensitiveString() { CaseInsensitiveString str1 = new CaseInsensitiveString("ThIs is A tEst"); @@ -234,7 +237,7 @@ public class UtilityTest extends TestFmwk { errln("FAIL: str1("+str1+") != str2("+str2+")"); } } - + @Test public void TestSourceLocation() { String here = TestFmwk.sourceLocation(); @@ -242,7 +245,7 @@ public class UtilityTest extends TestFmwk { String hereAgain = TestFmwk.sourceLocation(); assertTrue("here < there < hereAgain", here.compareTo(there) < 0 && there.compareTo(hereAgain) < 0); } - + public String CheckSourceLocale() { return TestFmwk.sourceLocation(); } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/VersionInfoTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/VersionInfoTest.java index 40b5199f9bc..40410154338 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/VersionInfoTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/VersionInfoTest.java @@ -14,6 +14,8 @@ package com.ibm.icu.dev.test.util; import java.util.Arrays; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.util.VersionInfo; @@ -24,6 +26,7 @@ import com.ibm.icu.util.VersionInfo; * @author Syn Wee Quek * @since release 2.1 March 01 2002 */ +@RunWith(JUnit4.class) public final class VersionInfoTest extends TestFmwk { // constructor --------------------------------------------------- diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/XLocaleDistanceTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/XLocaleDistanceTest.java index 3f3b24b589e..9b44eba4313 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/XLocaleDistanceTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/XLocaleDistanceTest.java @@ -10,6 +10,8 @@ import java.util.Map.Entry; import java.util.Set; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.locale.XLikelySubtags.LSR; @@ -26,6 +28,7 @@ import com.ibm.icu.util.ULocale; * * @author markdavis */ +@RunWith(JUnit4.class) public class XLocaleDistanceTest extends TestFmwk { private static final boolean REFORMAT = false; // set to true to get a reformatted data file listed diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/XLocaleMatcherTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/XLocaleMatcherTest.java index 0ba886598c2..9fc94b1abb8 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/XLocaleMatcherTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/XLocaleMatcherTest.java @@ -11,6 +11,8 @@ import java.util.TreeSet; import java.util.regex.Pattern; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.locale.XCldrStub.Joiner; @@ -29,6 +31,7 @@ import com.ibm.icu.util.ULocale; * * @author markdavis */ +@RunWith(JUnit4.class) public class XLocaleMatcherTest extends TestFmwk { private static final boolean REFORMAT = false; // set to true to get a reformatted data file listed diff --git a/icu4j/main/tests/core/src/com/ibm/icu/text/DigitListTest.java b/icu4j/main/tests/core/src/com/ibm/icu/text/DigitListTest.java index cc385f8889b..d84a6a11e4d 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/text/DigitListTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/text/DigitListTest.java @@ -5,10 +5,13 @@ package com.ibm.icu.text; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; +@RunWith(JUnit4.class) public class DigitListTest extends TestFmwk { private static DigitList digitList = new DigitList(); diff --git a/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/BreakIteratorTest.java b/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/BreakIteratorTest.java index 85c92a5dbf3..f2c04cbd2e4 100644 --- a/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/BreakIteratorTest.java +++ b/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/BreakIteratorTest.java @@ -12,9 +12,12 @@ import java.text.BreakIterator; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; +@RunWith(JUnit4.class) public class BreakIteratorTest extends TestFmwk { private static final int CHARACTER_BRK = 0; private static final int WORD_BRK = 1; @@ -72,7 +75,7 @@ public class BreakIteratorTest extends TestFmwk { } else { if (isIcuImpl) { logln("INFO: " + method + " returned ICU BreakIterator for locale " + loc); - } + } BreakIterator brkitrIcu = null; Locale iculoc = TestUtil.toICUExtendedLocale(loc); switch (type) { @@ -171,7 +174,7 @@ public class BreakIteratorTest extends TestFmwk { jdkBrkItrs[1] = BreakIterator.getWordInstance(iculoc); jdkBrkItrs[2] = BreakIterator.getLineInstance(iculoc); jdkBrkItrs[3] = BreakIterator.getSentenceInstance(iculoc); - + icuBrkItrs[0] = com.ibm.icu.text.BreakIterator.getCharacterInstance(iculoc); icuBrkItrs[1] = com.ibm.icu.text.BreakIterator.getWordInstance(iculoc); icuBrkItrs[2] = com.ibm.icu.text.BreakIterator.getLineInstance(iculoc); diff --git a/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/CollatorTest.java b/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/CollatorTest.java index fef8b30bb98..01dd9812524 100644 --- a/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/CollatorTest.java +++ b/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/CollatorTest.java @@ -13,11 +13,14 @@ import java.text.Collator; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.jdkadapter.CollatorICU; import com.ibm.icu.util.ULocale; +@RunWith(JUnit4.class) public class CollatorTest extends TestFmwk { /* * Check if getInstance returns the ICU implementation. diff --git a/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/CurrencyNameTest.java b/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/CurrencyNameTest.java index 8b113c701d0..d7f0bd26f19 100644 --- a/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/CurrencyNameTest.java +++ b/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/CurrencyNameTest.java @@ -16,10 +16,13 @@ import java.util.Locale; import java.util.Set; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; @SuppressWarnings("unchecked") +@RunWith(JUnit4.class) public class CurrencyNameTest extends TestFmwk { private static final Set AVAILABLE_CURRENCIES; private static final Method GETDISPLAYNAME_METHOD; diff --git a/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/DateFormatSymbolsTest.java b/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/DateFormatSymbolsTest.java index d4b1fed8402..c403fd104bd 100644 --- a/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/DateFormatSymbolsTest.java +++ b/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/DateFormatSymbolsTest.java @@ -12,10 +12,13 @@ import java.text.DateFormatSymbols; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.util.ULocale; +@RunWith(JUnit4.class) public class DateFormatSymbolsTest extends TestFmwk { /* * Check if getInstance returns the ICU implementation. diff --git a/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/DateFormatTest.java b/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/DateFormatTest.java index f55be470e68..02a668115d5 100644 --- a/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/DateFormatTest.java +++ b/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/DateFormatTest.java @@ -15,11 +15,14 @@ import java.util.Date; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.jdkadapter.CalendarICU; import com.ibm.icu.util.ULocale; +@RunWith(JUnit4.class) public class DateFormatTest extends TestFmwk { /* * Check if getInstance returns the ICU implementation. diff --git a/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/DecimalFormatSymbolsTest.java b/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/DecimalFormatSymbolsTest.java index fcd3e94f670..526eb1c7e84 100644 --- a/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/DecimalFormatSymbolsTest.java +++ b/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/DecimalFormatSymbolsTest.java @@ -13,10 +13,13 @@ import java.util.Currency; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.util.ULocale; +@RunWith(JUnit4.class) public class DecimalFormatSymbolsTest extends TestFmwk { /* * Check if getInstance returns the ICU implementation. diff --git a/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/LocaleNameTest.java b/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/LocaleNameTest.java index d24ab0dfec3..651f436fd90 100644 --- a/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/LocaleNameTest.java +++ b/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/LocaleNameTest.java @@ -14,10 +14,13 @@ import java.util.Locale; import java.util.Set; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.util.ULocale; +@RunWith(JUnit4.class) public class LocaleNameTest extends TestFmwk { private static final Method GETDISPLAYSCRIPT_METHOD; @@ -78,7 +81,7 @@ public class LocaleNameTest extends TestFmwk { } } else { if (!name.equals(icuname)) { - logln("INFO: Language name by JDK is " + name + ", but " + icuname + + logln("INFO: Language name by JDK is " + name + ", but " + icuname + " by ICU, for locale " + forLocale + " in locale " + inLocale); } // Try explicit ICU locale (xx_yy_ICU) @@ -135,7 +138,7 @@ public class LocaleNameTest extends TestFmwk { } else { // The name might be taken from JDK if (!name.equals(icuname)) { - logln("INFO: Script name by JDK is " + name + ", but " + icuname + + logln("INFO: Script name by JDK is " + name + ", but " + icuname + " in ICU, for locale " + forLocale + " in locale " + inLocale); } // Try explicit ICU locale (xx_yy_ICU) @@ -186,7 +189,7 @@ public class LocaleNameTest extends TestFmwk { } else { // The name might be taken from JDK if (!name.equals(icuname)) { - logln("INFO: Country name by JDK is " + name + ", but " + icuname + + logln("INFO: Country name by JDK is " + name + ", but " + icuname + " in ICU, for locale " + forLocale + " in locale " + inLocale); } // Try explicit ICU locale (xx_yy_ICU) @@ -259,7 +262,7 @@ public class LocaleNameTest extends TestFmwk { } } else { if (!name.equals(icuname)) { - logln("INFO: Variant name by JDK is " + name + ", but " + icuname + + logln("INFO: Variant name by JDK is " + name + ", but " + icuname + " in ICU, for locale " + forLocaleSingleVar + " in locale " + inLocale); } // Try explicit ICU locale (xx_yy_ICU) diff --git a/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/NumberFormatTest.java b/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/NumberFormatTest.java index 7c99767053b..6d4e2e1cc11 100644 --- a/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/NumberFormatTest.java +++ b/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/NumberFormatTest.java @@ -15,10 +15,13 @@ import java.text.ParseException; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.util.ULocale; +@RunWith(JUnit4.class) public class NumberFormatTest extends TestFmwk { private static final int DEFAULT_TYPE = 0; private static final int NUMBER_TYPE = 1; diff --git a/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/TimeZoneNameTest.java b/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/TimeZoneNameTest.java index 4c9ec3c435d..0db2c26f3ed 100644 --- a/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/TimeZoneNameTest.java +++ b/icu4j/main/tests/localespi/src/com/ibm/icu/dev/test/localespi/TimeZoneNameTest.java @@ -15,12 +15,15 @@ import java.util.Set; import java.util.TimeZone; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.TimeZoneNames; import com.ibm.icu.text.TimeZoneNames.NameType; import com.ibm.icu.util.ULocale; +@RunWith(JUnit4.class) public class TimeZoneNameTest extends TestFmwk { private static final Set ProblematicZones = new HashSet(); @@ -52,7 +55,7 @@ public class TimeZoneNameTest extends TestFmwk { for (String tzid : tzids) { // Java has a problem when a provider does not supply all 4 names // for a zone. For this reason, ICU TimeZoneName provider does not return - // localized names unless these 4 names are available. + // localized names unless these 4 names are available. String icuStdLong = getIcuDisplayName(tzid, false, TimeZone.LONG, loc); String icuDstLong = getIcuDisplayName(tzid, true, TimeZone.LONG, loc); @@ -72,13 +75,13 @@ public class TimeZoneNameTest extends TestFmwk { private void checkDisplayNamePair(int style, String tzid, Locale loc, boolean warnOnly) { /* Note: There are two problems here. - * + * * It looks Java 6 requires a TimeZoneNameProvider to return both standard name and daylight name * for a zone. If the provider implementation only returns either of them, Java 6 also ignore * the other. In ICU, there are zones which do not have daylight names, especially zones which * do not use daylight time. This test case does not check a standard name if its daylight name * is not available because of the Java 6 implementation problem. - * + * * Another problem is that ICU always use a standard name for a zone which does not use daylight * saving time even daylight name is requested. */ @@ -126,7 +129,7 @@ public class TimeZoneNameTest extends TestFmwk { logln("WARNING: TimeZone name by ICU is " + icuname + ", but got " + name + " for time zone " + tz.getID() + " in locale " + loc + " (daylight=" + daylight + ", style=" + styleStr + ")"); - + } else { errln("FAIL: TimeZone name by ICU is " + icuname + ", but got " + name + " for time zone " + tz.getID() + " in locale " + loc diff --git a/icu4j/main/tests/packaging/src/com/ibm/icu/dev/test/TestLocaleNamePackaging.java b/icu4j/main/tests/packaging/src/com/ibm/icu/dev/test/TestLocaleNamePackaging.java index 38f2be4d52b..e062b7243e0 100644 --- a/icu4j/main/tests/packaging/src/com/ibm/icu/dev/test/TestLocaleNamePackaging.java +++ b/icu4j/main/tests/packaging/src/com/ibm/icu/dev/test/TestLocaleNamePackaging.java @@ -14,12 +14,15 @@ import static com.ibm.icu.impl.LocaleDisplayNamesImpl.DataTableType.REGION; import java.util.Locale; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.impl.LocaleDisplayNamesImpl; import com.ibm.icu.text.LocaleDisplayNames; import com.ibm.icu.text.LocaleDisplayNames.DialectHandling; import com.ibm.icu.util.ULocale; +@RunWith(JUnit4.class) public class TestLocaleNamePackaging extends TestFmwk { public TestLocaleNamePackaging() { } @@ -77,7 +80,7 @@ public class TestLocaleNamePackaging extends TestFmwk { "DE", "TH", }; - String[] expected = LocaleDisplayNamesImpl.haveData(REGION) ? + String[] expected = LocaleDisplayNamesImpl.haveData(REGION) ? expectedWithRegionData : expectedWithoutRegionData; int n = 0; @@ -224,15 +227,15 @@ public class TestLocaleNamePackaging extends TestFmwk { : "en (GB)"); assertEquals("dialect 2", target, dn.localeDisplayName("en_GB")); } - + @Test public void testLocaleKeywords() { LocaleDisplayNames dn = LocaleDisplayNames.getInstance(ULocale.US, DialectHandling.DIALECT_NAMES); String name = dn.localeDisplayName("de@collation=phonebook"); - String target = LocaleDisplayNamesImpl.haveData(LANG) ? + String target = LocaleDisplayNamesImpl.haveData(LANG) ? "German (Phonebook Sort Order)" : "de (collation=phonebook)"; assertEquals("collation", target, name); - + } } diff --git a/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/AnyScriptTest.java b/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/AnyScriptTest.java index 601d77386c5..37b538430ff 100644 --- a/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/AnyScriptTest.java +++ b/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/AnyScriptTest.java @@ -9,6 +9,8 @@ package com.ibm.icu.dev.test.translit; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.lang.UScript; @@ -22,7 +24,8 @@ import com.ibm.icu.util.ULocale; * @author markdavis * */ -public class AnyScriptTest extends TestFmwk { +@RunWith(JUnit4.class) +public class AnyScriptTest extends TestFmwk { @Test public void TestContext() { Transliterator t = Transliterator.createFromRules("foo", "::[bc]; a{b}d > B;", Transliterator.FORWARD); @@ -33,7 +36,7 @@ public class AnyScriptTest extends TestFmwk { @Test public void TestScripts(){ // get a couple of characters of each script for testing - + StringBuffer testBuffer = new StringBuffer(); for (int script = 0; script < UScript.CODE_LIMIT; ++script) { UnicodeSet test = new UnicodeSet().applyPropertyAlias("script", UScript.getName(script)); @@ -44,10 +47,10 @@ public class AnyScriptTest extends TestFmwk { } String test = testBuffer.toString(); logln("Test line: " + test); - + int inclusion = TestFmwk.getExhaustiveness(); boolean testedUnavailableScript = false; - + for (int script = 0; script < UScript.CODE_LIMIT; ++script) { if (script == UScript.COMMON || script == UScript.INHERITED) { continue; @@ -55,7 +58,7 @@ public class AnyScriptTest extends TestFmwk { // if the inclusion rate is not 10, skip all but a small number of items. // Make sure, however, that we test at least one unavailable script if (inclusion < 10 && script != UScript.LATIN - && script != UScript.HAN + && script != UScript.HAN && script != UScript.HIRAGANA && testedUnavailableScript ) { @@ -103,25 +106,25 @@ public class AnyScriptTest extends TestFmwk { UnicodeSet ASCII = new UnicodeSet("[:ascii:]"); String lettersAndSpace = "abc def"; final String punctOnly = "( )"; - + String wideLettersAndSpace = widen.transform(lettersAndSpace); String widePunctOnly = widen.transform(punctOnly); assertContainsNone("Should be wide", ASCII, wideLettersAndSpace); assertContainsNone("Should be wide", ASCII, widePunctOnly); - + String back; back = narrow.transform(wideLettersAndSpace); assertEquals("Should be narrow", lettersAndSpace, back); back = narrow.transform(widePunctOnly); assertEquals("Should be narrow", punctOnly, back); - + Transliterator latin = Transliterator.getInstance("any-Latn"); back = latin.transform(wideLettersAndSpace); assertEquals("Should be ascii", lettersAndSpace, back); - + back = latin.transform(widePunctOnly); assertEquals("Should be ascii", punctOnly, back); - + // Han-Latin is now forward-only per CLDR ticket #5630 //Transliterator t2 = Transliterator.getInstance("any-Han"); //back = t2.transform(widePunctOnly); @@ -129,7 +132,7 @@ public class AnyScriptTest extends TestFmwk { } - + @Test public void TestCommonDigits() { UnicodeSet westernDigitSet = new UnicodeSet("[0-9]"); diff --git a/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/CompoundTransliteratorTest.java b/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/CompoundTransliteratorTest.java index cbbe2367d8d..3450f21ac3f 100644 --- a/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/CompoundTransliteratorTest.java +++ b/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/CompoundTransliteratorTest.java @@ -7,7 +7,10 @@ ******************************************************************************* */ package com.ibm.icu.dev.test.translit; + import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.Utility; @@ -20,6 +23,7 @@ import com.ibm.icu.text.Transliterator; * @test * @summary General test of CompoundTransliterator */ +@RunWith(JUnit4.class) public class CompoundTransliteratorTest extends TestFmwk { @Test public void TestConstruction(){ @@ -35,15 +39,15 @@ public class CompoundTransliteratorTest extends TestFmwk { errln("FAIL: Transliterator construction failed" + ex.getMessage()); throw ex; } - + final String IDs[]={ - names[0], - names[0]+";"+names[3], - names[3]+";"+names[1]+";"+names[2], - names[0]+";"+names[1]+";"+names[2]+";"+names[3] + names[0], + names[0]+";"+names[3], + names[3]+";"+names[1]+";"+names[2], + names[0]+";"+names[1]+";"+names[2]+";"+names[3] }; - + for(int i=0; i<4; i++){ try{ Transliterator.getInstance(IDs[i]); @@ -74,8 +78,8 @@ public class CompoundTransliteratorTest extends TestFmwk { // "UnicodeFilter adoptedFilter=0) failed for " + IDs[i]); // throw ex4; // } -// -// +// +// // try{ // CompoundTransliterator cpdtrans2=new CompoundTransliterator(transarray[i], null); // cpdtrans2 = null; @@ -85,11 +89,11 @@ public class CompoundTransliteratorTest extends TestFmwk { // throw ex5; // } - + } - + } - + @Test public void TestGetTransliterator(){ logln("Testing the getTransliterator() API of CompoundTransliterator"); @@ -119,10 +123,10 @@ public class CompoundTransliteratorTest extends TestFmwk { } } - + } - - + + @Test public void TestTransliterate(){ logln("Testing the handleTransliterate() API of CompoundTransliterator"); @@ -133,7 +137,7 @@ public class CompoundTransliteratorTest extends TestFmwk { errln("FAIL: construction using CompoundTransliterator(String ID) failed for " + "Any-Hex;Hex-Any"); throw iae; } - + String s="abcabc"; expect(ct1, s, s); Transliterator.Position index = new Transliterator.Position(); @@ -143,31 +147,31 @@ public class CompoundTransliteratorTest extends TestFmwk { ct1.finishTransliteration(rsource2, index); String result=rsource2.toString(); expectAux(ct1.getID() + ":ReplaceableString, index(0,0,0,0)", s + "->" + rsource2, result.equals(expectedResult), expectedResult); - + Transliterator.Position index2 = new Transliterator.Position(1,3,2,3); ReplaceableString rsource3=new ReplaceableString(s); - ct1.transliterate(rsource3, index2); + ct1.transliterate(rsource3, index2); ct1.finishTransliteration(rsource3, index2); result=rsource3.toString(); expectAux(ct1.getID() + ":String, index2(1,2,2,3)", s + "->" + rsource3, result.equals(expectedResult), expectedResult); - + String Data[]={ //ID, input string, transliterated string - "Any-Hex;Hex-Any;Any-Hex", "hello", "\\u0068\\u0065\\u006C\\u006C\\u006F", + "Any-Hex;Hex-Any;Any-Hex", "hello", "\\u0068\\u0065\\u006C\\u006C\\u006F", "Any-Hex;Hex-Any", "hello! How are you?", "hello! How are you?", "Devanagari-Latin;Latin-Devanagari", "\u092D\u0948'\u0930'\u0935", "\u092D\u0948\u0930\u0935", // quotes lost "Latin-Cyrillic;Cyrillic-Latin", "a'b'k'd'e'f'g'h'i'j'Shch'shch'zh'h", "a'b'k'd'e'f'g'h'i'j'Shch'shch'zh'h", "Latin-Greek;Greek-Latin", "ABGabgAKLMN", "ABGabgAKLMN", //"Latin-Arabic;Arabic-Latin", "Ad'r'a'b'i'k'dh'dd'gh", "Adrabikdhddgh", - "Hiragana-Katakana", "\u3041\u308f\u3099\u306e\u304b\u3092\u3099", - "\u30A1\u30f7\u30ce\u30ab\u30fa", - "Hiragana-Katakana;Katakana-Hiragana", "\u3041\u308f\u3099\u306e\u304b\u3051", + "Hiragana-Katakana", "\u3041\u308f\u3099\u306e\u304b\u3092\u3099", + "\u30A1\u30f7\u30ce\u30ab\u30fa", + "Hiragana-Katakana;Katakana-Hiragana", "\u3041\u308f\u3099\u306e\u304b\u3051", "\u3041\u308f\u3099\u306e\u304b\u3051", - "Katakana-Hiragana;Hiragana-Katakana", "\u30A1\u30f7\u30ce\u30f5\u30f6", - "\u30A1\u30f7\u30ce\u30ab\u30b1", - "Latin-Katakana;Katakana-Latin", "vavivuvevohuzizuzoninunasesuzezu", - "vavivuvevohuzizuzoninunasesuzezu", + "Katakana-Hiragana;Hiragana-Katakana", "\u30A1\u30f7\u30ce\u30f5\u30f6", + "\u30A1\u30f7\u30ce\u30ab\u30b1", + "Latin-Katakana;Katakana-Latin", "vavivuvevohuzizuzoninunasesuzezu", + "vavivuvevohuzizuzoninunasesuzezu", }; Transliterator ct2=null; for(int i=0; i " + hangul2 + "; but " + hangul + " =cpd=> " + jamoToName(hangulX) ); - errln(Utility.escape(buf.toString())); + errln(Utility.escape(buf.toString())); } else if (jamo.equals(jamo2)) { buf.setLength(0); buf.append("FAIL (Jamo<>Hangul problem): "); @@ -215,7 +218,7 @@ public class JamoTest extends TestFmwk { latin + " => " + jamoToName(jamo2) + " => " + hangul2 ); - errln(Utility.escape(buf.toString())); + errln(Utility.escape(buf.toString())); } else { buf.setLength(0); buf.append("FAIL: "); @@ -253,7 +256,7 @@ public class JamoTest extends TestFmwk { "\uc0c1\uad00\uc5c6\uc774 \uc720\ub2c8\ucf54\ub4dc\ub294 \ubaa8\ub4e0 " + "\ubb38\uc790\uc5d0 \ub300\ud574 \uace0\uc720 \ubc88\ud638\ub97c " + "\uc81c\uacf5\ud569\ub2c8\ub2e4. " + - + "\uae30\ubcf8\uc801\uc73c\ub85c \ucef4\ud4e8\ud130\ub294 " + "\uc22b\uc790\ub9cc \ucc98\ub9ac\ud569\ub2c8\ub2e4. \uae00\uc790\ub098 " + "\ub2e4\ub978 \ubb38\uc790\uc5d0\ub3c4 \uc22b\uc790\ub97c " + @@ -277,7 +280,7 @@ public class JamoTest extends TestFmwk { "\ud14c\ud06c\ub2c8\uceec \uae30\ud638\uc5d0 \ub9de\ub294 \ub2e8\uc77c " + "\uae30\ud638\ud654 \ubc29\ubc95\uc744 \uac16\uace0 \uc788\uc9c0 " + "\ubabb\ud558\uc600\uc2b5\ub2c8\ub2e4. " + - + "\uc774\ub7ec\ud55c \uae30\ud638\ud654 \uc2dc\uc2a4\ud15c\uc740 " + "\ub610\ud55c \ub2e4\ub978 \uae30\ud638\ud654 \uc2dc\uc2a4\ud15c\uacfc " + "\ucda9\ub3cc\ud569\ub2c8\ub2e4. \uc989 \ub450 \uac00\uc9c0 " + @@ -294,7 +297,7 @@ public class JamoTest extends TestFmwk { "\ud50c\ub7ab\ud3fc \uac04\uc5d0 \uc804\ub2ec\ud560 \ub54c\ub9c8\ub2e4 " + "\uadf8 \ub370\uc774\ud130\ub294 \ud56d\uc0c1 \uc190\uc0c1\uc758 " + "\uc704\ud5d8\uc744 \uacaa\uac8c \ub429\ub2c8\ub2e4. " + - + "\uc720\ub2c8\ucf54\ub4dc\ub85c \ubaa8\ub4e0 \uac83\uc744 " + "\ud574\uacb0\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4! " + "\uc720\ub2c8\ucf54\ub4dc\ub294 \uc0ac\uc6a9 \uc911\uc778 " + @@ -303,7 +306,7 @@ public class JamoTest extends TestFmwk { "\uc22b\uc790\ub97c " + "\uc81c\uacf5\ud569\ub2c8\ub2e4. \uc720\ub2c8\ucf54\ub4dc " + "\ud45c\uc900\uc740 " + // "Apple, HP, IBM, JustSystem, Microsoft, Oracle, SAP, " + - // "Sun, Sybase, Unisys " + + // "Sun, Sybase, Unisys " + "\ubc0f \uae30\ud0c0 \uc5ec\ub7ec " + "\ud68c\uc0ac\uc640 \uac19\uc740 \uc5c5\uacc4 " + "\uc120\ub450\uc8fc\uc790\uc5d0 \uc758\ud574 " + @@ -323,7 +326,7 @@ public class JamoTest extends TestFmwk { "\ucd5c\uadfc \uc804 \uc138\uacc4\uc5d0 \ubd88\uace0 \uc788\ub294 " + "\uae30\uc220 \uacbd\ud5a5\uc5d0\uc11c \uac00\uc7a5 \uc911\uc694\ud55c " + "\ubd80\ubd84\uc744 \ucc28\uc9c0\ud558\uace0 \uc788\uc2b5\ub2c8\ub2e4. " + - + "\uc720\ub2c8\ucf54\ub4dc\ub97c " + // Replaced a hyphen with a space to make the test case work with CLDR1.5 // "\ud074\ub77c\uc774\uc5b8\ud2b8-\uc11c\ubc84 \ub610\ub294 " + @@ -345,7 +348,7 @@ public class JamoTest extends TestFmwk { "\ub370\uc774\ud130\ub97c \uc190\uc0c1 \uc5c6\uc774 \uc5ec\ub7ec " + "\uc2dc\uc2a4\ud15c\uc744 \ud1b5\ud574 \uc804\uc1a1\ud560 \uc218 " + "\uc788\uc2b5\ub2c8\ub2e4. " + - + "\uc720\ub2c8\ucf54\ub4dc \ucf58\uc18c\uc2dc\uc5c4\uc5d0 \ub300\ud574 " + "\uc720\ub2c8\ucf54\ub4dc \ucf58\uc18c\uc2dc\uc5c4\uc740 " + "\ube44\uc601\ub9ac \uc870\uc9c1\uc73c\ub85c\uc11c \ud604\ub300 " + @@ -369,7 +372,7 @@ public class JamoTest extends TestFmwk { "\uc9c0\uc6d0\ud558\uace0\uc790\ud558\ub294 \uc870\uc9c1\uacfc " + "\uac1c\uc778\uc5d0\uac8c \uac1c\ubc29\ub418\uc5b4 " + "\uc788\uc2b5\ub2c8\ub2e4. " + - + "\ub354 \uc790\uc138\ud55c \ub0b4\uc6a9\uc740 \uc6a9\uc5b4\uc9d1, " + "\uc608\uc81c \uc720\ub2c8\ucf54\ub4dc \uc0ac\uc6a9 \uac00\ub2a5 " + "\uc81c\ud488, \uae30\uc220 \uc815\ubcf4 \ubc0f \uae30\ud0c0 " + @@ -406,7 +409,7 @@ public class JamoTest extends TestFmwk { "(Ti)", "\u1110", "(Pi)", "\u1111", "(Hi)", "\u1112", - + "(A)", "\u1161", "(AE)", "\u1162", "(YA)", "\u1163", diff --git a/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/RegexUtilitiesTest.java b/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/RegexUtilitiesTest.java index 3646358359c..5ce5d411e44 100644 --- a/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/RegexUtilitiesTest.java +++ b/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/RegexUtilitiesTest.java @@ -14,6 +14,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.UnicodeRegex; @@ -27,6 +29,7 @@ import com.ibm.icu.text.UnicodeSet; /** * @author markdavis */ +@RunWith(JUnit4.class) public class RegexUtilitiesTest extends TestFmwk { /** * Check basic construction. @@ -49,7 +52,7 @@ public class RegexUtilitiesTest extends TestFmwk { String expected = tests[i].length == 1 ? source : tests[i][1]; String actual = UnicodeRegex.fix(source); assertEquals(source, expected, actual); - } + } } Transliterator hex = Transliterator.getInstance("hex"); diff --git a/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/ReplaceableTest.java b/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/ReplaceableTest.java index 482fcef5a00..901bf369ae7 100644 --- a/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/ReplaceableTest.java +++ b/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/ReplaceableTest.java @@ -8,6 +8,10 @@ */ package com.ibm.icu.dev.test.translit; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.Utility; import com.ibm.icu.text.Replaceable; @@ -18,8 +22,9 @@ import com.ibm.icu.text.Transliterator; * @test * @summary Round trip test of Transliterator */ +@RunWith(JUnit4.class) public class ReplaceableTest extends TestFmwk { - @org.junit.Test + @Test public void Test() { check("Lower", "ABCD", "1234"); check("Upper", "abcd\u00DF", "123455"); // must map 00DF to SS @@ -35,11 +40,11 @@ public class ReplaceableTest extends TestFmwk { check("*x > a", "\uFFFFxy", "_33"); // expect "_23"? check("*(x) > A $1 B", "\uFFFFxy", "__223"); } - + void check(String transliteratorName, String test, String shouldProduceStyles) { TestReplaceable tr = new TestReplaceable(test, null); String original = tr.toString(); - + Transliterator t; if (transliteratorName.startsWith("*")) { transliteratorName = transliteratorName.substring(1); @@ -56,13 +61,13 @@ public class ReplaceableTest extends TestFmwk { } else { logln("OK: " + transliteratorName + " ( " + original + " ) => " + tr.toString()); } - - if (!tr.hasMetaData() || tr.chars.hasMetaData() + + if (!tr.hasMetaData() || tr.chars.hasMetaData() || tr.styles.hasMetaData()) { errln("Fail hasMetaData()"); } } - + /** * This is a test class that simulates styled text. @@ -77,11 +82,11 @@ public class ReplaceableTest extends TestFmwk { static class TestReplaceable implements Replaceable { ReplaceableString chars; ReplaceableString styles; - + static final char NO_STYLE = '_'; static final char NO_STYLE_MARK = 0xFFFF; - + TestReplaceable (String text, String styles) { chars = new ReplaceableString(text); StringBuffer s = new StringBuffer(); @@ -98,11 +103,12 @@ public class ReplaceableTest extends TestFmwk { } this.styles = new ReplaceableString(s.toString()); } - + public String getStyles() { return styles.toString(); } - + + @Override public String toString() { return chars.toString() + "{" + styles.toString() + "}"; } @@ -111,22 +117,27 @@ public class ReplaceableTest extends TestFmwk { return chars.substring(start, limit); } + @Override public int length() { return chars.length(); } + @Override public char charAt(int offset) { return chars.charAt(offset); } + @Override public int char32At(int offset) { return chars.char32At(offset); } + @Override public void getChars(int srcStart, int srcLimit, char dst[], int dstStart) { chars.getChars(srcStart, srcLimit, dst, dstStart); } + @Override public void replace(int start, int limit, String text) { if (substring(start,limit).equals(text)) return; // NO ACTION! if (DEBUG) System.out.print(Utility.escape(toString() + " -> replace(" + start + @@ -135,7 +146,8 @@ public class ReplaceableTest extends TestFmwk { fixStyles(start, limit, text.length()); if (DEBUG) System.out.println(Utility.escape(toString())); } - + + @Override public void replace(int start, int limit, char[] charArray, int charsStart, int charsLen) { if (substring(start,limit).equals(new String(charArray, charsStart, charsLen-charsStart))) return; // NO ACTION! @@ -167,18 +179,20 @@ public class ReplaceableTest extends TestFmwk { styles.replace(start, limit, s.toString()); } + @Override public void copy(int start, int limit, int dest) { chars.copy(start, limit, dest); styles.copy(start, limit, dest); } - + + @Override public boolean hasMetaData() { return true; } static final boolean DEBUG = false; } - + @org.junit.Test public void Test5789() { String rules = diff --git a/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/RoundTripTest.java b/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/RoundTripTest.java index c3f5734d5d0..a6305abd1b2 100644 --- a/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/RoundTripTest.java +++ b/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/RoundTripTest.java @@ -20,6 +20,8 @@ import java.io.UnsupportedEncodingException; import java.util.MissingResourceException; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.impl.Utility; @@ -37,6 +39,7 @@ import com.ibm.icu.util.ULocale; * @test * @summary Round trip test of Transliterator */ +@RunWith(JUnit4.class) public class RoundTripTest extends TestFmwk { //TODO - revisit test cases referencing FIX_ME @@ -88,6 +91,7 @@ public class RoundTripTest extends TestFmwk { abbreviated = false; } + @Override public void reset(UnicodeSet newSet) { reset(newSet, false); } @@ -105,6 +109,7 @@ public class RoundTripTest extends TestFmwk { } } + @Override protected void loadRange(int myRange) { super.loadRange(myRange); if (abbreviated && (endElement > nextElement + perRange)) { @@ -167,7 +172,7 @@ public class RoundTripTest extends TestFmwk { public void TestHangul() throws IOException { long start = System.currentTimeMillis(); TransliterationTest t = new TransliterationTest("Latin-Hangul", 5); - boolean TEST_ALL = getBooleanProperty("HangulRoundTripAll", false); + boolean TEST_ALL = getBooleanProperty("HangulRoundTripAll", false); if (TEST_ALL && TestFmwk.getExhaustiveness() == 10) { t.setPairLimit(Integer.MAX_VALUE); // only go to the limit if we have TEST_ALL and getInclusion } @@ -344,7 +349,7 @@ public class RoundTripTest extends TestFmwk { logln("TestGreek needs to be updated to remove delete the section marked [:Age=4.0:] filter"); } - return + return "[\u003B\u00B7[[:Greek:]&[:Letter:]]-[" + "\u1D26-\u1D2A" + // L& [5] GREEK LETTER SMALL CAPITAL GAMMA..GREEK LETTER SMALL CAPITAL PSI "\u1D5D-\u1D61" + // Lm [5] MODIFIER LETTER SMALL BETA..MODIFIER LETTER SMALL CHI @@ -422,15 +427,15 @@ public class RoundTripTest extends TestFmwk { if (FIX_ME) { new TransliterationTest("Latin-Thai") .test("[a-zA-Z\u0142\u1ECD\u00E6\u0131\u0268\u02CC]", - "[\u0E01-\u0E3A\u0E40-\u0E5B]", + "[\u0E01-\u0E3A\u0E40-\u0E5B]", "[a-zA-Z\u0142\u1ECD\u00E6\u0131\u0268\u02B9\u02CC]", null, this, new LegalThai()); } else { new TransliterationTest("Latin-Thai") .test("[a-zA-Z\u0142\u1ECD\u00E6\u0131\u0268\u02CC]", - "[\u0E01-\u0E3A\u0E40-\u0E5B]", + "[\u0E01-\u0E3A\u0E40-\u0E5B]", "[a-zA-Z\u0142\u1ECD\u00E6\u0131\u0268\u02B9\u02CC]", - "[\u0E4F]", this, new LegalThai()); + "[\u0E4F]", this, new LegalThai()); } showElapsed(start, "TestThai"); @@ -459,6 +464,7 @@ public class RoundTripTest extends TestFmwk { String virama = "\u094d\u09cd\u0a4d\u0acd\u0b4d\u0bcd\u0c4d\u0ccd\u0d4d"; String sanskritStressSigns = "\u0951\u0952\u0953\u0954\u097d"; String chandrabindu = "\u0901\u0981\u0A81\u0b01\u0c01"; + @Override public boolean is(String sourceString){ int cp=sourceString.charAt(0); @@ -922,6 +928,7 @@ public class RoundTripTest extends TestFmwk { // any medial must follow an initial (or medial) // any final must follow a medial (or final) + @Override public boolean is(String sourceString) { try { int t; @@ -959,6 +966,7 @@ public class RoundTripTest extends TestFmwk { //static BreakIterator thaiBreak = BreakIterator.getWordInstance(new Locale("th", "TH")); // anything is legal except word ending with Logical-order-exception public static class LegalThai extends Legal { + @Override public boolean is(String sourceString) { if (sourceString.length() == 0) return true; char ch = sourceString.charAt(sourceString.length() - 1); // don't worry about surrogates. @@ -985,6 +993,7 @@ public class RoundTripTest extends TestFmwk { static UnicodeSet FINAL = new UnicodeSet("[\u05DA\u05DD\u05DF\u05E3\u05E5]"); static UnicodeSet NON_FINAL = new UnicodeSet("[\u05DB\u05DE\u05E0\u05E4\u05E6]"); static UnicodeSet LETTER = new UnicodeSet("[:letter:]"); + @Override public boolean is(String sourceString) { if (sourceString.length() == 0) return true; // don't worry about surrogates. @@ -1022,6 +1031,7 @@ public class RoundTripTest extends TestFmwk { return "\u03C1\u03A1".indexOf(c) >= 0; } + @Override public boolean is(String sourceString) { try { String decomp = Normalizer.normalize(sourceString, Normalizer.NFD); @@ -1179,7 +1189,7 @@ public class RoundTripTest extends TestFmwk { } /** - * Will test + * Will test * that everything in sourceRange maps to targetRange, * that everything in targetRange maps to backtoSourceRange * that everything roundtrips from target -> source -> target, except roundtripExceptions @@ -1625,7 +1635,7 @@ public class RoundTripTest extends TestFmwk { StringBuffer result = new StringBuffer(); result.append("\u200E").append(s).append("\u200E (").append(TestUtility.hex(s)).append("/"); if (false) { // append age, as a check - int cp = 0; + int cp = 0; for (int i = 0; i < s.length(); i += UTF16.getCharCount(cp)) { cp = UTF16.charAt(s, i); if (i > 0) result.append(", "); @@ -1636,7 +1646,7 @@ public class RoundTripTest extends TestFmwk { return result.toString(); } - final void logWrongScript(String label, String from, String to, + final void logWrongScript(String label, String from, String to, UnicodeSet shouldContainAll, UnicodeSet shouldNotContainAny) { if (++errorCount > errorLimit) { throw new TestTruncated("Test truncated; too many failures"); diff --git a/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/ThreadTest.java b/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/ThreadTest.java index 1e0b263268d..5441c20e57b 100644 --- a/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/ThreadTest.java +++ b/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/ThreadTest.java @@ -11,6 +11,8 @@ package com.ibm.icu.dev.test.translit; import java.util.ArrayList; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.text.Transliterator; @@ -18,17 +20,18 @@ import com.ibm.icu.text.Transliterator; // Test for ICU Ticket #7201. With threading bugs in RuleBasedTransliterator, this // test would reliably crash. +@RunWith(JUnit4.class) public class ThreadTest extends TestFmwk { private ArrayList threads = new ArrayList(); private int iterationCount = 50000; - + @Test public void TestThreads() { if (TestFmwk.getExhaustiveness() >= 9) { // Exhaustive test. Run longer. iterationCount = 1000000; } - + for (int i = 0; i < 8; i++) { Worker thread = new Worker(); threads.add(thread); @@ -50,32 +53,34 @@ public class ThreadTest extends TestFmwk { } } } - + private static final String [] WORDS = {"edgar", "allen", "poe"}; - - private class Worker extends Thread { + + private class Worker extends Thread { public long count = 0; + @Override public void run() { - Transliterator tx = Transliterator.getInstance("Latin-Thai"); + Transliterator tx = Transliterator.getInstance("Latin-Thai"); for (int loop = 0; loop < iterationCount; loop++) { for (String s : WORDS) { count += tx.transliterate(s).length(); - } + } } } } - + // Test for ticket #10673, race in cache code in AnyTransliterator. // It's difficult to make the original unsafe code actually fail, but - // this test will fairly reliably take the code path for races in + // this test will fairly reliably take the code path for races in // populating the cache. - // + // @Test public void TestAnyTranslit() { final Transliterator tx = Transliterator.getInstance("Any-Latin"); ArrayList threads = new ArrayList(); for (int i=0; i<8; i++) { threads.add(new Thread() { + @Override public void run() { tx.transliterate("διαφορετικούς"); } diff --git a/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/TransliteratorTest.java b/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/TransliteratorTest.java index dd48b7ff6fa..090f280f52c 100644 --- a/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/TransliteratorTest.java +++ b/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/TransliteratorTest.java @@ -18,6 +18,8 @@ import java.util.Locale; import java.util.Map.Entry; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.dev.test.TestUtil; @@ -89,6 +91,7 @@ The Management * @test * @summary General test of Transliterator */ +@RunWith(JUnit4.class) public class TransliteratorTest extends TestFmwk { @Test public void TestHangul() { diff --git a/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/UnicodeMapTest.java b/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/UnicodeMapTest.java index 0f824f74e98..e277a600faa 100644 --- a/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/UnicodeMapTest.java +++ b/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/translit/UnicodeMapTest.java @@ -22,6 +22,8 @@ import java.util.TreeMap; import java.util.TreeSet; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestBoilerplate; import com.ibm.icu.dev.test.TestFmwk; @@ -39,6 +41,7 @@ import com.ibm.icu.text.UnicodeSet; * @test * @summary General test of UnicodeSet */ +@RunWith(JUnit4.class) public class UnicodeMapTest extends TestFmwk { static final int MODIFY_TEST_LIMIT = 32; @@ -66,7 +69,7 @@ public class UnicodeMapTest extends TestFmwk { assertEquals("EntryRange", expected, CollectionUtilities.join(foo.entryRanges(), "\n") + (foo.size() == 0 ? "" : "\n")); assertEquals("EntryRange", expected, foo.toString()); } - + @Test public void TestRemove() { UnicodeMap foo = new UnicodeMap() @@ -81,14 +84,14 @@ public class UnicodeMapTest extends TestFmwk { .put("abc", 3d) .put("mark", 999d) .freeze(); - + UnicodeMap afterFiiRemoval = new UnicodeMap() .put(0x20, -2d) .putAll(0x26, 0x29, -2d) .put("xy", 2d) .put("mark", 4d) .freeze(); - + UnicodeMap afterFiiRetained = new UnicodeMap() .putAll(0x21, 0x25, -2d) .put("abc", 3d) @@ -97,7 +100,7 @@ public class UnicodeMapTest extends TestFmwk { UnicodeMap test = new UnicodeMap().putAll(foo) .removeAll(fii); assertEquals("removeAll", afterFiiRemoval, test); - + test = new UnicodeMap().putAll(foo) .retainAll(fii); assertEquals("retainAll", afterFiiRetained, test); @@ -160,9 +163,9 @@ public class UnicodeMapTest extends TestFmwk { } /** - * @param rand + * @param rand * @param nextInt - * @param test + * @param test * @return */ private SortedMap fillRandomMap(Random rand, int max, SortedMap test) { @@ -218,6 +221,7 @@ public class UnicodeMapTest extends TestFmwk { } static Comparator OneFirstComparator = new Comparator() { + @Override public int compare(String o1, String o2) { int cp1 = UnicodeSet.getSingleCodePoint(o1); int cp2 = UnicodeSet.getSingleCodePoint(o2); @@ -234,14 +238,14 @@ public class UnicodeMapTest extends TestFmwk { }; /** - * @param rand + * @param rand * @param others * @return */ private String getRandomKey(Random rand) { int r = rand.nextInt(30); if (r == 0) { - return UTF16.valueOf(r); + return UTF16.valueOf(r); } else if (r < 10) { return UTF16.valueOf('A'-1+r); } else if (r < 20) { @@ -296,7 +300,7 @@ public class UnicodeMapTest extends TestFmwk { } return true; } - + @Test public void TestCloneAsThawed11721 () { UnicodeMap test = new UnicodeMap().put("abc", 3).freeze(); @@ -456,6 +460,7 @@ public class UnicodeMapTest extends TestFmwk { } static Comparator> ENTRY_COMPARATOR = new Comparator>() { + @Override public int compare(Map.Entry o1, Map.Entry o2) { if (o1 == o2) return 0; if (o1 == null) return -1; diff --git a/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/util/TestUtilities.java b/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/util/TestUtilities.java index 50ff6bab368..08fb32dad94 100644 --- a/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/util/TestUtilities.java +++ b/icu4j/main/tests/translit/src/com/ibm/icu/dev/test/util/TestUtilities.java @@ -14,10 +14,13 @@ import java.util.Set; import java.util.TreeSet; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import com.ibm.icu.dev.test.TestFmwk; import com.ibm.icu.dev.util.CollectionUtilities; +@RunWith(JUnit4.class) public class TestUtilities extends TestFmwk { @Test public void TestCollectionUtilitySpeed() { -- 2.40.0