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;
import com.ibm.icu.text.UTF16;
import com.ibm.icu.text.UnicodeSet;
+@RunWith(JUnit4.class)
public class TestCharset extends TestFmwk {
@Test
public void TestUTF16Converter(){
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;
}
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));
}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;
}
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());
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);
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++) {
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);
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();
+ (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)) {
+ (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++) {
fail = true;
break outer;
}
-
+
// expecting overflow
try {
bs = ByteBuffer.wrap(bytes, 'a', n).slice();
errln("Incorrect result in " + converter + " for underflow / overflow edge cases");
return;
}
-
+
// test surrogate combinations in encoding
String lead = "\ud888";
String trail = "\udc88";
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);
}
}
}
-
+
@Test
public void TestUTF8Converter() {
String converter = "UTF-8";
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;
} 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();
+ 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();
+ Integer.toHexString(i) + " received " + cr);
break;
}
-
-
+
+
}
}
if (true)
return;
}
-
+
@Test
public void TestHZ() {
/* test input */
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);
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<finishArray.length; i++)
finishArray[i] = finish.get(i);
-
+
logln("start: " + hex(in));
logln("finish: " + hex(finishArray));
}
errln(converter + " roundtrip test failed: " + ex.getMessage());
ex.printStackTrace(System.err);
}
-
+
/* For better code coverage */
CoderResult result = CoderResult.UNDERFLOW;
byte byteout[] = {
bb.position(bbPositions[i]);
cb.position(ccPositions[i]);
result = encoder.encode(cb, bb, true);
-
+
if (i < 3) {
if (!result.isOverflow()) {
errln("Overflow buffer error should have occurred while encoding HZ (" + i + ")");
{ '\u0062', },
{ '\u0062', },
};
-
+
String converter = "UTF-8";
CharsetProvider icu = new CharsetProviderICU();
Charset icuChar = icu.charsetForName(converter);
CharsetDecoder decoder = icuChar.newDecoder();
-
+
int i;
try {
for (i = 0; i < in.length; i++) {
errln("Incorrect result in " + converter);
}
}
-
+
@Test
public void TestSurrogateBehavior() {
CharsetProviderICU icu = new CharsetProviderICU();
-
+
// get all the converters into an array
Object[] converters = CharsetProviderICU.getAvailableNames();
-
+
String norm = "a";
String ext = "\u0275"; // theta
String lead = "\ud835";
String trail = "\udd04";
// lead + trail = \U1d504 (fraktur capital A)
-
- String input =
+
+ String input =
// error position
ext // unmap(1) 1
- + lead // under 1
+ + lead // under 1
+ lead // malf(1) 2
+ trail // unmap(2) 4
+ trail // malf(1) 5
};
int[] positions = new int[] { 1,1,2,4,5,6,7 };
int n = positions.length;
-
+
int badcount = 0;
int goodcount = 0;
int[] uhohindices = new int[n];
int[] unmapindices = new int[n];
ArrayList pass = new ArrayList();
ArrayList exempt = new ArrayList();
-
+
outer: for (int conv=0; conv<converters.length; conv++) {
String converter = (String)converters[conv];
if (converter.equals("x-IMAP-mailbox-name") || converter.equals("UTF-7") || converter.equals("CESU-8") || converter.equals("BOCU-1") ||
exempt.add(converter);
continue;
}
-
+
boolean currentlybad = false;
Charset icuChar = icu.charsetForName(converter);
CharsetEncoder encoder = icuChar.newEncoder();
CoderResult cr;
-
+
CharBuffer source = CharBuffer.wrap(input);
ByteBuffer target = ByteBuffer.allocate(30);
ByteBuffer expected = null;
errln(converter + " " + ex.getClass().getName() + ": " + ex.getMessage());
continue outer;
}
-
+
encoder.onUnmappableCharacter(CodingErrorAction.REPORT);
encoder.onMalformedInput(CodingErrorAction.REPORT);
for (int i=0; i<n; i++) {
badposindices[i]++;
errln("(index=" + i + ") " + converter + " Received: " + source.position() + " Expected: " + positions[i]);
}
-
+
}
encoder.reset();
-
+
//System.out.println("\n" + hex(target.array()));
//System.out.println(hex(expected.array()) + "\n" + expected.limit());
if (!(equals(target, expected, expected.limit()) && target.position() == expected.limit())) {
if (!currentlybad) {currentlybad = true; badcount++; logln(""); }
errln(converter + " Received: \"" + hex(target.array()) + "\" Expected: \"" + hex(expected.array()) + "\"");
}
-
+
if (!currentlybad) {
goodcount++;
pass.add(converter);
}
}
-
+
logln("\n" + badcount + " / " + (converters.length - exempt.size()) + " (" + goodcount + " good, " + badcount + " bad)");
log("index\t"); for (int i=0; i<n; i++) log(i + "\t"); logln("");
log("unmap\t"); for (int i=0; i<n; i++) log(unmapindices[i] + "\t"); logln("");
log("pos \t"); for (int i=0; i<n; i++) log(badposindices[i] + "\t"); logln("");
log("uhoh \t"); for (int i=0; i<n; i++) log(uhohindices[i] + "\t"); logln("");
logln("");
- log("The few that passed: "); for (int i=0; i<pass.size(); i++) log(pass.get(i) + ", "); logln("");
- log("The few that are exempt: "); for (int i=0; i<exempt.size(); i++) log(exempt.get(i) + ", "); logln("");
+ log("The few that passed: "); for (int i=0; i<pass.size(); i++) log(pass.get(i) + ", "); logln("");
+ log("The few that are exempt: "); for (int i=0; i<exempt.size(); i++) log(exempt.get(i) + ", "); logln("");
}
-
+
// public void TestCharsetCallback() {
// String currentTest = "initialization";
// try {
// Class[] params;
-//
+//
// // get the classes
// Class CharsetCallback = Class.forName("com.ibm.icu.charset.CharsetCallback");
// Class Decoder = Class.forName("com.ibm.icu.charset.CharsetCallback$Decoder");
// Class Encoder = Class.forName("com.ibm.icu.charset.CharsetCallback$Encoder");
-//
+//
// // set up encoderCall
-// params = new Class[] {CharsetEncoderICU.class, Object.class,
-// CharBuffer.class, ByteBuffer.class, IntBuffer.class,
+// params = new Class[] {CharsetEncoderICU.class, Object.class,
+// CharBuffer.class, ByteBuffer.class, IntBuffer.class,
// char[].class, int.class, int.class, CoderResult.class };
// Method encoderCall = Encoder.getDeclaredMethod("call", params);
-//
+//
// // set up decoderCall
-// params = new Class[] {CharsetDecoderICU.class, Object.class,
+// params = new Class[] {CharsetDecoderICU.class, Object.class,
// ByteBuffer.class, CharBuffer.class, IntBuffer.class,
// char[].class, int.class, CoderResult.class};
// Method decoderCall = Decoder.getDeclaredMethod("call", params);
-//
+//
// // get relevant fields
// Object SUB_STOP_ON_ILLEGAL = getFieldValue(CharsetCallback, "SUB_STOP_ON_ILLEGAL", null);
-//
+//
// // set up a few arguments
// CharsetProvider provider = new CharsetProviderICU();
// Charset charset = provider.charsetForName("UTF-8");
// CoderResult unmap = CoderResult.unmappableForLength(2);
// CoderResult malf = CoderResult.malformedForLength(2);
// CoderResult under = CoderResult.UNDERFLOW;
-//
+//
// // set up error arrays
// Integer invalidCharLength = new Integer(1);
// Byte subChar1 = new Byte((byte)0);
// Byte subChar1_alternate = new Byte((byte)1); // for TO_U_CALLBACK_SUBSTITUTE
-//
+//
// // set up chars and bytes backups and expected values for certain cases
// CharBuffer charsBackup = bufferCopy(chars);
// ByteBuffer bytesBackup = bufferCopy(bytes);
// CharBuffer decoderCharsExpected2 = bufferCopy(chars);
// IntBuffer decoderOffsetsExpected1 = bufferCopy(offsets);
// IntBuffer decoderOffsetsExpected2 = bufferCopy(offsets);
-//
+//
// // initialize fields to obtain expected data
// setFieldValue(CharsetDecoderICU.class, "invalidCharLength", decoder, invalidCharLength);
// setFieldValue(CharsetICU.class, "subChar1", ((CharsetICU) decoder.charset()), subChar1);
-//
+//
// // run cbFromUWriteSub
// Method cbFromUWriteSub = CharsetEncoderICU.class.getDeclaredMethod("cbFromUWriteSub", new Class[] { CharsetEncoderICU.class, CharBuffer.class, ByteBuffer.class, IntBuffer.class});
// cbFromUWriteSub.setAccessible(true);
// CoderResult encoderResultExpected = (CoderResult)cbFromUWriteSub.invoke(encoder, new Object[] {encoder, encoderCharsExpected, encoderBytesExpected, encoderOffsetsExpected});
-//
+//
// // run toUWriteUChars with normal data
// Method toUWriteUChars = CharsetDecoderICU.class.getDeclaredMethod("toUWriteUChars", new Class[] { CharsetDecoderICU.class, char[].class, int.class, int.class, CharBuffer.class, IntBuffer.class, int.class});
// toUWriteUChars.setAccessible(true);
// CoderResult decoderResultExpected1 = (CoderResult)toUWriteUChars.invoke(decoder, new Object[] {decoder, new char[] {0xFFFD}, new Integer(0), new Integer(1), decoderCharsExpected1, decoderOffsetsExpected1, new Integer(bytes.position())});
-//
+//
// // reset certain fields
// setFieldValue(CharsetDecoderICU.class, "invalidCharLength", decoder, invalidCharLength);
// setFieldValue(CharsetICU.class, "subChar1", ((CharsetICU) decoder.charset()), subChar1_alternate);
-//
+//
// // run toUWriteUChars again
// CoderResult decoderResultExpected2 = (CoderResult)toUWriteUChars.invoke(decoder, new Object[] {decoder, new char[] {0x1A}, new Integer(0), new Integer(1), decoderCharsExpected2, decoderOffsetsExpected2, new Integer(bytes.position())});
-//
+//
// // begin creating the tests array
// ArrayList tests = new ArrayList();
-//
+//
// // create tests for FROM_U_CALLBACK_SKIP 0
// tests.add(new Object[] {encoderCall, "FROM_U_CALLBACK_SKIP", new Object[] { encoder, null, chars, bytes, offsets, buffer, length, cp, null }, under, charsBackup, bytesBackup, offsetsBackup, new Object[] { }});
// tests.add(new Object[] {encoderCall, "FROM_U_CALLBACK_SKIP", new Object[] { encoder, SUB_STOP_ON_ILLEGAL, chars, bytes, offsets, buffer, length, cp, malf }, malf, charsBackup, bytesBackup, offsetsBackup, new Object[] { }});
// tests.add(new Object[] {encoderCall, "FROM_U_CALLBACK_SKIP", new Object[] { encoder, SUB_STOP_ON_ILLEGAL, chars, bytes, offsets, buffer, length, cp, unmap }, under, charsBackup, bytesBackup, offsetsBackup, new Object[] { }});
// tests.add(new Object[] {encoderCall, "FROM_U_CALLBACK_SKIP", new Object[] { encoder, SUB_STOP_ON_ILLEGAL + "xx", chars, bytes, offsets, buffer, length, cp, null }, null, charsBackup, bytesBackup, offsetsBackup, new Object[] { }});
-//
+//
// // create tests for TO_U_CALLBACK_SKIP 4
// tests.add(new Object[] {decoderCall, "TO_U_CALLBACK_SKIP", new Object[] { decoder, null, bytes, chars, offsets, buffer, length, null }, under, charsBackup, bytesBackup, offsetsBackup, new Object[] { invalidCharLength, subChar1 }});
// tests.add(new Object[] {decoderCall, "TO_U_CALLBACK_SKIP", new Object[] { decoder, SUB_STOP_ON_ILLEGAL, bytes, chars, offsets, buffer, length, malf }, malf, charsBackup, bytesBackup, offsetsBackup, new Object[] { invalidCharLength, subChar1 }});
// tests.add(new Object[] {decoderCall, "TO_U_CALLBACK_SKIP", new Object[] { decoder, SUB_STOP_ON_ILLEGAL, bytes, chars, offsets, buffer, length, unmap }, under, charsBackup, bytesBackup, offsetsBackup, new Object[] { invalidCharLength, subChar1 }});
// tests.add(new Object[] {decoderCall, "TO_U_CALLBACK_SKIP", new Object[] { decoder, SUB_STOP_ON_ILLEGAL + "xx", bytes, chars, offsets, buffer, length, null }, null, charsBackup, bytesBackup, offsetsBackup, new Object[] { invalidCharLength, subChar1 }});
-//
+//
// // create tests for FROM_U_CALLBACK_STOP 8
// tests.add(new Object[] {encoderCall, "FROM_U_CALLBACK_STOP", new Object[] { encoder, null, chars, bytes, offsets, buffer, length, cp, null }, null, charsBackup, bytesBackup, offsetsBackup, new Object[] { }});
// tests.add(new Object[] {encoderCall, "FROM_U_CALLBACK_STOP", new Object[] { encoder, SUB_STOP_ON_ILLEGAL, chars, bytes, offsets, buffer, length, cp, malf }, malf, charsBackup, bytesBackup, offsetsBackup, new Object[] { }});
// tests.add(new Object[] {encoderCall, "FROM_U_CALLBACK_STOP", new Object[] { encoder, SUB_STOP_ON_ILLEGAL, chars, bytes, offsets, buffer, length, cp, unmap }, unmap, charsBackup, bytesBackup, offsetsBackup, new Object[] { }});
// tests.add(new Object[] {encoderCall, "FROM_U_CALLBACK_STOP", new Object[] { encoder, SUB_STOP_ON_ILLEGAL + "xx", chars, bytes, offsets, buffer, length, cp, null }, null, charsBackup, bytesBackup, offsetsBackup, new Object[] { }});
-//
+//
// // create tests for TO_U_CALLBACK_STOP 12
// tests.add(new Object[] {decoderCall, "TO_U_CALLBACK_STOP", new Object[] { decoder, null, bytes, chars, offsets, buffer, length, null }, null, charsBackup, bytesBackup, offsetsBackup, new Object[] { invalidCharLength, subChar1 }});
// tests.add(new Object[] {decoderCall, "TO_U_CALLBACK_STOP", new Object[] { decoder, SUB_STOP_ON_ILLEGAL, bytes, chars, offsets, buffer, length, malf }, malf, charsBackup, bytesBackup, offsetsBackup, new Object[] { invalidCharLength, subChar1 }});
// tests.add(new Object[] {decoderCall, "TO_U_CALLBACK_STOP", new Object[] { decoder, SUB_STOP_ON_ILLEGAL, bytes, chars, offsets, buffer, length, unmap }, unmap, charsBackup, bytesBackup, offsetsBackup, new Object[] { invalidCharLength, subChar1 }});
// tests.add(new Object[] {decoderCall, "TO_U_CALLBACK_STOP", new Object[] { decoder, SUB_STOP_ON_ILLEGAL + "xx", bytes, chars, offsets, buffer, length, null }, null, charsBackup, bytesBackup, offsetsBackup, new Object[] { invalidCharLength, subChar1 }});
-//
+//
// // create tests for FROM_U_CALLBACK_SUBSTITUTE 16
// tests.add(new Object[] {encoderCall, "FROM_U_CALLBACK_SUBSTITUTE", new Object[] { encoder, null, chars, bytes, offsets, buffer, length, cp, null }, encoderResultExpected, encoderCharsExpected, encoderBytesExpected, encoderOffsetsExpected, new Object[] { }});
// tests.add(new Object[] {encoderCall, "FROM_U_CALLBACK_SUBSTITUTE", new Object[] { encoder, SUB_STOP_ON_ILLEGAL, chars, bytes, offsets, buffer, length, cp, malf }, malf, charsBackup, bytesBackup, offsetsBackup, new Object[] { }});
// tests.add(new Object[] {encoderCall, "FROM_U_CALLBACK_SUBSTITUTE", new Object[] { encoder, SUB_STOP_ON_ILLEGAL, chars, bytes, offsets, buffer, length, cp, unmap }, encoderResultExpected, encoderCharsExpected, encoderBytesExpected, encoderOffsetsExpected, new Object[] { }});
// tests.add(new Object[] {encoderCall, "FROM_U_CALLBACK_SUBSTITUTE", new Object[] { encoder, SUB_STOP_ON_ILLEGAL + "xx", chars, bytes, offsets, buffer, length, cp, null }, null, charsBackup, bytesBackup, offsetsBackup, new Object[] { }});
-//
+//
// // create tests for TO_U_CALLBACK_SUBSTITUTE 20
// tests.add(new Object[] {decoderCall, "TO_U_CALLBACK_SUBSTITUTE", new Object[] { decoder, null, bytes, chars, offsets, buffer, length, null }, decoderResultExpected1, decoderCharsExpected1, bytesBackup, decoderOffsetsExpected1, new Object[] { invalidCharLength, subChar1 }});
// tests.add(new Object[] {decoderCall, "TO_U_CALLBACK_SUBSTITUTE", new Object[] { decoder, null, bytes, chars, offsets, buffer, length, null }, decoderResultExpected2, decoderCharsExpected2, bytesBackup, decoderOffsetsExpected2, new Object[] { invalidCharLength, subChar1_alternate }});
-//
+//
// Iterator iter = tests.iterator();
// for (int i=0; iter.hasNext(); i++) {
// // get the data out of the map
// Object[] next = (Object[])iter.next();
-//
+//
// Method method = (Method)next[0];
// String fieldName = (String)next[1];
// Object field = getFieldValue(CharsetCallback, fieldName, null);
// CharBuffer charsExpected = (CharBuffer)next[4];
// ByteBuffer bytesExpected = (ByteBuffer)next[5];
// IntBuffer offsetsExpected = (IntBuffer)next[6];
-//
+//
// // set up error arrays and certain fields
// Object[] values = (Object[])next[7];
// if (method == decoderCall) {
// } else if (method == encoderCall) {
// encoder.reset();
// }
-//
+//
// try {
// // invoke the method
// CoderResult actual = (CoderResult)method.invoke(field, args);
-//
+//
// // if expected != actual
// if (!coderResultsEqual(expected, actual)) {
// // case #i refers to the index in the arraylist tests
// errln(fieldName + " failed to return the correct result for case #" + i + ".");
// }
// // if the expected buffers != actual buffers
-// else if (!(buffersEqual(chars, charsExpected) &&
+// else if (!(buffersEqual(chars, charsExpected) &&
// buffersEqual(bytes, bytesExpected) &&
// buffersEqual(offsets, offsetsExpected))) {
// // case #i refers to the index in the arraylist tests
// errln(fieldName + " threw an exception for case #" + i + ": " + ex.getCause());
// //ex.getCause().printStackTrace();
// }
-//
+//
// // reset the buffers
// System.arraycopy(bytesBackup.array(), 0, bytes.array(), 0, 10);
// System.arraycopy(charsBackup.array(), 0, chars.array(), 0, 10);
// chars.position(charsBackup.position());
// offsets.position(offsetsBackup.position());
// }
-//
+//
// } catch (Exception ex) {
// errln("TestCharsetCallback skipped due to " + ex.toString());
// ex.printStackTrace();
// }
// }
-//
+//
// private Object getFieldValue(Class c, String name, Object instance) throws Exception {
// Field field = c.getDeclaredField(name);
// field.setAccessible(true);
// dest.position(src.position());
// return dest;
// }
-
+
@Test
public void TestAPISemantics(/*String encoding*/) {
}
if (result.isError()) {
errln("ToChars single the result is an error "+result.toString());
- }
+ }
}
if (unistr.length() != (chars.limit())) {
errln("ToChars single len does not match");
} else {
boolean result = true;
for (int i = 0; i < chars.length; i++) {
- if (chars[i] != compareTo[i]) {
+ if (chars[i] != compareTo[i]) {
logln(
"Got: "
+ hex(chars[i])
/*
@Test
public void TestCallback(String encoding) throws Exception {
-
+
byte[] gbSource =
{
(byte) 0x81,
if (!equals(myTarget, new String(expectedResult))) {
errln("Test callback GB18030 to Unicode : FAILED");
}
-
+
}
*/
@Test
public void TestCanConvert(/*String encoding*/)throws Exception {
- char[] mySource = {
+ char[] mySource = {
'\ud800', '\udc00',/*surrogate pair */
'\u22A6','\u22A7','\u22A8','\u22A9','\u22AA',
'\u22AB','\u22AC','\u22AD','\u22AE','\u22AF',
'\u22B0','\u22B1','\u22B2','\u22B3','\u22B4',
'\ud800','\udc00',/*surrogate pair */
'\u22B5','\u22B6','\u22B7','\u22B8','\u22B9',
- '\u22BA','\u22BB','\u22BC','\u22BD','\u22BE'
+ '\u22BA','\u22BB','\u22BC','\u22BD','\u22BE'
};
String encoding = "UTF-16";
CharsetEncoder encoder = null;
}
}
-
+
@Test
public void TestAvailableCharsets() {
SortedMap map = Charset.availableCharsets();
errln("Did not get the expected canonical name. Got: "+canonicalName); //get the canonical name
}
}
-
+
@Test
public void TestICUAvailableCharsets() {
CharsetProviderICU icu = new CharsetProviderICU();
warnln("Error creating charset encoder for " + encoding + ": " + e);
}
}
-
+
@Test
public void TestSubBytes(){
try{
//create utf-8 decoder
CharsetDecoder decoder = new CharsetProviderICU().charsetForName("utf-8").newDecoder();
-
+
//create a valid byte array, which can be decoded to " buffer"
byte[] unibytes = new byte[] { 0x0020, 0x0062, 0x0075, 0x0066, 0x0066, 0x0065, 0x0072 };
-
+
ByteBuffer buffer = ByteBuffer.allocate(20);
-
+
//add a evil byte to make the byte buffer be malformed input
buffer.put((byte)0xd8);
-
+
//put the valid byte array
buffer.put(unibytes);
-
+
//reset postion
- buffer.flip();
-
+ buffer.flip();
+
decoder.onMalformedInput(CodingErrorAction.REPLACE);
CharBuffer out = decoder.decode(buffer);
String expected = "\ufffd buffer";
@Test
public void TestImplFlushFailure(){
-
+
try{
CharBuffer in = CharBuffer.wrap("\u3005\u3006\u3007\u30FC\u2015\u2010\uFF0F");
CharsetEncoder encoder = new CharsetProviderICU().charsetForName("iso-2022-jp").newEncoder();
if(out.position()!= 20){
errln("Did not get the expected position from flush");
}
-
+
}catch (Exception ex){
errln("Could not create encoder for iso-2022-jp exception: "+ex.toString());
- }
+ }
}
*/
@Test
public void TestISO88591() {
-
+
Charset cs = new CharsetProviderICU().charsetForName("iso-8859-1");
if(cs!=null){
CharsetEncoder encoder = cs.newEncoder();
}else{
errln("Could not create Charset for iso-8859-1");
}
-
+
}
@Test
logln("\\ud800 is malformed for JDK utf-8 encoder");
//e.printStackTrace();
}
-
+
CharsetEncoder encoderJDK = Charset.forName("utf-8").newEncoder();
try {
encoderJDK.encode(CharBuffer.wrap("\ud800"));
} catch (Exception e) {
logln("\\ud800 is malformed for JDK utf-8 encoder");
//e.printStackTrace();
- }
+ }
}
-
+
@Test
public void TestUTF16Bom(){
equals(rt, in);
}
}
-
+
private void smBufDecode(CharsetDecoder decoder, String encoding, ByteBuffer source, CharBuffer target,
boolean throwException, boolean flush) throws BufferOverflowException, Exception {
smBufDecode(decoder, encoding, source, target, throwException, flush, true);
}
/*private void fromUnicodeTest() throws Exception {
-
+
logln("Loaded Charset: " + charset.getClass().toString());
logln("Loaded CharsetEncoder: " + encoder.getClass().toString());
logln("Loaded CharsetDecoder: " + decoder.getClass().toString());
-
+
ByteBuffer myTarget = ByteBuffer.allocate(gbSource.length);
logln("Created ByteBuffer of length: " + uSource.length);
CharBuffer mySource = CharBuffer.wrap(uSource);
encoder.encode(mySource, myTarget, true);
if (!equals(myTarget, gbSource)) {
errln("--Test Unicode to " + encoding + ": FAILED");
- }
+ }
logln("Test Unicode to " + encoding +" passed");
}
@Test
public void TestToUnicode( ) throws Exception {
-
+
logln("Loaded Charset: " + charset.getClass().toString());
logln("Loaded CharsetEncoder: " + encoder.getClass().toString());
logln("Loaded CharsetDecoder: " + decoder.getClass().toString());
-
+
CharBuffer myTarget = CharBuffer.allocate(uSource.length);
ByteBuffer mySource = ByteBuffer.wrap(getByteArray(gbSource));
decoder.reset();
errln("Encountered exception in smBufCharset");
}
}
-
+
@Test
public void TestMultithreaded() throws Exception {
final Charset cs = Charset.forName(encoding);
// commented out since the mehtods on
// Charset API are supposed to be thread
// safe ... to test it we dont sync
-
+
// synchronized(charset){
while (!interrupted()) {
try {
}
}
*/
-
+
@Test
- public void TestMBCS(){
+ public void TestMBCS(){
{
// Encoder: from Unicode conversion
CharsetEncoder encoderICU = new CharsetProviderICU().charsetForName("ibm-971").newEncoder();
}
}
}
-
+
@Test
public void TestJB4897(){
CharsetProviderICU provider = new CharsetProviderICU();
- Charset charset = provider.charsetForName("x-abracadabra");
+ Charset charset = provider.charsetForName("x-abracadabra");
if(charset!=null && charset.canEncode()== true){
errln("provider.charsetForName() does not validate the charset names" );
}
//test to make sure that number of aliases and canonical names are in the charsets that are in
@Test
public void TestAllNames() {
-
+
CharsetProviderICU provider= new CharsetProviderICU();
Object[] available = CharsetProviderICU.getAvailableNames();
for(int i=0; i<available.length;i++){
continue;
}
Charset cs = provider.charsetForName((String)available[i]);
-
+
Object[] javaAliases = cs.aliases().toArray();
//seach for ICU canonical name in javaAliases
boolean inAliasList = false;
CharBuffer out = CharBuffer.allocate(3);
return decoder.decode(in, out, true);
}
-
+
@Test
public void TestJavaUTF16Decoder(){
CharsetProviderICU provider = new CharsetProviderICU();
public void TestUTF32BOM(){
Charset cs = (new CharsetProviderICU()).charsetForName("UTF-32");
- char[] in = new char[] { 0xd800, 0xdc00,
+ char[] in = new char[] { 0xd800, 0xdc00,
0xd801, 0xdc01,
- 0xdbff, 0xdfff,
- 0xd900, 0xdd00,
+ 0xdbff, 0xdfff,
+ 0xd900, 0xdd00,
0x0000, 0x0041,
0x0000, 0x0042,
0x0000, 0x0043};
-
+
CharBuffer inBuf = CharBuffer.allocate(in.length);
inBuf.put(in);
CharsetEncoder encoder = cs.newEncoder();
inBuf.rewind();
encoder.encode(inBuf, outBuf, true);
outBuf.rewind();
- if(outBuf.get(0)!= (byte)0x00 && outBuf.get(1)!= (byte)0x00 &&
+ if(outBuf.get(0)!= (byte)0x00 && outBuf.get(1)!= (byte)0x00 &&
outBuf.get(2)!= (byte)0xFF && outBuf.get(3)!= (byte)0xFE){
errln("The UTF32 encoder did not appended bom. Length returned: " + outBuf.remaining());
}
// swallow the expection.
}
}
-
+
/*
* Michael Ow
* Modified 070424
*/
- /*The following two methods provides the option of exceptions when Decoding
+ /*The following two methods provides the option of exceptions when Decoding
* and Encoding if needed for testing purposes.
*/
private void smBufDecode(CharsetDecoder decoder, String encoding, ByteBuffer source, CharBuffer target) {
private void smBufDecode(CharsetDecoder decoder, String encoding, ByteBuffer source, CharBuffer target, boolean backedByArray) {
try {
smBufDecode(decoder, encoding, source, target, false, false, backedByArray);
- }
- catch (Exception ex) {
+ }
+ catch (Exception ex) {
System.out.println("!exception!");
}
}
}
private void smBufEncode(CharsetEncoder encoder, String encoding, CharBuffer source, ByteBuffer target, boolean backedByArray) {
try {
- smBufEncode(encoder, encoding, source, target, false, false);
+ smBufEncode(encoder, encoding, source, target, false, false);
}
catch (Exception ex) {
System.out.println("!exception!");
public void TestNullCanonicalName() {
String enc = null;
String canonicalName = CharsetProviderICU.getICUCanonicalName(enc);
-
+
if (canonicalName != null) {
errln("getICUCanonicalName return a non-null string for given null string");
}
@Test
public void TestGetAllNames() {
String[] names = null;
-
+
names = CharsetProviderICU.getAllNames();
-
+
if (names == null) {
errln("getAllNames returned a null string.");
}
@Test
public void TestCharsetContains() {
boolean test;
-
- CharsetProvider provider = new CharsetProviderICU();
+
+ CharsetProvider provider = new CharsetProviderICU();
Charset cs1 = provider.charsetForName("UTF-32");
Charset cs2 = null;
-
+
test = cs1.contains(cs2);
-
+
if (test != false) {
errln("Charset.contains returned true for a null charset.");
}
-
+
cs2 = CharsetICU.forNameICU("UTF-32");
-
+
test = cs1.contains(cs2);
-
+
if (test != true) {
errln("Charset.contains returned false for an identical charset.");
}
-
+
cs2 = provider.charsetForName("UTF-8");
-
+
test = cs1.contains(cs2);
-
+
if (test != false) {
errln("Charset.contains returned true for a different charset.");
}
@Test
public void TestCharsetICUNullCharsetName() {
String charsetName = null;
-
+
try {
CharsetICU.forNameICU(charsetName);
errln("CharsetICU.forName should have thown an exception after getting a null charsetName.");
}
- catch(Exception ex) {
+ catch(Exception ex) {
}
}
-
+
//Test CharsetASCII
@Test
public void TestCharsetASCIIOverFlow() {
int byteBufferLimit;
int charBufferLimit;
-
+
CharsetProvider provider = new CharsetProviderICU();
- Charset cs = provider.charsetForName("ASCII");
+ Charset cs = provider.charsetForName("ASCII");
CharsetEncoder encoder = cs.newEncoder();
CharsetDecoder decoder = cs.newDecoder();
-
+
CharBuffer charBuffer = CharBuffer.allocate(0x90);
ByteBuffer byteBuffer = ByteBuffer.allocate(0x90);
-
+
CharBuffer charBufferTest = CharBuffer.allocate(0xb0);
ByteBuffer byteBufferTest = ByteBuffer.allocate(0xb0);
-
+
for(int j=0;j<=0x7f; j++){
charBuffer.put((char)j);
byteBuffer.put((byte)j);
}
-
+
byteBuffer.limit(byteBufferLimit = byteBuffer.position());
byteBuffer.position(0);
charBuffer.limit(charBufferLimit = charBuffer.position());
charBuffer.position(0);
-
+
//test for overflow
byteBufferTest.limit(byteBufferLimit - 5);
byteBufferTest.position(0);
}
catch (Exception ex) {
}
-
+
// For better code coverage
/* For better code coverage */
byte byteout[] = {
public void TestCharsetUTF7() {
CoderResult result = CoderResult.UNDERFLOW;
CharsetProvider provider = new CharsetProviderICU();
- Charset cs = provider.charsetForName("UTF-7");
+ Charset cs = provider.charsetForName("UTF-7");
CharsetEncoder encoder = cs.newEncoder();
CharsetDecoder decoder = cs.newDecoder();
-
+
CharBuffer us = CharBuffer.allocate(0x100);
ByteBuffer bs = ByteBuffer.allocate(0x100);
-
+
/* Unicode : A<not equal to Alpha Lamda>. */
/* 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());
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);
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());
}
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.");
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);
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);
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);
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);
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);
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);
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());
} 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()) {
@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);
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();
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.");
}
//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());
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.");
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) {
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.");
} 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);
}
//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();
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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,
};
};
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,
};
};
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",
};
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",
};
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();
}
}
}
-
+
// Testing invalid input exceptions
@Test
public void TestInvalidInput() {
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() {
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
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);
errln("Error should have occurred while encoding: " + charsetName);
}
}
-
+
/* Round trip test of SCSU converter*/
@Test
public void TestSCSUConverter(){
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,
0x01df, 0xf000, 0xdbff, 0xdfff
};
-
+
char germanUTF16[]={
0x00d6, 0x006c, 0x0020, 0x0066, 0x006c, 0x0069, 0x0065, 0x00df, 0x0074
};
};
// 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,
(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;
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);
}
}
}
-
+
/* Monkey test */
{
char[] monkeyIn = {
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);
}
};
encode.reset();
CharBuffer malformedSrc = CharBuffer.wrap(malformedSequence);
-
+
try {
encode.encode(malformedSrc);
errln("Malformed error should have thrown an exception.");
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
(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());
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() {
}
}
}
-
+
/* Increase code coverage for CharsetICU and CharsetProviderICU*/
@Test
public void TestCharsetICUCodeCoverage() {
}
errln("IllegalArgumentException should have been thrown.");
}
-
+
@Test
public void TestCharsetLMBCS() {
String []lmbcsNames = {
"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) {
}
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]);
}
}
errln("Exception thrown: " + ex + " while using charset: " + lmbcsNames[i]);
}
-
+
}
-
+
// Test malformed
CoderResult malformedResult = CoderResult.UNDERFLOW;
byte[] malformedBytes = {
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
};
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) {
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. */
}
}
}
-
+
@Test
public void TestIsFixedWidth(){
String[] fixedWidth = {
"UTF32",
"ibm-5478_P100-1995"
};
-
+
String[] notFixedWidth = {
"GB18030",
"UTF8",
};
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();
"ISCII,version=0",
"ISO_2022,locale=ko,version=0"
};
-
+
int[] expected = {
40,
20,
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.
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()) {
}
}
}
-
+
/*
* 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
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";
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++) {
/**
* 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
*/
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;
import com.ibm.icu.text.UTF16;
import com.ibm.icu.text.UnicodeSet;
+@RunWith(JUnit4.class)
public class TestSelection extends TestFmwk {
@Test
public void TestConversionUTF16() {
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," +
"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," +
"\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 " +
"\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" +
"\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 " +
"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" +
"\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" +
"\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" +
"\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 " +
"\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" +
"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" +
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;
/**
* @author Mark Davis
*/
+@RunWith(JUnit4.class)
public class AlphabeticIndexTest extends TestFmwk {
/**
*
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;
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.
*******************************************************************************
*/
-/**
+/**
* 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;
CollationTest.doTest(this, collator, seq[i], seq[i + 1], -1);
}
}
-}
\ No newline at end of file
+}
* 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;
/**
- *
- * 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;
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;
key1 = localeCollator.getCollationKey(randString1);
key2 = ruleCollator.getCollationKey(randString1);
-
+
report(locale.getDisplayName(), randString1, key1, key2);
}
}
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');
*******************************************************************************
*/
-/**
+/**
* 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() {
{ 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]);
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) {
}
}
}
-
+
private void reportCResult( String source, String target, CollationKey sourceKey, CollationKey targetKey,
int compareResult, int keyResult, int incResult, int expectedResult ) {
if (expectedResult < -1 || expectedResult > 1) {
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);
} else {
errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect);
}
-
+
msg1 = ok2 ? "Ok: key(\"" : "FAIL: key(\"";
msg2 = "\").compareTo(key(\"";
msg3 = "\")) returned ";
msg2 = " vs. ";
errln(msg1 + CollationTest.prettify(sourceKey) + msg2 + CollationTest.prettify(targetKey));
}
-
+
msg1 = ok3 ? "Ok: incCompare(\"" : "FAIL: incCompare(\"";
msg2 = "\", \"";
msg3 = "\") returned ";
logln(msg1 + source + msg2 + target + msg3 + sResult);
} else {
errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect);
- }
+ }
}
}
}
*******************************************************************************
*/
-/**
+/**
* 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;
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 = {
{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 = {
{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},
{0x63},
{0x7a}
};
-
+
int[] results = {
-1,
-1, //Collator::GREATER,
-1,
1,
1,
- -1, // 10
+ -1, // 10
1,
-1,
1,
-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() {
// 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]);
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);
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'<A";
String source[] = {"z",
"\uD800\uDC00",
"\ud800\udc0a\u0308",
- "\ud800\udc02"
+ "\ud800\udc02"
};
-
+
String target[] = {"\uD800\uDC00",
"\ud800\udc0a\u0308",
"A",
- "\ud800\udc03"
+ "\ud800\udc03"
};
-
- // this test is to verify the supplementary sort key order in the english
+
+ // this test is to verify the supplementary sort key order in the english
// collator
Collator enCollation;
try {
enCollation = Collator.getInstance(Locale.ENGLISH);
} catch (Exception e) {
errln("ERROR: Failed to create the collator for ENGLISH");
- return;
+ return;
}
-
+
myCollation.setStrength(Collator.TERTIARY);
int count = 0;
// logln("start of english collation supplementary characters test\n");
count ++;
}
doTest(enCollation, source[count], target[count], 1);
-
+
// logln("start of tailored collation supplementary characters test\n");
count = 0;
Collator newCollation;
newCollation = new RuleBasedCollator(rules);
} catch (Exception e) {
errln("ERROR: Failed to create the collator for rules");
- return;
+ return;
}
-
- // tests getting collation elements for surrogates for tailored rules
+
+ // tests getting collation elements for surrogates for tailored rules
while (count < 4) {
doTest(newCollation, source[count], target[count], -1);
count ++;
}
-
- // tests that \uD801\uDC01 still has the same value, not changed
+
+ // tests that \uD801\uDC01 still has the same value, not changed
CollationKey enKey = enCollation.getCollationKey(source[3]);
CollationKey newKey = newCollation.getCollationKey(source[3]);
int keyResult = enKey.compareTo(newKey);
char[] source = new char[1];
char ch;
int expected[] = {0};
-
+
try {
enColl = Collator.getInstance(Locale.ENGLISH);
} catch (Exception e) {
errln("ERROR: Failed to create the collator for ENGLISH");
return;
}
-
+
try{
myColl = new RuleBasedCollator(rule);
} catch(Exception e){
errln("Fail to create RuleBasedCollator with rules:" + rule);
return;
- }
+ }
enColl.setStrength(Collator.PRIMARY);
myColl.setStrength(Collator.PRIMARY);
-
+
((RuleBasedCollator)enColl).setAlternateHandlingShifted(true);
((RuleBasedCollator)myColl).setAlternateHandlingShifted(true);
-
+
if(((RuleBasedCollator)enColl).isAlternateHandlingShifted() != true) {
errln("ERROR: ALTERNATE_HANDLING value can not be set to SHIFTED\n");
}
-
- // space is supposed to be a variable
- CollationKey key = enColl.getCollationKey(" ");
- byte[] result = key.toByteArray();
-
+
+ // space is supposed to be a variable
+ CollationKey key = enColl.getCollationKey(" ");
+ byte[] result = key.toByteArray();
+
for(int i = 0; i < result.length; i++) {
if(result[i]!= expected[i]) {
- errln("ERROR: SHIFTED alternate does not return 0 for primary of space\n");
- break;
+ errln("ERROR: SHIFTED alternate does not return 0 for primary of space\n");
+ break;
}
}
-
+
ch = 'a';
while (ch < 'z') {
source[0] = ch;
key = myColl.getCollationKey(new String(source));
result = key.toByteArray();
-
+
for(int i = 0; i < result.length; i++) {
if(result[i]!= expected[i]) {
- errln("ERROR: SHIFTED alternate does not return 0 for primary of space\n");
- break;
+ errln("ERROR: SHIFTED alternate does not return 0 for primary of space\n");
+ break;
}
}
ch ++;
}
}
-
+
@Test
public void TestJB1401() {
Collator myCollator = null;
char[] NFD_UnsafeStartChars = {
- 0x0f73, // Tibetan Vowel Sign II
- 0x0f75, // Tibetan Vowel Sign UU
- 0x0f81, // Tibetan Vowel Sign Reversed II
+ 0x0f73, // Tibetan Vowel Sign II
+ 0x0f75, // Tibetan Vowel Sign UU
+ 0x0f81, // Tibetan Vowel Sign Reversed II
0
};
int i;
-
+
try{
myCollator = Collator.getInstance(Locale.ENGLISH);
} catch(Exception e) {
// in original form, NFD, and then NFC form.
char c = NFD_UnsafeStartChars[i];
if (c==0) {break;}
-
+
String x = "\u00C0" + c; // \u00C0 is A Grave
String y;
String z;
-
+
try{
y = Normalizer.decompose(x, false);
z = Normalizer.decompose(y, true);
errln("ERROR: Failed to normalize test of character" + c);
return;
}
-
+
// Collation test. All three strings should be equal.
// doTest does both strcoll and sort keys, with params in both orders.
doTest(myCollator, x, y, 0);
doTest(myCollator, x, z, 0);
- doTest(myCollator, y, z, 0);
-
+ doTest(myCollator, y, z, 0);
+
// Run collation element iterators over the three strings. Results should be same for each.
-
+
{
CollationElementIterator ceiX, ceiY, ceiZ;
int ceX, ceY, ceZ;
errln("ERROR: getCollationElementIterator failed");
return;
}
-
+
for (j=0;; j++) {
try{
ceX = ceiX.next();
errln("ERROR: CollationElementIterator.next failed for iteration " + j);
break;
}
-
+
if (ceX != ceY || ceY != ceZ) {
errln("ERROR: ucol_next failed for iteration " + j);
break;
}
}
}
-
+
// main test method called with different strengths,
// tests comparison of custum collation with different strengths
-
+
private void doTest(Collator collation, char[] source, char[] target, int result) {
String s = new String(source);
String t = new String(target);
doTestVariant(collation, t, s, 0);
}
}
-
+
// main test method called with different strengths,
// tests comparison of custum collation with different strengths
-
+
private void doTest(Collator collation,String s, String t, int result) {
doTestVariant(collation, s, t, result);
if(result == -1) {
doTestVariant(collation, t, s, 0);
}
}
-
+
private void doTestVariant(Collator collation, String source, String target, int result) {
int compareResult = collation.compare(source, target);
CollationKey srckey , tgtkey;
errln("Collation key comparison failed in variant test\n");
}
}
-}
\ No newline at end of file
+}
*******************************************************************************
*/
-/**
+/**
* Port From: ICU4C v2.1 : Collate/CollationEnglishTest
* Source File: $ICU4CRoot/source/test/intltest/encoll.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 CollationEnglishTest extends TestFmwk{
private static char[][] testSourceCases = {
{0x0061 /* 'a' */, 0x0062 /* 'b' */},
{0x0062 /* 'b' */, 0x006C /* 'l' */, 0x0061 /* 'a' */, 0x0063 /* 'c' */, 0x006B /* 'k' */, 0x0020 /* ' ' */, 0x0062 /* 'b' */, 0x0069 /* 'i' */, 0x0072 /* 'r' */, 0x0064 /* 'd' */},
{0x0062 /* 'b' */, 0x006C /* 'l' */, 0x0061 /* 'a' */, 0x0063 /* 'c' */, 0x006B /* 'k' */, 0x002D /* '-' */, 0x0062 /* 'b' */, 0x0069 /* 'i' */, 0x0072 /* 'r' */, 0x0064 /* 'd' */},
{0x0048 /* 'H' */, 0x0065 /* 'e' */, 0x006C /* 'l' */, 0x006C /* 'l' */, 0x006F /* 'o' */},
- {0x0041 /* 'A' */, 0x0042 /* 'B' */, 0x0043 /* 'C' */},
+ {0x0041 /* 'A' */, 0x0042 /* 'B' */, 0x0043 /* 'C' */},
{0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
{0x0062 /* 'b' */, 0x006C /* 'l' */, 0x0061 /* 'a' */, 0x0063 /* 'c' */, 0x006B /* 'k' */, 0x0062 /* 'b' */, 0x0069 /* 'i' */, 0x0072 /* 'r' */, 0x0064 /* 'd' */},
{0x0062 /* 'b' */, 0x006C /* 'l' */, 0x0061 /* 'a' */, 0x0063 /* 'c' */, 0x006B /* 'k' */, 0x002D /* '-' */, 0x0062 /* 'b' */, 0x0069 /* 'i' */, 0x0072 /* 'r' */, 0x0064 /* 'd' */},
{0x0062 /* 'b' */, 0x006C /* 'l' */, 0x0061 /* 'a' */, 0x0063 /* 'c' */, 0x006B /* 'k' */, 0x002D /* '-' */, 0x0062 /* 'b' */, 0x0069 /* 'i' */, 0x0072 /* 'r' */, 0x0064 /* 'd' */},
- {0x0070 /* 'p' */, 0x00EA, 0x0063 /* 'c' */, 0x0068 /* 'h' */, 0x0065 /* 'e' */},
+ {0x0070 /* 'p' */, 0x00EA, 0x0063 /* 'c' */, 0x0068 /* 'h' */, 0x0065 /* 'e' */},
{0x0070 /* 'p' */, 0x00E9, 0x0063 /* 'c' */, 0x0068 /* 'h' */, 0x00E9},
{0x00C4, 0x0042 /* 'B' */, 0x0308, 0x0043 /* 'C' */, 0x0308},
{0x0061 /* 'a' */, 0x0308, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
{0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
{0x0041 /* 'A' */},
{0x0041 /* 'A' */},
- {0x0061 /* 'a' */, 0x0062 /* 'b' */},
+ {0x0061 /* 'a' */, 0x0062 /* 'b' */},
{0x0074 /* 't' */, 0x0063 /* 'c' */, 0x006F /* 'o' */, 0x006D /* 'm' */, 0x0070 /* 'p' */, 0x0061 /* 'a' */, 0x0072 /* 'r' */, 0x0065 /* 'e' */, 0x0070 /* 'p' */, 0x006C /* 'l' */, 0x0061 /* 'a' */, 0x0069 /* 'i' */, 0x006E /* 'n' */},
- {0x0061 /* 'a' */, 0x0062 /* 'b' */},
+ {0x0061 /* 'a' */, 0x0062 /* 'b' */},
{0x0061 /* 'a' */, 0x0023 /* '#' */, 0x0062 /* 'b' */},
{0x0061 /* 'a' */, 0x0023 /* '#' */, 0x0062 /* 'b' */},
{0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
{0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */, 0x0064 /* 'd' */, 0x0061 /* 'a' */},
{0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */, 0x0064 /* 'd' */, 0x0061 /* 'a' */},
{0x00E6, 0x0062 /* 'b' */, 0x0063 /* 'c' */, 0x0064 /* 'd' */, 0x0061 /* 'a' */},
- {0x00E4, 0x0062 /* 'b' */, 0x0063 /* 'c' */, 0x0064 /* 'd' */, 0x0061 /* 'a' */},
+ {0x00E4, 0x0062 /* 'b' */, 0x0063 /* 'c' */, 0x0064 /* 'd' */, 0x0061 /* 'a' */},
{0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
{0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
{0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
{0x0061 /* 'a' */, 0x0308, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
{0x0074 /* 't' */, 0x0068 /* 'h' */, 0x0069 /* 'i' */, 0x0302, 0x0073 /* 's' */},
{0x0070 /* 'p' */, 0x00EA, 0x0063 /* 'c' */, 0x0068 /* 'h' */, 0x0065 /* 'e' */},
- {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
+ {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
{0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
{0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
{0x0061 /* 'a' */, 0x00E6, 0x0063 /* 'c' */},
{0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
{0x0061 /* 'a' */, 0x00E6, 0x0063 /* 'c' */},
{0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
- {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
+ {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
{0x0070 /* 'p' */, 0x00E9, 0x0063 /* 'c' */, 0x0068 /* 'h' */, 0x00E9} // 49
};
-
+
private static char[][] testTargetCases = {
{0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
{0x0062 /* 'b' */, 0x006C /* 'l' */, 0x0061 /* 'a' */, 0x0063 /* 'c' */, 0x006B /* 'k' */, 0x0062 /* 'b' */, 0x0069 /* 'i' */, 0x0072 /* 'r' */, 0x0064 /* 'd' */},
{0x0041 /* 'A' */, 0x0042 /* 'B' */, 0x0043 /* 'C' */},
{0x0062 /* 'b' */, 0x006C /* 'l' */, 0x0061 /* 'a' */, 0x0063 /* 'c' */, 0x006B /* 'k' */, 0x0062 /* 'b' */, 0x0069 /* 'i' */, 0x0072 /* 'r' */, 0x0064 /* 'd' */, 0x0073 /* 's' */},
{0x0062 /* 'b' */, 0x006C /* 'l' */, 0x0061 /* 'a' */, 0x0063 /* 'c' */, 0x006B /* 'k' */, 0x0062 /* 'b' */, 0x0069 /* 'i' */, 0x0072 /* 'r' */, 0x0064 /* 'd' */, 0x0073 /* 's' */},
- {0x0062 /* 'b' */, 0x006C /* 'l' */, 0x0061 /* 'a' */, 0x0063 /* 'c' */, 0x006B /* 'k' */, 0x0062 /* 'b' */, 0x0069 /* 'i' */, 0x0072 /* 'r' */, 0x0064 /* 'd' */},
+ {0x0062 /* 'b' */, 0x006C /* 'l' */, 0x0061 /* 'a' */, 0x0063 /* 'c' */, 0x006B /* 'k' */, 0x0062 /* 'b' */, 0x0069 /* 'i' */, 0x0072 /* 'r' */, 0x0064 /* 'd' */},
{0x0070 /* 'p' */, 0x00E9, 0x0063 /* 'c' */, 0x0068 /* 'h' */, 0x00E9},
{0x0070 /* 'p' */, 0x00E9, 0x0063 /* 'c' */, 0x0068 /* 'h' */, 0x0065 /* 'e' */, 0x0072 /* 'r' */},
{0x00C4, 0x0042 /* 'B' */, 0x0308, 0x0043 /* 'C' */, 0x0308},
{0x0041 /* 'A' */, 0x00E1, 0x0063 /* 'c' */, 0x0064 /* 'd' */},
{0x0041 /* 'A' */, 0x00E1, 0x0063 /* 'c' */, 0x0064 /* 'd' */},
{0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
- {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
+ {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
{0x0054 /* 'T' */, 0x0043 /* 'C' */, 0x006F /* 'o' */, 0x006D /* 'm' */, 0x0070 /* 'p' */, 0x0061 /* 'a' */, 0x0072 /* 'r' */, 0x0065 /* 'e' */, 0x0050 /* 'P' */, 0x006C /* 'l' */, 0x0061 /* 'a' */, 0x0069 /* 'i' */, 0x006E /* 'n' */},
{0x0061 /* 'a' */, 0x0042 /* 'B' */, 0x0063 /* 'c' */},
{0x0061 /* 'a' */, 0x0023 /* '#' */, 0x0042 /* 'B' */},
{0x00C4, 0x0062 /* 'b' */, 0x0063 /* 'c' */, 0x0064 /* 'd' */, 0x0061 /* 'a' */},
{0x00E4, 0x0062 /* 'b' */, 0x0063 /* 'c' */, 0x0064 /* 'd' */, 0x0061 /* 'a' */},
{0x00C4, 0x0062 /* 'b' */, 0x0063 /* 'c' */, 0x0064 /* 'd' */, 0x0061 /* 'a' */},
- {0x00C4, 0x0062 /* 'b' */, 0x0063 /* 'c' */, 0x0064 /* 'd' */, 0x0061 /* 'a' */},
+ {0x00C4, 0x0062 /* 'b' */, 0x0063 /* 'c' */, 0x0064 /* 'd' */, 0x0061 /* 'a' */},
{0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0023 /* '#' */, 0x0063 /* 'c' */},
{0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
{0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x003D /* '=' */, 0x0063 /* 'c' */},
{0x00E4, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
{0x0074 /* 't' */, 0x0068 /* 'h' */, 0x00EE, 0x0073 /* 's' */},
{0x0070 /* 'p' */, 0x00E9, 0x0063 /* 'c' */, 0x0068 /* 'h' */, 0x00E9},
- {0x0061 /* 'a' */, 0x0042 /* 'B' */, 0x0043 /* 'C' */},
+ {0x0061 /* 'a' */, 0x0042 /* 'B' */, 0x0043 /* 'C' */},
{0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0064 /* 'd' */},
{0x00E4, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
{0x0061 /* 'a' */, 0x00C6, 0x0063 /* 'c' */},
{0x00E4, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
{0x0061 /* 'a' */, 0x00C6, 0x0063 /* 'c' */},
{0x0061 /* 'a' */, 0x0042 /* 'B' */, 0x0064 /* 'd' */},
- {0x00E4, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
+ {0x00E4, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
{0x0070 /* 'p' */, 0x00EA, 0x0063 /* 'c' */, 0x0068 /* 'h' */, 0x0065 /* 'e' */}
}; // 49
private static int[] results = {
//-1:LESS; 0:EQUAL; 1:GREATER
- -1,
+ -1,
-1, /*Collator::GREATER,*/
-1,
1,
-1,
0,
-1,
- -1,
+ -1,
-1 // 49
};
{ 0x0152},
{0x006F /* 'o' */, 0x0066 /* 'f' */},
};
-
+
private Collator myCollation = null;
-
+
public CollationEnglishTest() {
}
-
+
@Before
public void init()throws Exception {
myCollation = Collator.getInstance(Locale.ENGLISH);
}
-
+
//performs test with strength PRIMARY
@Test
public void TestPrimary() {
myCollation.setStrength(Collator.PRIMARY);
for (i = 38; i < 43 ; i++) {
doTest(testSourceCases[i], testTargetCases[i], results[i]);
- }
+ }
}
-
+
//perform test with strength SECONDARY
@Test
public void TestSecondary() {
}
}
}
-
+
//perform test with strength TERTIARY
@Test
public void TestTertiary() {
for (i = 0; i < 38 ; i++)
{
doTest(testSourceCases[i], testTargetCases[i], results[i]);
- }
+ }
int j = 0;
for (i = 0; i < 10; i++)
}
}
}
-
+
// main test routine, tests rules defined by the "en" 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);
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)
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);
} else {
errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect);
}
-
+
msg1 = ok2 ? "Ok: key(\"" : "FAIL: key(\"";
msg2 = "\").compareTo(key(\"";
msg3 = "\")) returned ";
msg2 = " vs. ";
errln(msg1 + CollationTest.prettify(sourceKey) + msg2 + CollationTest.prettify(targetKey));
}
-
+
msg1 = ok3 ? "Ok: incCompare(\"" : "FAIL: incCompare(\"";
msg2 = "\", \"";
msg3 = "\") returned ";
logln(msg1 + source + msg2 + target + msg3 + sResult);
} else {
errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect);
- }
+ }
}
}
}
*******************************************************************************
*/
-/**
+/**
* 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},
};
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() {
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);
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) {
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);
} else {
errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect);
}
-
+
msg1 = ok2 ? "Ok: key(\"" : "FAIL: key(\"";
msg2 = "\").compareTo(key(\"";
msg3 = "\")) returned ";
msg2 = " vs. ";
errln(msg1 + CollationTest.prettify(sourceKey) + msg2 + CollationTest.prettify(targetKey));
}
-
+
msg1 = ok3 ? "Ok: incCompare(\"" : "FAIL: incCompare(\"";
msg2 = "\", \"";
msg3 = "\") returned ";
logln(msg1 + source + msg2 + target + msg3 + sResult);
} else {
errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect);
- }
+ }
}
}
}
*******************************************************************************
*/
-/**
+/**
* 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'*/},
/*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},
{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() {
int expected;
myCollation.setStrength(Collator.SECONDARY);
-
+
for (i = 0; i < testAcute.length; i++) {
for (j = 0; j < testAcute.length; j++) {
if (i < j) {
}
}
}
-
+
@Test
public void TestContinuationReordering()
{
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");
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);
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) {
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);
} else {
errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect);
}
-
+
msg1 = ok2 ? "Ok: key(\"" : "FAIL: key(\"";
msg2 = "\").compareTo(key(\"";
msg3 = "\")) returned ";
msg2 = " vs. ";
errln(msg1 + CollationTest.prettify(sourceKey) + msg2 + CollationTest.prettify(targetKey));
}
-
+
msg1 = ok3 ? "Ok: incCompare(\"" : "FAIL: incCompare(\"";
msg2 = "\", \"";
msg3 = "\") returned ";
logln(msg1 + source + msg2 + target + msg3 + sResult);
} else {
errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect);
- }
+ }
}
}
-}
+}
*******************************************************************************
*/
-/**
+/**
* Port From: ICU4C v2.1 : collate/CollationMonkeyTest
* Source File: $ICU4CRoot/source/test/intltest/mnkytst.cpp
**/
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;
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) {
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();
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();
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);
msg += ") Failed.";
errln(msg);
}
-
+
msg = "";
result = collationKey2.compareTo(collationKey1);
if (result != 1) {
errln(msg);
}
}
-
+
// perform monkey tests using Collator.compare
@Test
public void TestCompare() {
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();
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();
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 : ";
msg += " Failed.";
errln(msg);
}
-
+
msg = "";
result = myPrimaryCollator.compare(addOne, subs);
if (result != 1) {
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"));
warnln( "Demo Test 1 Table Collation object creation failed.");
return;
}
-
+
for(i=0; i<2; i++){
doTest(myCollation, testSourceCases[i], testTargetCases[i], -1);
}
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);
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) {
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 = "\", \"";
logln(msg1 + src + msg2 + target + msg3 + sResult);
} else {
errln(msg1 + src + msg2 + target + msg3 + sResult + msg4 + sExpect);
- }
+ }
}
}
}
*******************************************************************************
*/
-/**
+/**
* 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},
{ -1, -1 },
{ 0, 1 }
};
-
+
private Collator myCollation = null;
-
+
public CollationGermanTest() {
}
-
+
@Before
public void init() throws Exception {
myCollation = Collator.getInstance(Locale.GERMAN);
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(){
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);
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)
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);
} else {
errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect);
}
-
+
msg1 = ok2 ? "Ok: key(\"" : "FAIL: key(\"";
msg2 = "\").compareTo(key(\"";
msg3 = "\")) returned ";
msg2 = " vs. ";
errln(msg1 + CollationTest.prettify(sourceKey) + msg2 + CollationTest.prettify(targetKey));
}
-
+
msg1 = ok3 ? "Ok: incCompare(\"" : "FAIL: incCompare(\"";
msg2 = "\", \"";
msg3 = "\") returned ";
logln(msg1 + source + msg2 + target + msg3 + sResult);
} else {
errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect);
- }
+ }
}
}
}
*******************************************************************************
*/
-/**
+/**
* Port From: ICU4C v2.1 : collate/CollationIteratorTest
* Source File: $ICU4CRoot/source/test/intltest/itercoll.cpp
**/
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;
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
*/
warnln("Couldn't create a RuleBasedCollator.");
return;
}
-
+
String source = "abcd";
CollationElementIterator i = c.getCollationElementIterator(source);
int e0 = 0;
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
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()
*/
}
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");
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");
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");
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");
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");
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()
*/
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;
}
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;
}
// TODO: try iterating halfway through a messy string.
}
-
-
+
+
void assertEqual(CollationElementIterator i1, CollationElementIterator i2) {
int c1, c2, count = 0;
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;
}
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;
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 {
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 {
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 {
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 {
return;
}
iter = ((RuleBasedCollator)c5).getCollationElementIterator(source);
-
+
CollationTest.backAndForth(this, iter);
}
-
-
-
+
+
+
/**
* Test for setText()
*/
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();
break;
}
}
-
+
// Now set it to point to the same string as the first iterator
try {
iter2.setText(test1);
return;
}
assertEqual(iter1, iter2);
-
+
iter1.reset();
//now use the overloaded setText(ChracterIterator&, UErrorCode) function to set the text
CharacterIterator chariter = new StringCharacterIterator(test1);
return;
}
assertEqual(iter1, iter2);
-
+
iter1.reset();
//now use the overloaded setText(ChracterIterator&, UErrorCode) function to set the text
UCharacterIterator uchariter = UCharacterIterator.getInstance(test1);
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());
}
codepoint ++;
}
-
+
if (UCharacter.isDefined(codepoint)) {
source.append(codepoint);
}
-
+
if (codepoint != 0xFFFF) {
codepoint ++;
}
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.
}
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;) {
}
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",
// 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
// 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;
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;
}
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]);
" \u00E6" + // small letter ae, expands
" \u1E4D" + // small letter o with tilde and acute, decomposes
" ";
-
+
int[] rootStandardOffsets = {
0, 1,2,
2, 3,4,4,
28,
29
};
-
+
int[] rootSearchOffsets = {
0, 1,2,
2, 3,4,4,
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 ),
};
*******************************************************************************
*/
-/**
+/**
* 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},
/*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);
}
}
public void TestTertiary() {
int i = 0;
myCollation.setStrength(Collator.TERTIARY);
-
+
for (i = 0; i < 6; i++) {
doTest(testSourceCases[i], testTargetCases[i], results[i]);
}
}
}
- /*
+ /*
* Test Small, Large letters
*/
@Test
doTest(testChooonKigooCases[i], testChooonKigooCases[i + 1], -1);
}
}
-
+
/*
* Test common Hiragana and Katakana characters (e.g. 0x3099) (ticket:6140)
*/
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);
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) {
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);
} else {
errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect);
}
-
+
msg1 = ok2 ? "Ok: key(\"" : "FAIL: key(\"";
msg2 = "\").compareTo(key(\"";
msg3 = "\")) returned ";
msg2 = " vs. ";
errln(msg1 + CollationTest.prettify(sourceKey) + msg2 + CollationTest.prettify(targetKey));
}
-
+
msg1 = ok3 ? "Ok: incCompare(\"" : "FAIL: incCompare(\"";
msg2 = "\", \"";
msg3 = "\") returned ";
logln(msg1 + source + msg2 + target + msg3 + sResult);
} else {
errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect);
- }
+ }
}
}
}
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;
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
*******************************************************************************
*/
-/**
+/**
* Port From: ICU4C v2.1 : collate/CollationMonkeyTest
* Source File: $ICU4CRoot/source/test/intltest/mnkytst.cpp
**/
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;
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) {
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();
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);
msg += ") Failed.";
errln(msg);
}
-
+
msg = "";
result = collationKey2.compareTo(collationKey1);
if (result != 1) {
errln(msg);
}
}
-
+
// perform monkey tests using Collator.compare
@Test
public void TestCompare() {
errln("CollationMonkeyTest.TestCompare(): source is empty - ICU_DATA not set or data missing?");
return;
}
-
+
Collator myCollator;
try {
myCollator = Collator.getInstance(new Locale("en", "US"));
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();
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 : ";
msg += " Failed.";
errln(msg);
}
-
+
msg = "";
result = myCollator.compare(addOne, subs);
if (result != 1) {
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"));
warnln( "Demo Test 1 Table Collation object creation failed.");
return;
}
-
+
for(i=0; i<2; i++){
doTest(myCollation, testSourceCases[i], testTargetCases[i], -1);
}
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);
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) {
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 = "\", \"";
logln(msg1 + src + msg2 + target + msg3 + sResult);
} else {
errln(msg1 + src + msg2 + target + msg3 + sResult + msg4 + sExpect);
- }
+ }
}
}
}
*******************************************************************************
*/
-/**
+/**
* 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;
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;
import com.ibm.icu.text.Collator;
import com.ibm.icu.text.RuleBasedCollator;
+@RunWith(JUnit4.class)
public class CollationRegressionTest extends TestFmwk {
// @bug 4048446
//
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);
count += 1;
} while (c1 != CollationElementIterator.NULLORDER);
}
-
+
// @bug 4051866
//
// Collator -> rules -> Collator round-trip broken for expanding characters
// 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 {
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"
errln("black-bird == black");
}
}
-
+
// @bug 4054238
//
// CollationElementIterator will not work correctly if the associated
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(">")) {
} else {
errln("Bogus comparison string \"" + comparison + "\"");
}
-
+
int compareResult = 0;
-
+
logln("i = " + i);
logln(source);
logln(target);
} catch (Exception e) {
errln(e.toString());
}
-
+
CollationKey sourceKey = null, targetKey = null;
try {
sourceKey = c.getCollationKey(source);
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)
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);
} else {
errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect);
}
-
+
msg1 = ok2 ? "Ok: key(\"" : "FAIL: key(\"";
msg2 = "\").compareTo(key(\"";
msg3 = "\")) returned ";
msg2 = " vs. ";
errln(msg1 + CollationTest.prettify(sourceKey) + msg2 + CollationTest.prettify(targetKey));
}
-
+
msg1 = ok3 ? "Ok: incCompare(\"" : "FAIL: incCompare(\"";
msg2 = "\", \"";
msg3 = "\") returned ";
logln(msg1 + source + msg2 + target + msg3 + sResult);
} else {
errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect);
- }
+ }
}
}
@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
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"
@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);
errln("failure building collator:" + e);
return;
}
-
+
c.setDecomposition(Collator.NO_DECOMPOSITION);
-
+
String[] tertiary = {
"A", "<", "B",
"H", "<", "\u0131",
"\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
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
errln("'abcd e' == 'abcd f'");
}
}
-
+
// @bug 4066189
//
// Unicode characters need to be recursively decomposed to get the
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
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
// 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");
}
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)) {
errln("en_us.equals(null) threw " + e.toString());
}
}
-
+
// @bug 4081866
//
// Combining characters in different classes not reordered properly.
// 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
errln("Combining chars were not reordered");
}
}
-
+
// @bug 4087241
//
// string comparison errors in Scandinavian collators
};
compareArray(c, tests);
}
-
+
// @bug 4087243
//
// CollationKey takes ignorable strings into account when it shouldn't
};
compareArray(c, tests);
}
-
+
// @bug 4092260
//
// Mu/micro conflict
};
compareArray(c, tests);
}
-
+
// @bug 4095316
//
@Test
};
compareArray(c, tests);
}
-
+
// @bug 4101940
//
@Test
errln("next did not return NULLORDER");
}
}
-
+
// @bug 4103436
//
// Collator::compare not handling spaces properly
};
compareArray(c, tests);
}
-
+
// @bug 4114076
//
// Collation not Unicode conformant with Hangul syllables
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
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- //
// @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 */) {
// -> 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
errln("CollationKey creation failed.");
}
}
-
+
// @bug 4132736
//
// sort order of french words with multiple accents has errors
} 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
"\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
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 */) {
// 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;
}
}
}
-
+
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
}
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);
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();
}
System.out.print(": ");
for(int i=0;i<bytes.length;i++) {
- sb.append(" 0x"+Integer.toHexString(((int)bytes[i])&0xff));
+ sb.append(" 0x"+Integer.toHexString((bytes[i])&0xff));
}
sb.append("\n");
return sb;
//
// Use a custom collator class whose createCollationElementIterator
// methods increment a count....
- //
+ //
RuleBasedCollator en_us = (RuleBasedCollator) Collator.getInstance(Locale.US);
My4146160Collator.count = 0;
My4146160Collator mc = null;
errln("Failed to create a My4146160Collator.");
return;
}
-
+
CollationKey key = null;
try {
key = mc.getCollationKey("1");
errln("Failure to get a CollationKey from a My4146160Collator.");
return;
}
-
+
if (My4146160Collator.count < 1) {
errln("My4146160Collator.getCollationElementIterator not called for getCollationKey");
}
-
+
My4146160Collator.count = 0;
mc.compare("1", "2");
-
+
if (My4146160Collator.count < 1) {
errln("My4146160Collator.getCollationElementIterator not called for compare");
}
count += 1;
return super.getCollationElementIterator(text);
}
-
+
public CollationElementIterator getCollationElementIterator(java.text.CharacterIterator text) {
count += 1;
return super.getCollationElementIterator(text);
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;
import com.ibm.icu.text.Collator.CollatorFactory;
import com.ibm.icu.util.ULocale;
+@RunWith(JUnit4.class)
public class CollationServiceTest extends TestFmwk {
@Test
public void TestRegister() {
// register a singleton
Collator frcol = Collator.getInstance(ULocale.FRANCE);
Collator uscol = Collator.getInstance(ULocale.US);
-
+
{ // try override en_US collator
Object key = Collator.registerInstance(frcol, ULocale.US);
Collator ncol = Collator.getInstance(ULocale.US);
if (!frcol.equals(ncol)) {
errln("register of fr collator for fu_FU failed");
}
-
+
ULocale[] locales = Collator.getAvailableULocales();
boolean found = false;
for (int i = 0; i < locales.length; ++i) {
errln("found " + name + " for fu_FU");
}
}catch(MissingResourceException ex){
- warnln("Could not load locale data.");
+ warnln("Could not load locale data.");
}
try{
String name = Collator.getDisplayName(fu_FU, fu_FU);
errln("found " + name + " for fu_FU");
}
}catch(MissingResourceException ex){
- warnln("Could not load locale data.");
+ warnln("Could not load locale data.");
}
if (!Collator.unregister(key)) {
}
{
- // coverage after return to default
+ // coverage after return to default
ULocale[] locales = Collator.getAvailableULocales();
-
+
for (int i = 0; i < locales.length; ++i) {
if (locales[i].equals(fu_FU)) {
errln("new locale fu_FU not reported as supported locale");
class TestFactory extends CollatorFactory {
private Map map;
private Set ids;
-
+
TestFactory(CollatorInfo[] info) {
map = new HashMap();
for (int i = 0; i < info.length; ++i) {
}
}
+ @Override
public Collator createCollator(ULocale loc) {
CollatorInfo ci = (CollatorInfo)map.get(loc);
if (ci != null) {
return null;
}
+ @Override
public String getDisplayName(ULocale objectLocale, ULocale displayLocale) {
CollatorInfo ci = (CollatorInfo)map.get(objectLocale);
if (ci != null) {
return null;
}
+ @Override
public Set getSupportedLocaleIDs() {
if (ids == null) {
HashSet set = new HashSet();
return ids;
}
}
-
+
class TestFactoryWrapper extends CollatorFactory {
CollatorFactory delegate;
-
+
TestFactoryWrapper(CollatorFactory delegate) {
this.delegate = delegate;
}
-
+
+ @Override
public Collator createCollator(ULocale loc) {
return delegate.createCollator(loc);
}
-
+
// use CollatorFactory getDisplayName(ULocale, ULocale) for coverage
-
+
+ @Override
public Set getSupportedLocaleIDs() {
return delegate.getSupportedLocaleIDs();
}
Collator gecol = Collator.getInstance(ULocale.GERMANY);
Collator jpcol = Collator.getInstance(ULocale.JAPAN);
Collator fucol = Collator.getInstance(fu_FU);
-
+
CollatorInfo[] info = {
new CollatorInfo(ULocale.US, frcol, null),
new CollatorInfo(ULocale.FRANCE, gecol, null),
try{
factory = new TestFactory(info);
}catch(MissingResourceException ex){
- warnln("Could not load locale data.");
+ warnln("Could not load locale data.");
}
// coverage
{
try{
name = Collator.getDisplayName(fu_FU, fu_FU_FOO);
}catch(MissingResourceException ex){
- warnln("Could not load locale data.");
+ warnln("Could not load locale data.");
}
logln("*** default name: " + name);
Collator.unregister(key);
-
+
ULocale bar_BAR = new ULocale("bar_BAR");
Collator col = Collator.getInstance(bar_BAR);
ULocale valid = col.getLocale(ULocale.VALID_LOCALE);
}
int n1 = checkAvailable("before registerFactory");
-
+
{
Object key = Collator.registerFactory(factory);
-
+
int n2 = checkAvailable("after registerFactory");
-
+
Collator ncol = Collator.getInstance(ULocale.US);
if (!frcol.equals(ncol)) {
errln("frcoll for en_US failed");
if (!jpcol.equals(ncol)) {
errln("jpcol for fu_FU_FOO failed, got: " + ncol);
}
-
+
ULocale[] locales = Collator.getAvailableULocales();
boolean found = false;
for (int i = 0; i < locales.length; ++i) {
if (!found) {
errln("new locale fu_FU not reported as supported locale");
}
-
+
String name = Collator.getDisplayName(fu_FU);
if (!"little bunny Foo Foo".equals(name)) {
errln("found " + name + " for fu_FU");
int n3 = checkAvailable("after unregister");
assertTrue("register increases count", n2>n1);
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");
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"
};
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);
}
assertTrue("getFunctionalEquivalent(de).isAvailable==true",
isAvailable[0] == true);
-
+
equiv = Collator.getFunctionalEquivalent(KW[0],
new ULocale("de_DE"),
isAvailable);
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",
"en_US_VALLEYGIRL","root","f"
};
final int DATA_COUNT=(DATA.length/3);
-
+
for(int i=0;i<DATA_COUNT;i++) {
boolean isAvailable[] = new boolean[1];
ULocale input = new ULocale(DATA[(i*3)+0]);
// for (int i = 0; i < Collator.getKeywords().length; ++i) {
// ULocale base = Collator.getFunctionalEquivalent(keywords[i],locales[k]);
// String[] values = Collator.getKeywordValues(keywords[i]);
-// for (int j = 0; j < Collator.getKeywordValues(keywords[i]).length;++j) {
-// ULocale other = Collator.getFunctionalEquivalent(keywords[i],
+// for (int j = 0; j < Collator.getKeywordValues(keywords[i]).length;++j) {
+// ULocale other = Collator.getFunctionalEquivalent(keywords[i],
// new ULocale(locales[k] + "@" + keywords[i] + "=" + values[j]),
// isAvailable);
// if (isAvailable[0] && !other.equals(base)) {
errln("Keyword value " + expected[j] + " missing for locale: " + locale);
}
}
-
+
// Collator.getKeywordValues return the same contents for both commonlyUsed
// true and false.
String[] all = Collator.getKeywordValuesForLocale("collation", loc, false);
*******************************************************************************
*/
-/**
+/**
* Port From: ICU4C v2.1 : Collate/CollationSpanishTest
* Source File: $ICU4CRoot/source/test/intltest/escoll.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 CollationSpanishTest extends TestFmwk {
+
+@RunWith(JUnit4.class)
+public class CollationSpanishTest extends TestFmwk {
private static char[][] testSourceCases = {
{0x61, 0x6c, 0x69, 0x61, 0x73},
{0x45, 0x6c, 0x6c, 0x69, 0x6f, 0x74},
-1,
0
};
-
+
//static public Collator myCollation = Collator.getInstance(new Locale("es", "ES"));
-
+
private Collator myCollation = null;
-
+
public CollationSpanishTest() {
}
-
+
@Before
public void init() throws Exception {
myCollation = Collator.getInstance(new Locale("es", "ES"));
}
-
+
@Test
public void TestTertiary(){
int i = 0;
doTest(testSourceCases[i], testTargetCases[i], results[i]);
}
}
-
+
@Test
public void TestPrimary(){
int i;
doTest(testSourceCases[i], testTargetCases[i], results[i]);
}
}
-
+
// amin test routine, tests rules specific to the spanish locale
private void doTest(char[] source, char[] target, int result) {
String s = new String(source);
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) {
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);
} else {
errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect);
}
-
+
msg1 = ok2 ? "Ok: key(\"" : "FAIL: key(\"";
msg2 = "\").compareTo(key(\"";
msg3 = "\")) returned ";
msg2 = " vs. ";
errln(msg1 + CollationTest.prettify(sourceKey) + msg2 + CollationTest.prettify(targetKey));
}
-
+
msg1 = ok3 ? "Ok: incCompare(\"" : "FAIL: incCompare(\"";
msg2 = "\", \"";
msg3 = "\") returned ";
logln(msg1 + source + msg2 + target + msg3 + sResult);
} else {
errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect);
- }
+ }
}
}
}
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;
import com.ibm.icu.util.Output;
import com.ibm.icu.util.ULocale;
+@RunWith(JUnit4.class)
public class CollationTest extends TestFmwk {
public CollationTest() {
}
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);
}
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) {
}
orders[size++] = order;
}
-
+
if (maxSize > size) {
int[] temp = new int[size];
System.arraycopy(orders, 0, temp, 0, size);
}
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) {
} 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) {
TestFmwk.errln("");
}
}
-
+
static final String appendCompareResult(int result, String target){
if (result == -1) {
target += "LESS";
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) {
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 \""
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();
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);
}
}
final String s = "\uFFFE\uFFFF";
long[] ces;
-
+
ces = rbc.internalGetCEs(s);
if (ces.length != 2) {
errln("expected 2 CEs for <FFFE, FFFF>, got " + ces.length);
}
}
-
+
// ICU4C: TestIllegalUTF8 / not applicable to ICU4J
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;
*******************************************************************************
*/
-/**
+/**
* 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;
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.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
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();
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;
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
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",
"\u0E44\u0E44\u0E01\u0E01",
"\u0E01\u0E44\u0E44\u0E01",
};
-
+
RuleBasedCollator collator;
StrCmp comparator;
try {
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
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 {
}
// private inner class -------------------------------------------------
-
- private static final class StrCmp implements Comparator<String>
+
+ private static final class StrCmp implements Comparator<String>
{
- 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) {
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 {
this.r = r;
}
+ @Override
public void run() {
try {
synchronized (control) {
*******************************************************************************
*/
-/**
+/**
* 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},
-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;
doTest(testSourceCases[i], testTargetCases[i], results[i]);
}
}
-
+
@Test
public void TestPrimary() {
int i;
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);
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) {
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);
} else {
errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect);
}
-
+
msg1 = ok2 ? "Ok: key(\"" : "FAIL: key(\"";
msg2 = "\").compareTo(key(\"";
msg3 = "\")) returned ";
msg2 = " vs. ";
errln(msg1 + CollationTest.prettify(sourceKey) + msg2 + CollationTest.prettify(targetKey));
}
-
+
msg1 = ok3 ? "Ok: incCompare(\"" : "FAIL: incCompare(\"";
msg2 = "\", \"";
msg3 = "\") returned ";
logln(msg1 + source + msg2 + target + msg3 + sResult);
} else {
errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect);
- }
+ }
}
}
}
*******************************************************************************
*/
-/**
+/**
* 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 */
{ 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 */
/* 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++) {
}
}
}
-
+
// 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++) {
}
}
}
-
- // 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++) {
}
}
}
-
- // 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++) {
}
}
}
-
+
@Test
public void TestG7Data() {
Locale locales[] = {
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) {
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);
} else {
errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect);
}
-
+
msg1 = ok2 ? "Ok: key(\"" : "FAIL: key(\"";
msg2 = "\").compareTo(key(\"";
msg3 = "\")) returned ";
msg2 = " vs. ";
errln(msg1 + CollationTest.prettify(sourceKey) + msg2 + CollationTest.prettify(targetKey));
}
-
+
msg1 = ok3 ? "Ok: incCompare(\"" : "FAIL: incCompare(\"";
msg2 = "\", \"";
msg3 = "\") returned ";
logln(msg1 + source + msg2 + target + msg3 + sResult);
} else {
errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect);
- }
+ }
}
}
}
*******************************************************************************
*/
-/**
+/**
* 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() {
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);
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,
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);
} else {
errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect);
}
-
+
msg1 = ok2 ? "Ok: key(\"" : "FAIL: key(\"";
msg2 = "\").compareTo(key(\"";
msg3 = "\")) returned ";
msg2 = " vs. ";
errln(msg1 + CollationTest.prettify(sourceKey) + msg2 + CollationTest.prettify(targetKey));
}
-
+
msg1 = ok3 ? "Ok: incCompare(\"" : "FAIL: incCompare(\"";
msg2 = "\", \"";
msg3 = "\") returned ";
logln(msg1 + source + msg2 + target + msg3 + sResult);
} else {
errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect);
- }
+ }
}
}
}
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;
import com.ibm.icu.util.ULocale;
import com.ibm.icu.util.VersionInfo;
+@RunWith(JUnit4.class)
public class UCAConformanceTest extends TestFmwk {
public UCAConformanceTest() {
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;
import com.ibm.icu.util.TimeZone;
import com.ibm.icu.util.ULocale;
-
-
+@RunWith(JUnit4.class)
public class GlobalizationPreferencesTest extends TestFmwk {
@Test
public void TestDefault() {
// 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
if (gpLocale2 != null) {
errln("FAIL: Number of locales must be 2");
}
-
+
// Calendar locale
Calendar cal = gp.getCalendar();
ULocale calLocale = cal.getLocale(ULocale.VALID_LOCALE);
GlobalizationPreferences gp = new GlobalizationPreferences();
if (gp.isFrozen()) {
errln("FAIL: This object is not yet frozen");
- }
+ }
logln("Call reset()");
boolean bSet = true;
if (bSet) {
errln("FAIL: setLocale(ULocale) must be blocked after frozen");
}
-
+
// setTerritory(String)
logln("Call setTerritory(String) after frozen");
bSet = true;
// 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");
}
if (!bSet) {
errln("FAIL: setLocales(ULocale) must not throw an exception before frozen");
- }
+ }
}
static String[][] INPUT_LOCALEIDS = {
sb.append(localeStrings[j]);
}
logln("Input locales: " + sb.toString());
-
+
gp.reset();
gp.setLocales(locales);
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());
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];
sb.append(localeStrings[j]);
}
logln("Input locales: " + sb.toString());
-
+
gp.reset();
gp.setLocales(localeArray);
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());
errln("FAIL: Locale index(" + j + ") does not match - GP:" + loc.toString()
+ " Expected:" + RESULTS_LOCALEIDS[i][j]);
}
- }
+ }
}
}
for (int i = 0; i < ACCEPT_LANGUAGES.length; i++) {
String acceptLanguage = ACCEPT_LANGUAGES[i];
logln("Accept language: " + acceptLanguage);
-
+
gp.reset();
gp.setLocales(acceptLanguage);
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());
errln("FAIL: Locale index(" + j + ") does not match - GP:" + loc.toString()
+ " Expected:" + RESULTS_LOCALEIDS[i][j]);
}
- }
+ }
}
}
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"));
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];
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");
// Freeze
logln("Freeze this object");
gp.freeze();
-
+
boolean bFrozen = false;
try {
gp.setTerritory("FR");
}
// 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");
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);
// Safe clone
logln("cloneAsThawed");
- GlobalizationPreferences gp1 = (GlobalizationPreferences)gp.cloneAsThawed();
+ GlobalizationPreferences gp1 = gp.cloneAsThawed();
cur = gp.getCurrency();
code = cur.getCurrencyCode();
if (!code.equals("BRL")) {
// Safe clone
logln("cloneAsThawed");
- GlobalizationPreferences gp1 = (GlobalizationPreferences)gp.cloneAsThawed();
+ GlobalizationPreferences gp1 = gp.cloneAsThawed();
cal = gp.getCalendar();
calType = cal.getType();
if (!calType.equals("japanese")) {
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();
// Modifiable clone
logln("cloneAsThawed");
- GlobalizationPreferences gp1 = (GlobalizationPreferences)gp.cloneAsThawed();
+ GlobalizationPreferences gp1 = gp.cloneAsThawed();
tz = gp1.getTimeZone();
tzid = tz.getID();
if (!tzid.equals(customJstId)) {
tzid = tz.getID();
if (!tzid.equals(cst.getID())) {
errln("FAIL: Time zone ID is " + tzid + " Expected: " + cst.getID());
- }
+ }
}
@Test
// 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")) {
// 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();
// 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();
// 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)) {
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"));
if (!illegalArg) {
errln("FAIL: getNumberFormat must throw IllegalArgumentException for type -1");
}
-
+
// Set explicit territory
logln("Set territory - US");
gp.setTerritory("US");
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");
}
// 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);
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;
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();
if (r == null) {
r = createRandom();
}
- n = ((int)(r.nextInt(10000) - 3000)) / 16d;
+ n = (r.nextInt(10000) - 3000) / 16d;
}
String s = fmt.format(n);
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.StringSearch;
import com.ibm.icu.util.ULocale;
+@RunWith(JUnit4.class)
public class SearchTest extends TestFmwk {
//inner class
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;
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";
@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");
}
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")},
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;
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);
}
}
@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<ULocale> list = new LinkedHashSet<ULocale>();
- List<UiListItem> expected = new ArrayList<UiListItem>();
- 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<UiListItem> 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<ULocale> list = new LinkedHashSet<ULocale>();
+ List<UiListItem> expected = new ArrayList<UiListItem>();
+ 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<UiListItem> 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<ULocale> supported = Collections.singleton(new ULocale(malformed));
assertNull("Failed to detect bogus locale «" + malformed + "»", supported);
} catch (IllformedLocaleException e) {
logln("Successfully detected ill-formed locale «" + malformed + "»:" + e.getMessage());
- }
+ }
}
}
}
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;
* 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() {}
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;
* @author Lina Kemmel
*
*/
+@RunWith(JUnit4.class)
public class TestBidiTransform extends TestFmwk {
static final char LATN_ZERO = '\u0030';
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;
* @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;
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;
// 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;
// astro.setDate(cal3.getTime());
// astro.foo();
}
-
+
@Test
public void TestMoonAge(){
GregorianCalendar gc = new GregorianCalendar(new SimpleTimeZone(0,"GMT"));
{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}
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;
* 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",
* 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;
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 = {
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.
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
//
// 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();
}
}
}
-
+
static public final boolean ROLL = true;
static public final boolean ADD = false;
-
+
/**
* Process test cases for <code>add</code> and <code>roll</code> methods.
* Each test case is an array of integers, as follows:
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];
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.
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.
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;
* 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.
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,
// ** 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),
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), //*
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; i<DATA.length; ++i) {
String s = fmt.format(DATA[i]);
try {
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
Calendar.DAY_OF_YEAR, 121,
END,
4,1,2, // Expect 4*-2
-
+
// I've disabled this test because it doesn't work this way,
// not even with a GregorianCalendar! MONTH alone isn't enough
// to supersede DAY_OF_YEAR. Some other month-related field is
//! Calendar.MONTH, 3,
//! END,
//! 4,1,1, // Expect 4*-1
-
+
// If we set IS_LEAP_MONTH last, that should take precedence
Calendar.MONTH, 3,
Calendar.DAY_OF_MONTH, 1,
{ 4638, 4,0, 30, MONTH, 2, 4638, 5,0, 30 }, // no dom pin
{ 4638, 4,0, 30, MONTH, 3, 4638, 6,0, 29 }, // dom should pin
};
-
+
ChineseCalendar cal = new ChineseCalendar();
doRollAdd(ADD, cal, tests);
}
{ 4638, 4,0, 30, MONTH, 15, 4638, 5,0, 30 }, // no dom pin
{ 4638, 4,0, 30, MONTH, -10, 4638, 6,0, 29 }, // dom should pin
};
-
+
ChineseCalendar cal = new ChineseCalendar();
doRollAdd(ROLL, cal, tests);
}
-
+
void doRollAdd(boolean roll, ChineseCalendar cal, int[][] tests) {
String name = roll ? "rolling" : "adding";
-
+
for (int i = 0; i < tests.length; i++) {
int[] test = tests[i];
errln("could not create ChineseCalendar with ULocale");
}
}
-
+
{
// new ChineseCalendar(TimeZone)
- ChineseCalendar cal = new ChineseCalendar(TimeZone.getDefault());
+ ChineseCalendar cal = new ChineseCalendar(TimeZone.getDefault());
if(cal == null){
errln("could not create ChineseCalendar with TimeZone");
}
// 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...
ChineseCalendar cc = new ChineseCalendar();
cc.set(Calendar.YEAR, 22);
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();
}
@Test
- public void Test6510()
- {
- Calendar gregorianCalendar;
- ChineseCalendar chineseCalendar, chineseCalendar2;
- ChineseDateFormat dateFormat;
- SimpleDateFormat simpleDateFormat;
-
- simpleDateFormat = new com.ibm.icu.text.SimpleDateFormat("MM/dd/yyyy G 'at' HH:mm:ss vvvv", Locale.US);
- dateFormat = new com.ibm.icu.text.ChineseDateFormat("MM/dd/yyyy(G) HH:mm:ss", Locale.CHINA);
-
- // lunar to gregorian
- chineseCalendar = new ChineseCalendar(77, 26, Calendar.JANUARY, 0, 6, 0, 0, 0);
+ public void Test6510()
+ {
+ Calendar gregorianCalendar;
+ ChineseCalendar chineseCalendar, chineseCalendar2;
+ ChineseDateFormat dateFormat;
+ SimpleDateFormat simpleDateFormat;
+
+ simpleDateFormat = new com.ibm.icu.text.SimpleDateFormat("MM/dd/yyyy G 'at' HH:mm:ss vvvv", Locale.US);
+ dateFormat = new com.ibm.icu.text.ChineseDateFormat("MM/dd/yyyy(G) HH:mm:ss", Locale.CHINA);
+
+ // lunar to gregorian
+ chineseCalendar = new ChineseCalendar(77, 26, Calendar.JANUARY, 0, 6, 0, 0, 0);
// coverage
assertEquals("equivalent ChineseCalendar() constructors", chineseCalendar,
new ChineseCalendar(77, 26, Calendar.JANUARY, 0, 6));
- gregorianCalendar = Calendar.getInstance(Locale.US);
- gregorianCalendar.setTime(chineseCalendar.getTime());
-
- // gregorian to lunar
- chineseCalendar2 = new ChineseCalendar();
- chineseCalendar2.setTimeInMillis(gregorianCalendar.getTimeInMillis());
-
- // validate roundtrip
- if (chineseCalendar.getTimeInMillis() != chineseCalendar2.getTimeInMillis())
- {
- errln("time1: " + chineseCalendar.getTimeInMillis());
- errln("time2: " + chineseCalendar2.getTimeInMillis());
- errln("Lunar [MM/dd/y(G) HH:mm:ss] " + dateFormat.format(chineseCalendar));
- errln("**PROBLEM Grego [MM/dd/y(G) HH:mm:ss] " + simpleDateFormat.format(gregorianCalendar));
- errln("Grego [MM/dd/y(G) HH:mm:ss] " + simpleDateFormat.format(gregorianCalendar));
- errln("Lunar [MM/dd/y(G) HH:mm:ss] " + dateFormat.format(chineseCalendar2));
- }
- }
+ gregorianCalendar = Calendar.getInstance(Locale.US);
+ gregorianCalendar.setTime(chineseCalendar.getTime());
+
+ // gregorian to lunar
+ chineseCalendar2 = new ChineseCalendar();
+ chineseCalendar2.setTimeInMillis(gregorianCalendar.getTimeInMillis());
+
+ // validate roundtrip
+ if (chineseCalendar.getTimeInMillis() != chineseCalendar2.getTimeInMillis())
+ {
+ errln("time1: " + chineseCalendar.getTimeInMillis());
+ errln("time2: " + chineseCalendar2.getTimeInMillis());
+ errln("Lunar [MM/dd/y(G) HH:mm:ss] " + dateFormat.format(chineseCalendar));
+ errln("**PROBLEM Grego [MM/dd/y(G) HH:mm:ss] " + simpleDateFormat.format(gregorianCalendar));
+ errln("Grego [MM/dd/y(G) HH:mm:ss] " + simpleDateFormat.format(gregorianCalendar));
+ errln("Lunar [MM/dd/y(G) HH:mm:ss] " + dateFormat.format(chineseCalendar2));
+ }
+ }
}
package com.ibm.icu.dev.test.calendar;
import java.util.Date;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
import com.ibm.icu.util.Calendar;
+@RunWith(JUnit4.class)
public class ChineseTestCase extends TestCase {
/**
boolean isLeapMonth, int dayOfMonth, int dayOfWeek) {
setTime(new Date(JULIAN_EPOCH + (long)(ONE_DAY * julian)));
-
+
set(Calendar.ERA, era);
set(Calendar.YEAR, year);
set(Calendar.MONTH, month - 1);
/**
* Return a String representation of this test case's time.
*/
+ @Override
public String toString() {
return dowToString(get(Calendar.DAY_OF_WEEK)) +
get(Calendar.YEAR) + "of" + get(Calendar.ERA) +
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.util.Calendar;
import com.ibm.icu.util.GregorianCalendar;
import com.ibm.icu.util.SimpleTimeZone;
import com.ibm.icu.util.TimeZone;
-public class CompatibilityTest extends com.ibm.icu.dev.test.TestFmwk {
+@RunWith(JUnit4.class)
+public class CompatibilityTest extends TestFmwk {
static final String[] FIELD_NAME = {
"ERA", "YEAR", "MONTH", "WEEK_OF_YEAR", "WEEK_OF_MONTH",
"DAY_OF_MONTH", "DAY_OF_YEAR", "DAY_OF_WEEK",
*/
@Test
public void TestGregorianChangeover() {
-
+
java.util.TimeZone jdkGMT = java.util.TimeZone.getTimeZone("GMT");
java.util.Calendar jdkCal = java.util.Calendar.getInstance(jdkGMT);
jdkCal.clear();
jdkCal.set(1582, Calendar.OCTOBER, 15);
-
+
// if(jdkCal instanceof java.util.GregorianCalendar) {
// logln("jdk IS grego");
// java.util.GregorianCalendar jdkgc = (java.util.GregorianCalendar)
final long ONE_DAY = 24*60*60*1000L;
int[] DATA = {
// Julian# Year Month DOM JULIAN:Year, Month, DOM
- 2440588, 1970, Calendar.JANUARY, 1, 1969, Calendar.DECEMBER, 19,
+ 2440588, 1970, Calendar.JANUARY, 1, 1969, Calendar.DECEMBER, 19,
2415080, 1900, Calendar.MARCH, 1, 1900, Calendar.FEBRUARY, 17,
2451604, 2000, Calendar.FEBRUARY, 29, 2000, Calendar.FEBRUARY, 16,
2452269, 2001, Calendar.DECEMBER, 25, 2001, Calendar.DECEMBER, 12,
if (delta != 0 || year != year2 || month != month2 ||
dom != dom2) errln(s + " FAIL");
else logln(s);
-
+
// Test Julian computation
year = DATA[i+4];
month = DATA[i+5];
int tzoffset = 123400;
SimpleTimeZone zone = new SimpleTimeZone(tzoffset, tzid);
- Calendar cal = (Calendar)Calendar.getInstance((SimpleTimeZone)zone.clone());
+ Calendar cal = Calendar.getInstance((SimpleTimeZone)zone.clone());
if (!zone.equals(cal.getTimeZone())) errln("FAIL: Calendar.getTimeZone failed");
cal.after(cal2)) errln("FAIL: equals/before/after failed");
// Roll back to January
- cal.roll(Calendar.MONTH, (int)(1 + Calendar.DECEMBER - cal.get(Calendar.MONTH)));
+ cal.roll(Calendar.MONTH, 1 + Calendar.DECEMBER - cal.get(Calendar.MONTH));
if (cal.equals(cal2) ||
cal2.before(cal) ||
cal.after(cal2)) errln("FAIL: equals/before/after failed");
public int getDay() { return day; }
public int getHour() { return hour; }
}
- final TransitionItem[] transitionItems = {
+ final TransitionItem[] transitionItems = {
new TransitionItem( "America/Caracas", 2007, Calendar.DECEMBER, 8, 10 ), // day before change in ZONE_OFFSET
new TransitionItem( "US/Pacific", 2011, Calendar.MARCH, 12, 10 ), // day before change in DST_OFFSET
};
// jb4406 is probably not a bug, this is to document the behavior
GregorianCalendar cal = new GregorianCalendar();
final int MILLIS_IN_DAY = 1000 * 60 * 60 * 24;
-
+
logln("julian day value jumps at changeover");
for (int day = 12; day < 18; ++day) {
cal.set(1582, 9, day);
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;
/**
* Tests for the <code>CopticCalendar</code> 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;
/* 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.
*/
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);
m == month &&
d == day)) {
errln("y: " + y +
- " m: " + m +
- " d: " + d +
+ " m: " + m +
+ " d: " + d +
" --> jd: " + jd +
" --> y: " + eyear +
" m: " + month +
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));
}
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");
}
errln("could not create CopticCalendar with ULocale");
}
}
-
+
{
// new CopticCalendar(Locale)
CopticCalendar cal = new CopticCalendar(Locale.getDefault());
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());
errln("could not create CopticCalendar with year,month,date,hour,minute,second");
}
}
-
+
{
// data
CopticCalendar cal = new CopticCalendar(1997, CopticCalendar.TOUT, 1);
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);
}
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;
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.
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,
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
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,
{ 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);
}
{ 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";
// 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);
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();
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;
/**
* Tests for the <code>EthiopicCalendar</code> 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;
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 },
{ 0001, MUHARRAM, 30, MONTH, 1, 0001, SAFAR, 29 },
{ 0002, HIJJAH, 30, YEAR, -1, 0001, HIJJAH, 29 },
};
-
+
EthiopicCalendar cal = newCivil();
doRollAdd(ROLL, cal, tests);
/* 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
* 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
* 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.
*/
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
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
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
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
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());
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);
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");
}
errln("could not create EthiopicCalendar with ULocale");
}
}
-
+
{
// new EthiopicCalendar(Locale)
EthiopicCalendar cal = new EthiopicCalendar(Locale.getDefault());
errln("could not create EthiopicCalendar with TimeZone,ULocale");
}
}
-
+
{
// new EthiopicCalendar(Date)
EthiopicCalendar cal = new EthiopicCalendar(new Date());
logln(cal.getTime().toString());
}
-
+
{
// data
EthiopicCalendar cal = new EthiopicCalendar(1997, EthiopicCalendar.MESKEREM, 1);
}
}
}
-
+
private static EthiopicCalendar newAmeteAlemEraCalendar() {
EthiopicCalendar alemawiCalendar = new EthiopicCalendar();
alemawiCalendar.setAmeteAlemEra(true);
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);
}
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;
/**
* Tests for the <code>HebrewCalendar</code> class.
*/
+@RunWith(JUnit4.class)
public class HebrewTest extends CalendarTestFmwk {
// Constants to save typing.
public static final int TISHRI = HebrewCalendar.TISHRI;
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 },
{ 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 },
};
// 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
{ 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");
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,
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());
}
// 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 +
" -> " +
}
}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
// 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)
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);
(cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.YEAR));
}
}
-
+
cal.clear();
cal.set(Calendar.YEAR, y);
cal.set(Calendar.MONTH, m + monthDelta - 1);
errln("could not create HebrewCalendar with TimeZone");
}
}
-
+
{
// new HebrewCalendar(ULocale)
HebrewCalendar cal = new HebrewCalendar(ULocale.getDefault());
errln("could not create HebrewCalendar with ULocale");
}
}
-
+
{
// new HebrewCalendar(Locale)
HebrewCalendar cal = new HebrewCalendar(Locale.getDefault());
errln("could not create HebrewCalendar with locale");
}
}
-
+
{
// new HebrewCalendar(Date)
HebrewCalendar cal = new HebrewCalendar(new Date());
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"
};
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);
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++) {
break;
}
}
- }
+ }
}
// Test case for Ticket#10313. HebrewCalendar requires
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;
/**
* Tests for the <code>Holiday</code> class.
*/
+@RunWith(JUnit4.class)
public class HolidayTest extends TestFmwk {
@Before
public void init() throws Exception {
now = new Date();
}
}
-
+
private Calendar cal;
private Date longTimeAgo;
private Date now;
// logln("rule: " + h.getRule().toString());
// h.setRule(h.getRule());
-
-
+
+
logln("HolidayCalendarDemo test");
{
final Calendar c = Calendar.getInstance(TimeZone.GMT_ZONE); // Temporary copy
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());
}
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 {
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();
logln("firstAfter: " + h);
}
}
-
+
@Test
public void TestDisplayName() {
Holiday[] holidays = Holiday.getHolidays(ULocale.US);
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;
/**
* @summary Tests of new functionality in IBMCalendar
*/
+@RunWith(JUnit4.class)
public class IBMCalendarTest extends CalendarTestFmwk {
/**
* Test weekend support in IBMCalendar.
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;
/**
* Tests for the <code>IndianCalendar</code> 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;
/** 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.
*/
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);
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));
}
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");
}
errln("could not create IndianCalendar with ULocale");
}
}
-
+
{
// new IndianCalendar(Locale)
IndianCalendar cal = new IndianCalendar(Locale.getDefault());
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());
errln("could not create IndianCalendar with year,month,date,hour,minute,second");
}
}
-
+
{
// data
String[] calendarLocales = {
doLimitsTest(indian, null, cal.getTime());
doTheoreticalLimitsTest(indian, true);
}
-
+
/**
* Problem reported by Bruno Haible <bruno.haible@de.ibm.com>
* -- see ticket 8419 -- http://bugs.icu-project.org/trac/ticket/8419
@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();
}
}
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;
/**
* Tests for the <code>IslamicCalendar</code> class.
*/
+@RunWith(JUnit4.class)
public class IslamicTest extends CalendarTestFmwk {
/** Constants to save typing. */
public static final int MUHARRAM = IslamicCalendar.MUHARRAM;
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 },
{ 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);
}
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);
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));
}
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();
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() {
{
errln("could not create IslamicCalendar with ULocale");
}
}
-
+
{
// new IslamicCalendar(Locale)
IslamicCalendar cal = new IslamicCalendar(Locale.getDefault());
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();
} else {
errln("wrong object type returned from getCalculationType");
}
-
+
Date now = new Date();
cal.setTime(now);
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"
};
civilCalendar.setCalculationType(CalculationType.ISLAMIC);
return civilCalendar;
}
-
+
private static IslamicCalendar newIslamicUmalqura() {
IslamicCalendar civilCalendar = new IslamicCalendar();
civilCalendar.setCalculationType(CalculationType.ISLAMIC_UMALQURA);
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);
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() {
/*/
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 {
} catch(IllegalArgumentException iae) {
errln("unexpected exception received!!!");
}
-
+
try {
tstCal.clear();
initMonth = 2;
} catch(IllegalArgumentException iae) {
// expected this
}
-
+
try {
tstCal.clear();
initMonth = 3;
} 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);
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();
}
}
}
-
+
@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);
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();
logln("getMillis: "+gotMillis);
}
}
-
+
tstCalendar.set(IslamicCalendar.SECOND, 0);
-
+
logln("setSecond=0: "+tstCalendar);
{
long gotMillis = tstCalendar.getTimeInMillis();
cnf.printStackTrace();
}
}
-
+
@Test
public void TestIslamicTabularDates() {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
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)
@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);
}
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;
/**
* Tests for the <code>JapaneseCalendar</code> class.
*/
+@RunWith(JUnit4.class)
public class JapaneseTest extends CalendarTestFmwk {
-
+
@Test
public void TestCoverage() {
{
}
}
}
-
+
@Test
public void Test3860()
{
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 {
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);
}
}
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() );
int fieldNum = expected[i+0];
int expectedVal = expected[i+1];
int actualVal = c.get(fieldNum);
-
+
if(expectedVal == actualVal) {
logln(FIELD_NAME[fieldNum]+": "+ actualVal);
} else {
}
}
}
-
+
@Test
public void Test5345calendar() {
logln("** testIncompleteCalendar()");
JapaneseCalendar c = new JapaneseCalendar(TimeZone.getDefault());
logln("test clear");
c.clear();
-
+
// Showa 45 = Gregorian 1970
int expected0[] = { Calendar.ERA, 234,
Calendar.YEAR, 45 };
logln("test setting era");
c.clear();
c.set(Calendar.ERA, JapaneseCalendar.MEIJI);
-
-
+
+
int expectedA[] = { Calendar.ERA, JapaneseCalendar.MEIJI };
checkExpected(c, expectedA);
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);
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.
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,
@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();
}
}
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;
/**
* @author andy
*/
+@RunWith(JUnit4.class)
public class TestCharsetDetector extends TestFmwk
{
public TestCharsetDetector()
}
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;
String [] charsetNames = CharsetDetector.getAllDetectableCharsets();
CheckAssert(charsetNames.length != 0);
for (i=0; i<charsetNames.length; i++) {
- CheckAssert(charsetNames[i].equals("") == false);
+ CheckAssert(charsetNames[i].equals("") == false);
// System.out.println("\"" + charsetNames[i] + "\"");
}
byte[] bytes = s.getBytes("ISO-8859-1");
CharsetDetector det = new CharsetDetector();
CharsetMatch m;
-
+
det.enableInputFilter(true);
if (!det.inputFilterEnabled()){
errln("input filter should be enabled");
}
-
+
det.setText(bytes);
m = det.detect();
-
+
if (! m.getLanguage().equals("fr")) {
errln("input filter did not strip markup!");
}
-
+
det.enableInputFilter(false);
det.setText(bytes);
m = det.detect();
-
+
if (! m.getLanguage().equals("en")) {
errln("unfiltered input did not detect as English!");
}
}
-
+
@Test
public void TestUTF8() throws Exception {
-
+
String s = "This is a string with some non-ascii characters that will " +
"be converted to UTF-8, then shoved through the detection process. " +
"\u0391\u0392\u0393\u0394\u0395" +
CharsetDetector det = new CharsetDetector();
String retrievedS;
Reader reader;
-
+
retrievedS = det.getString(bytes, "UTF-8");
CheckAssert(s.equals(retrievedS));
-
+
reader = det.getReader(new ByteArrayInputStream(bytes), "UTF-8");
try {
CheckAssert(s.equals(stringFromReader(reader)));
}
det.setDeclaredEncoding("UTF-8"); // Jitterbug 4451, for coverage
}
-
+
@Test
public void TestUTF16() throws Exception
{
- String source =
+ String source =
"u0623\u0648\u0631\u0648\u0628\u0627, \u0628\u0631\u0645\u062c\u064a\u0627\u062a " +
"\u0627\u0644\u062d\u0627\u0633\u0648\u0628 \u002b\u0020\u0627\u0646\u062a\u0631\u0646\u064a\u062a";
-
+
byte[] beBytes = source.getBytes("UnicodeBig");
byte[] leBytes = source.getBytes("UnicodeLittle");
CharsetDetector det = new CharsetDetector();
CharsetMatch m;
-
+
det.setText(beBytes);
m = det.detect();
-
+
if (! m.getName().equals("UTF-16BE")) {
errln("Encoding detection failure: expected UTF-16BE, got " + m.getName());
}
-
+
det.setText(leBytes);
m = det.detect();
-
+
if (! m.getName().equals("UTF-16LE")) {
errln("Encoding detection failure: expected UTF-16LE, got " + m.getName());
}
// Jitterbug 4451, for coverage
- int confidence = m.getConfidence();
+ int confidence = m.getConfidence();
if(confidence != 100){
errln("Did not get the expected confidence level " + confidence);
}
}
-
+
@Test
public void TestC1Bytes() throws Exception
{
String sISO =
"This is a small sample of some English text. Just enough to be sure that it detects correctly.";
-
+
String sWindows =
"This is another small sample of some English text. Just enough to be sure that it detects correctly. It also includes some \u201CC1\u201D bytes.";
byte[] bISO = sISO.getBytes("ISO-8859-1");
byte[] bWindows = sWindows.getBytes("windows-1252");
-
+
CharsetDetector det = new CharsetDetector();
CharsetMatch m;
-
+
det.setText(bWindows);
m = det.detect();
-
+
if (!m.getName().equals("windows-1252")) {
errln("Text with C1 bytes not correctly detected as windows-1252.");
return;
}
-
+
det.setText(bISO);
m = det.detect();
-
+
if (!m.getName().equals("ISO-8859-1")) {
errln("Text without C1 bytes not correctly detected as ISO-8859-1.");
}
}
-
+
@Test
public void TestShortInput() {
// Test that detection with very short byte strings does not crash and burn.
- // The shortest input that should produce positive detection result is two bytes,
+ // The shortest input that should produce positive detection result is two bytes,
// a UTF-16 BOM.
// TODO: Detector confidence levels needs to be refined for very short input.
// Too high now, for some charsets that happen to be compatible with a few bytes of input.
- byte [][] shortBytes = new byte [][]
+ byte [][] shortBytes = new byte [][]
{
{},
{(byte)0x0a},
{(byte)'A', (byte)'B', (byte)'C'},
{(byte)'A', (byte)'B', (byte)'C', (byte)'D'}
};
-
+
CharsetDetector det = new CharsetDetector();
CharsetMatch m;
for (int i=0; i<shortBytes.length; i++) {
logln("i=" + i + " -> " + m.getName());
}
}
-
+
@Test
public void TestBufferOverflow()
{
{(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",
null,
"ISO-8859-1"
};
-
+
CharsetDetector det = new CharsetDetector();
CharsetMatch match;
// Open and read the test data file.
//
//InputStreamReader isr = null;
-
+
try {
InputStream is = TestCharsetDetector.class.getResourceAsStream("CharsetDetectionTests.xml");
if (is == null) {
// 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 {
is.close();
}
Element root = doc.getDocumentElement();
-
+
NodeList testCases = root.getElementsByTagName("test-case");
-
+
// Process each test case
Map<String, byte[]> encToBytes = new TreeMap<String, byte[]>();
for (int n = 0; n < testCases.getLength(); n += 1) {
}
encToBytes.clear();
}
-
+
} catch (Exception e) {
errln("exception while processing test cases: " + e.toString());
}
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)
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) {
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;
m = det.detect();
charsetMatch = m.getName();
CheckAssert(charsetMatch.equals("EUC-JP"));
-
+
// Tests "public String getLanguage()"
CheckAssert(m.getLanguage().equals("ja"));
}
@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();
m = det.detect();
charsetMatch = m.getName();
CheckAssert(charsetMatch.equals("windows-1256"));
-
+
// Tests "public String getLanguage()"
CheckAssert(m.getLanguage().endsWith("ar"));
}
m = det.detect();
charsetMatch = m.getName();
CheckAssert(charsetMatch.equals("IBM420_rtl"));
-
+
// Tests "public String getLanguage()"
CheckAssert(m.getLanguage().endsWith("ar"));
}
@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"));
} catch (Exception ex) {
errln("Error getting string for charsetMatch: " + charsetMatch);
}
-
+
m = _testIBM424_he_ltr(s);
charsetMatch = m.getName();
CheckAssert(charsetMatch.equals("IBM424_ltr"));
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();
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();
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);
CharsetMatch m = det.detect();
return m;
}
-
+
/*
* Test the method int match(CharsetDetector det) in CharsetRecog_UTF_16_LE
*/
detector1.setText(data1);
CharsetMatch match1 = detector1.detect();
assertEquals("Expected GB18030", "GB18030", match1.getName());
-
+
CharsetDetector detector2 = new CharsetDetector();
byte[] data2 = createData2();
detector2.setText(data2);
// 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();
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 " +
"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.
*
out.write(Integer.parseInt(new String(number), 16));
}
}
-
+
return out.toByteArray();
}
//
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<input.length; i++) {
input[i] = (byte)0xb2;
det.setText(input);
det.detect();
}
-
+
@Test
public void TestBug6954 () throws Exception {
// Ticket 6954 - trouble with the haveC1Bytes flag that is used to distinguish between
CharsetMatch match2 = csd2.detect();
String name2 = match2.getName();
assertEquals("Initial use of second detector", "ISO-8859-1", name2);
-
+
// Recheck the 1252 results from the first detector, which should not have been
// altered by the use of a different detector.
name1 = match1.getName();
assertEquals("Wrong charset name after running a second charset detector", "windows-1252", name1);
}
-
+
@Test
public void TestBug6889() {
// Verify that CharsetDetector.detectAll() does not return the same encoding multiple times.
fail("Unexpected exception " + e.toString());
return;
}
-
+
CharsetDetector det = new CharsetDetector();
det.setText(textBytes);
CharsetMatch matches[] = det.detectAll();
-
+
HashSet<String> detectedEncodings = new HashSet<String>();
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.";
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) {
// System.out.println("Thread " + n + " is finished.");
}
}
-
+
Thread threads[] = new Thread[10];
for (int i=0; i<10; i++) {
threads[i] = new WorkerThread(i);
}
}
-
+
}
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) {
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]);
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: ");
// continuation
/* IDX , S . */
byte [] segment2 = { 0x01, 0x2c, 0x20, 0x53, 0x2e };
-
+
result = decompressTest(segment1, segment2);
if(! result.equals("Booth, S.")) {
errln("Decompression test failed");
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();
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,
(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,
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
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:");
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;
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);
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:");
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];
int[] unicharsRead = new int[1];
int[] bytesRead = new int[1];
-
+
int totalCharsCompressed = 0;
int totalBytesWritten = 0;
// 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.");*/
} 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");
}
/** 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
printChars(s2, s2len);
result = true;
}
-
+
int len = Math.min(s1len, s2len);
for(int i = 0; i < len; ++i) {
if(s1[i] != s2[i]) {
break;
}
}
-
+
return result;
}
char[] result = new char [len];
int runLen = 0;
int used = 0;
-
+
while(used < len) {
runLen = (int) (30 * random.nextDouble());
if(used + runLen >= len) {
randomRun(result, used, runLen, random);
used += runLen;
}
-
+
return result;
}*/
"\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",
//==========================
private final static int SINGLEBYTEMODE = 0;
private final static int UNICODEMODE = 1;
-
+
//==========================
// Single-byte mode tags
//==========================
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));
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("");
- }
+ }
}
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) {
{ true, false },
{ true, false, true },
};
-
+
String[] targets = {
"<testList></testList>",
"<testList><test>true</test></testList>",
String s4 = " It is\n only a test\t ";
String s4x = " It is only a test ";
- String[][] datas = {
+ String[][] datas = {
{},
{ s1 },
{ s2, s1 },
"<testList></testList>",
"<testList><test>" + s1 + "</test></testList>",
"<testList><test>" + s2 + "</test><test>" + s1 + "</test></testList>",
- "<testList><test>" + s3 + "</test><test>" + s2 +
+ "<testList><test>" + s3 + "</test><test>" + s2 +
"</test><test>" + s1 + "</test></testList>",
- "<testList><test>" + s3 + "</test><test>Null</test><test>" + s1 +
+ "<testList><test>" + s3 + "</test><test>Null</test><test>" + s1 +
"</test><test>Null</test></testList>",
- "<testList><test>" + s4x + "</test><test>" + s1 +
+ "<testList><test>" + s4x + "</test><test>" + s1 +
"</test><test>" + s3 + "</test><test>" + s2 + "</test></testList>",
};
String s3 = "This is a test";
String s4 = "It is only a test";
- String[][] table = {
+ String[][] table = {
{},
{ s1 },
{ s2, s1 },
"<testList></testList>" +
"<testList><test></test></testList>" +
"<testList><test> </test><test></test></testList>" +
- "<testList><test>This is a test</test><test> </test>" +
+ "<testList><test>This is a test</test><test> </test>" +
"<test></test></testList>" +
"<testList>Null</testList>" +
"<testList><test>It is only a test</test><test></test>" +
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;
* @author srl
*
*/
+@RunWith(JUnit4.class)
public class ICUDurationTest extends TestFmwk {
/**
* Allows us to not depend on javax.xml.datatype.DatatypeFactory.
}
/**
- *
+ *
*/
public ICUDurationTest() {
}
DurationFormat df;
String expect;
String formatted;
-
+
df = DurationFormat.getInstance(new ULocale("it"));
formatted = df.formatDurationFromNow(4096);
expect = "fra quattro secondi";
} 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)
} else {
logln("format date -> " + formatted);
}
-
+
formatted = df.formatDurationFrom(1000*3600*24, new Date(0).getTime());
expect = "fra un giorno";
if(!expect.equals(formatted)) {
String out;
String expected;
String expected2;
-
+
// test 1
d = newDuration(1, 2, 46, 40); // "PT2H46M40S"
df = DurationFormat.getInstance(new ULocale("en"));
} else {
errln("FAIL: got " + out + " wanted " + expected + " from " + d);
}
-
+
// test 2
d = newDuration(10000);
df = DurationFormat.getInstance(new ULocale("en"));
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 {
errln("FAIL: null DurationFormat returned.");
}
}
-
+
/* Tests the class
* DurationFormat
*/
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{
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;
/**
* 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
};
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
};
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;
}
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;
}
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;
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
assertNotNull(null, pbf.getOneOrTwoUnitBuilder());
assertNotNull(null, pbf.getMultiUnitBuilder(2));
}
-
+
@Test
public void testBuilderFactoryPeriodConstruction() {
// see ticket #8307
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));
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() {
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;
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();
"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();
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() {
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;
* @test
* General test of Big NumberFormat
*/
+@RunWith(JUnit4.class)
public class BigNumberFormatTest extends TestFmwk {
static final int ILLEGAL = -1;
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;
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
*******************************************************************************
*/
-/**
+/**
* Port From: ICU4C v1.8.1 : format : DateFormatMiscTests
* Source File: $ICU4CRoot/source/test/intltest/miscdtfm.cpp
**/
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
*/
//
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");
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);
logln("");
}
}
-
+
/* @Bug 4099975
* SimpleDateFormat constructor SimpleDateFormat(String, DateFormatSymbols)
* should clone the DateFormatSymbols parameter
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");
}
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");
}
}
}
}
-
+
/*
* @bug 4117335
*/
*******************************************************************************
*/
-/**
+/**
* Port From: ICU4C v1.8.1 : format : DateFormatRegressionTest
* Source File: $ICU4CRoot/source/test/intltest/dtfmrgts.cpp
**/
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;
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
*/
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);
} catch (Exception e) {
errln("Error reparsing date: " + e.getMessage());
}
-
+
try {
StringBuffer rt = new StringBuffer("");
rt = sdf.format(sdf.parse(todayS.toString()), rt, pos);
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",
"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);
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");
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();
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];
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
*/
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);
*/
@Test
public void Test4061287() {
-
+
SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
try {
logln(df.parse("35/01/1971").toString());
if (!ok)
errln("Fail: Lenient not working");
}
-
+
/**
* @bug 4065240
*/
String strShortDate, strFullDate;
Locale saveLocale = Locale.getDefault();
TimeZone saveZone = TimeZone.getDefault();
-
+
try {
Locale curLocale = new Locale("de", "DE");
Locale.setDefault(curLocale);
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 <EST> in de_DE is updated
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
*/
/**
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();
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. */
} catch (ParseException e) {
errln("Fail: " + e);
e.printStackTrace();
- }
+ }
}
-
+
/**
* @bug 4089106
*/
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);
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.");
}
} catch (ClassNotFoundException e) {
errln("Fail: " + e);
}
-
+
}
-
+
/**
* @bug 4101483
*/
if (fp.getBeginIndex() == fp.getEndIndex())
errln("Fail: Empty field");
}
-
+
/**
* @bug 4103340
* @bug 4138203
*/
@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
*/
TimeZone.setDefault(saveZone);
}
}
-
+
/**
* @bug 4104136
*/
errln( "Fail: Expected result " + exp);
}
}
-
+
/**
* @bug 4104522
* CANNOT REPRODUCE
pp.setIndex(0);
text = "time";
dt = sdf.parse(text, pp);
- logln(" text: \"" + text + "\"" + " date: " + dt);
+ logln(" text: \"" + text + "\"" + " date: " + dt);
}
-
+
/**
* @bug 4106807
*/
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();
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("");
}
}
}
-
+
/*
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"
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());
// 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("");
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
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
errln("Parse format \"" + format + "\" failed.");
}
}
-
+
/**
* DateFormat shouldn't parse year "-1" as a two-digit year (e.g., "-1" . 1999).
*/
* 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();
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);
// Yuck: See j25
actStr = ((DateFormat) dispFmt).format(actual);
}
-
+
if (expected.getTime() == (actual.getTime())) {
out += str + " => " + actStr + "\n";
} else {
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();
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.
d = cal.getTime();
logln("Attempt to set Calendar to Feb 29 2000: " + disp.format(d));
}
-
+
@Test
public void Test714() {
//TimeZone Offset
logln(what + "=" + s);
first = s.charAt(0);
if(first<kHindiZero || 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());
}
}
logln(what + ": " + s);
first = s.charAt(0);
if(first<kArabicZero || 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());
}
}
logln(what + ": " + s);
first = s.charAt(0);
if(first<kArabicZero || 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());
}
}
{
logln(what + ": " + s);
first = s.charAt(0);
if(first<kLatinZero || 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());
}
}
logln(what+ ": " + s);
first = s.charAt(0);
if(first<kArabicZero || 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());
}
}
logln(what+ ": " + s);
first = s.charAt(0);
if(first<kArabicZero || 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());
}
}
logln(what+ ": " + s);
first = s.charAt(0);
if(first<kArabicZero || 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());
}
}
}
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
}
}
}
-
+
@Test
public void TestParsing() {
String pattern = "EEE-WW-MMMM-yyyy";
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) {
String dangiDateStr = fmt.format(d);
assertEquals("Bad date format", "Mo1 20, 2013", dangiDateStr);
}
-
+
@Test
public void TestT10110() {
try {
@Test
public void TestT10239() {
-
+
class TestDateFormatItem {
public String parseString;
public String pattern;
expectedResult = expResult;
}
};
-
+
final TestDateFormatItem[] items = {
// parse String pattern expected result
new TestDateFormatItem("1 Oct 13 2013", "e MMM dd yyyy", "1 Oct 13 2013"),
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) {
}
}
}
-
+
@Test
public void TestT10334() {
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
}
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());
}
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);
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+"]");
}
} catch (ParseException pe) {
// expected
}
-
+
/*
* test to verify new code (and improve code coverage) for normal quarter processing
*/
@Test
public void TestT10619() {
-
+
class TestDateFormatLeniencyItem {
public boolean leniency;
public String parseString;
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) {
}
}
}
-
+
@Test
public void TestT10906()
{
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) {
this.d = d;
}
+ @Override
public void run() {
String s0 = fmt.format(d);
for (int i = 0; i < 1000; i++) {
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) {
}
}
- // 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<ISOPattern.length; i++) {
aSimpleDF.applyPattern( ISOPattern[i] );
logln( "Pattern = " + aSimpleDF.toPattern());
logln( "Format = " + aSimpleDF.format(d));
}
}
-
+
//DateFormat getDateTimeInstance(int, int), invalid styles no exception
@Test
public void Test4213086() {
} catch(Exception e){
logln("dateStyle = 2" + "\t timeStyle = -2");
logln("Exception caught!");
- }
-
+ }
+
try {
DateFormat df3 = DateFormat.getDateTimeInstance(4, 2);
d = df3.format(someDate);
logln("Exception caught!");
logln("********************************************");
}
-
+
try {
DateFormat df4 = DateFormat.getDateTimeInstance(-12, -12);
d = df4.format(someDate);
logln("Exception caught!");
logln("********************************************");
}
-
+
try{
DateFormat df5 = DateFormat.getDateTimeInstance(2, 123);
- d = df5.format(someDate);
+ d = df5.format(someDate);
errln("we should catch an exception here");
} catch(Exception e){
logln("dateStyle = 2" + "\t timeStyle = 123");
logln("The value of d: " + d);
}
}
-
+
//DateFormat.format works wrongly?
@Test
public void Test4250359() {
DateFormat tf = DateFormat.getTimeInstance(DateFormat.SHORT);
String act_result = tf.format(d);
String exp_result = "5:53 PM";
-
+
if(!act_result.equals(exp_result)){
errln("The result is not expected");
}
}
-
+
//pattern "s.S, parse '1ms'"
@Test
public void Test4253490() {
Date d = new Date(1002705212231L);
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.SSSSSSS''"};
-
+ "''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''"};
+
SimpleDateFormat aSimpleDF = (SimpleDateFormat) DateFormat.getDateTimeInstance();
for (int i = 0; i < ISOPattern.length; i++) {
aSimpleDF.applyPattern(ISOPattern[i]);
logln("Format = " + aSimpleDF.format(d));
}
}
-
+
//about regression test
@Test
public void Test4266432() {
Locale loc = Locale.getDefault();
String dateFormat = "MM/dd/yy HH:mm:ss zzz";
SimpleDateFormat fmt = new SimpleDateFormat(dateFormat);
-
+
ParsePosition p0 = new ParsePosition(0);
logln("Under " + loc +" locale");
Date d = fmt.parse("01/22/92 04:52:00 GMT", p0);
logln(d.toString());
}
-
+
//SimpleDateFormat inconsistent for number of digits for years
@Test
public void Test4358730() {
cal.clear();
cal.set(2001,11,10);
Date today = cal.getTime();
-
+
sdf.applyPattern("MM d y");
logln(sdf.format(today));
sdf.applyPattern("MM d yy");
logln(sdf.format(today));
-
+
sdf.applyPattern("MM d yyy");
logln(sdf.format(today));
-
+
sdf.applyPattern("MM d yyyy");
logln(sdf.format(today));
-
+
sdf.applyPattern("MM d yyyyy");
logln(sdf.format(today));
}
-
+
//Parse invalid string
@Test
public void Test4375399() {
Thread.sleep(1000);
} catch (Exception e) {}
}*/
-
+
@Test
public void Test4468663() {
Date d =new Date(-93716671115767L);
logln("original date: " + origin_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);
-
+
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();
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);
}
}
}
}
}
-
+
//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);
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);
}
}
}
}
-
+
}
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;
/**
* 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;
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;
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.
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) {
}
String expected = data[i + 1];
if (!out.equals(expected))
{
- errln((String)"FAIL: " + in + " -> " + out + " expected -> " + expected);
+ errln("FAIL: " + in + " -> " + out + " expected -> " + expected);
}
}
}
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);
String expected = DATA[i][1];
if (!result.equals(expected))
- errln((String) "FAIL: -> " + result.toString() + " expected -> " + expected);
+ errln("FAIL: -> " + result.toString() + " expected -> " + expected);
}
}
*******************************************************************************
*/
-/**
+/**
* Port From: ICU4C v1.8.1 : format : DateIntervalFormatTest
* Source File: $ICU4CRoot/source/test/intltest/dtifmtts.cpp
**/
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;
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");
// 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",
"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);
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(
}
- /*
+ /*
* Test format using user defined DateIntervalInfo
*/
@Test
// 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)
"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);
}
errln("parse exception" + e);
continue;
}
- DateInterval dtitv = new DateInterval(date.getTime(),
+ DateInterval dtitv = new DateInterval(date.getTime(),
date_2.getTime());
DateIntervalInfo dtitvinf = new DateIntervalInfo();
- /*
+ /*
* Test format using user defined DateIntervalInfo
*/
@Test
// 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)
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);
// 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",
};
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]);
}
}
"hv",
"hz",
"EEddMMyyyy", // following could be normalized
- "EddMMy",
+ "EddMMy",
"hhmm",
"hhmmzz",
"hms", // following could not be normalized
}
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
}
- // 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);
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() {
} 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) " +
// 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){}
}
"Custom DateIntervalInfo objects should not mess up cache",
expected,
dif.format(from, to, new StringBuffer(), new FieldPosition(0))
- .toString());
+ .toString());
}
"Custom DateIntervalInfo objects should not mess up cache",
expected,
dif.format(from, to, new StringBuffer(), new FieldPosition(0))
- .toString());
+ .toString());
}
@Test
@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"
};
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));
}
String formattedEnd = dateFormat.format(endDate);
PatternInfo patternInfo = intervalFormat.getRawPatterns().get("M");
-
+
String firstPart = patternInfo.getFirstPart();
String secondPart = patternInfo.getSecondPart();
if (!matches(dateFormatPattern, firstPart, secondPart)) {
+ dateFormatPattern + "» and date interval format «" + firstPart + secondPart + "».");
}
}
-
+
logln(locale
+ "\tskeleton: «" + skeleton
+ "»\tpattern: «" + dateFormatPattern
// 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;
}
@Test
public void TestFPos_SkelWithSeconds () {
-
+
final long[] deltas = {
0L, // none
200L, // 200 millisec
format = fmt;
}
};
-
+
final ExpectPosAndFormat[] exp_en_HHmm = {
new ExpectPosAndFormat( 3, 5, "09:00" ),
new ExpectPosAndFormat( 3, 5, "09:00" ),
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 ),
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
final DateIntervalFormat formatter = DateIntervalFormat.getInstance(DateFormat.YEAR_MONTH_DAY, ULocale.US);
final ArrayList<DateInterval> testIntervals = new ArrayList<DateInterval>();
final ArrayList<String>expectedResults = new ArrayList<String>();
-
+
// 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);
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<String> expectedItr = expectedResults.listIterator();
}
}
}
-
+
List<TestThread> threads = new ArrayList<TestThread>();
for (int i=0; i<4; ++i) {
threads.add(new TestThread());
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;
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 {
* Corporation and others. All Rights Reserved.
*/
-/**
+/**
* Port From: JDK 1.4b1 : java.text.Format.IntlTestDateFormat
* Source File: java/text/format/IntlTestDateFormat.java
**/
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;
public IntlTestDateFormat() {
//Constructure
}
-
+
@Before
public void init() throws Exception {
fFormat = DateFormat.getInstance();
}
-
+
@Test
public void TestULocale() {
localeTest(ULocale.getDefault(), "Default Locale");
SimpleDateFormat s = (SimpleDateFormat) fFormat;
logln(fTestName + " Pattern " + s.toPattern());
}
-
+
private void tryDate(Date theDate) {
final int DEPTH = 10;
Date[] date = new Date[DEPTH];
* Corporation and others. All Rights Reserved.
**/
-/**
+/**
* Port From: JDK 1.4b1 : java.text.Format.IntlTestDateFormatAPI
* Source File: java/text/format/IntlTestDateFormatAPI.java
**/
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;
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
*******************************************************************************
*/
-/**
+/**
* Port From: ICU4C v1.8.1 : format : IntlTestDateFormatAPI
* Source File: $ICU4CRoot/source/test/intltest/dtfmapts.cpp
**/
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;
* 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
*/
@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");
errln("FAIL: Can't create DateFormat");
}
}
-
+
// SimpleDateFormat calling Format & DateFormat API
{
logln("SimpleDateFormat");
System.out.println(pe);
}
}
-
+
// NumberFormat calling Format API
{
logln("NumberFormat");
errln("FAIL: Can't create NumberFormat");
}
}
-
+
// DecimalFormat calling Format & NumberFormat API
{
logln("DecimalFormat");
System.out.println(pe);
}
}
-
+
//ICU4J have not the classes ChoiceFormat and MessageFormat
/*
// ChoiceFormat calling Format & NumberFormat API
System.out.println(pe);
}
}
-
-
+
+
// MessageFormat calling Format API
{
logln("MessageFormat");
* 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
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
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]);
}
}
}
-
+
@Test
public void TestGetWeekdays2(){
DateFormatSymbols symbol;
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]);
}
}
}
-
+
}
-
+
@Test
public void TestGetEraNames(){
DateFormatSymbols symbol;
for (int i = 0; i < s.length; i++) {
logln(s[i]);
}
-
+
}
private boolean UnicodeStringsArePrefixes(String[] prefixArray, String[] baseArray){
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 ||
!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");
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
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;
// 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
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
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.
*/
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;
* 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;
* 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
**/
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
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");
// errln("ERROR: Couldn't create a DecimalFormat");
// }
}
-
+
// Jitterbug 4451, for coverage
@Test
public void TestCoverage(){
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();
* 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;
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;
* @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
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()");
// errln("ERROR: Couldn't create a SimpleDateFormat");
// }
}
-
+
// Jitterbug 4451, for coverage
@Test
public void TestCoverage(){
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 = {
"",
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);
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);
// expected.
}
}
-
+
@Test
public void TestGetLocale() {
assertEquals(
"getLocale", ULocale.ENGLISH, ListFormatter.getInstance(ULocale.ENGLISH).getLocale());
}
-
+
@Test
public void Test9946() {
ListFormatter listFormatter = ListFormatter.getInstance(ULocale.ENGLISH);
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;
* for information on how to update with each new release.
* @author markdavis
*/
+@RunWith(JUnit4.class)
public class MeasureUnitTest extends TestFmwk {
static class OrderedPair<F extends Comparable, S extends Comparable> extends Pair<F, S> implements Comparable<OrderedPair<F, S>> {
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
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;
* 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.
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.
pos.setErrorIndex(4);
if (pos.getErrorIndex() != 4)
errln("setErrorIndex failed, got " + pos.getErrorIndex() + " instead of 4");
-
+
if (objs != null) {
errln("objs should be null");
}
*/
@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);
"'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) {
throw new RuntimeException("didn't get exception for invalid input");
}
}
-
+
@Test
public void test4293229() {
MessageFormat format = new MessageFormat("'''{'0}'' '''{0}'''");
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'.";
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 + "}");
ostream.writeObject(original);
ostream.flush();
byte bytes[] = baos.toByteArray();
-
+
ObjectInputStream istream = new ObjectInputStream(new ByteArrayInputStream(bytes));
MessageFormat reconstituted = (MessageFormat)istream.readObject();
return reconstituted;
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;
currencyStyle = NumberFormat.getIntegerInstance(swapLoc);
}
+ @Override
public NumberFormat createFormat(ULocale loc, int formatType) {
if (formatType == FORMAT_CURRENCY) {
return currencyStyle;
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;
/**
* 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
*/
// 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);
*******************************************************************************
*/
-/**
+/**
* Porting From: ICU4C v1.8.1 : format : NumberFormatRoundTripTest
* Source File: $ICU4CRoot/source/test/intltest/nmfmtrt.cpp
**/
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;
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) {
}
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.
*/
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);
_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);
s = fmt.format(value.doubleValue());
else
s = fmt.format(value.longValue());
-
+
Number n = new Double(0);
boolean show = verbose;
if (DEBUG)
} 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");
} 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);
- }
+ }
}
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;
* @author rocketman
*
*/
+@RunWith(JUnit4.class)
public class NumberFormatSpecificationTest extends TestFmwk {
@Test
public void TestBasicPatterns() {
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.##");
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"));
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, "@@@"));
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"));
assertEquals("", "170,0E-3", formatFrWithPattern(0.17, "##0.000#E0"));
}
}
-
+
@Test
public void TestPercent() {
assertEquals("", "57,3%", formatFrWithPattern(0.573, "0.0%"));
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‰"));
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"));
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);
private static String format(double d, NumberFormat nf) {
return nf.format(d).replace('\u00a0', ' ');
}
-
+
}
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;
import com.ibm.icu.util.CurrencyAmount;
import com.ibm.icu.util.ULocale;
+@RunWith(JUnit4.class)
public class NumberFormatTest extends TestFmwk {
@Test
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;
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';
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;
* @author tschumann (Tim Schumann)
*
*/
+@RunWith(JUnit4.class)
public class PluralFormatTest extends TestFmwk {
private void helperTestRules(String localeIDs, String testPattern, Map<Integer,String> changes) {
String[] locales = Utility.split(localeIDs, ',');
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;
* @author tschumann (Tim Schumann)
*
*/
+@RunWith(JUnit4.class)
public class PluralFormatUnitTest extends TestFmwk {
@Test
public void TestConstructor() {
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}");
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;
/**
* @author markdavis
- *
+ *
*/
+@RunWith(JUnit4.class)
public class PluralRangesTest extends TestFmwk {
@Test
public void TestLocaleData() {
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;
* @author dougfelt (Doug Felt)
* @author markdavis (Mark Davis) [for fractional support]
*/
+@RunWith(JUnit4.class)
public class PluralRulesTest extends TestFmwk {
PluralRulesFactory factory = PluralRulesFactory.NORMAL;
enum StandardPluralCategories {
zero, one, two, few, many, other;
/**
- *
+ *
*/
private static final Set<StandardPluralCategories> ALL = Collections.unmodifiableSet(EnumSet
.allOf(StandardPluralCategories.class));
/**
* Return a mutable set
- *
+ *
* @param source
* @return
*/
}
static final Comparator<Set<StandardPluralCategories>> SHORTEST_FIRST = new Comparator<Set<StandardPluralCategories>>() {
+ @Override
public int compare(Set<StandardPluralCategories> arg0, Set<StandardPluralCategories> arg1) {
int diff = arg0.size() - arg1.size();
if (diff != 0) {
}
private static final Comparator<PluralRules> PLURAL_RULE_COMPARATOR = new Comparator<PluralRules>() {
+ @Override
public int compare(PluralRules o1, PluralRules o2) {
return o1.compareTo(o2);
}
}
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;
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() {
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
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;
* 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" +
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.text.RelativeDateTimeFormatter.Style;
import com.ibm.icu.util.ULocale;
+@RunWith(JUnit4.class)
public class RelativeDateTimeFormatterTest extends TestFmwk {
@Test
public void TestRelativeDateWithQuantity() {
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;
* @author rocketman
*
*/
+@RunWith(JUnit4.class)
public class ScientificNumberFormatterTest extends TestFmwk {
@Test
public void TestBasic() {
"1.23456×10⁻⁷⁸",
superscript.format(1.23456e-78));
}
-
-
+
+
@Test
public void TestFarsi() {
ScientificNumberFormatter fmt = ScientificNumberFormatter.getMarkupInstance(
decfmt.applyPattern("0.00E+0");
ScientificNumberFormatter fmt = ScientificNumberFormatter.getMarkupInstance(
decfmt, "<sup>", "</sup>");
-
+
assertEquals(
"",
"6.02×10<sup>+23</sup>",
fmt.format(6.02e23));
}
-
+
@Test
public void TestPlusSignInExponentSuperscript() {
DecimalFormat decfmt = (DecimalFormat) NumberFormat.getScientificInstance(ULocale.ENGLISH);
"6.02×10⁺²³",
fmt.format(6.02e23));
}
-
+
@Test
public void TestFixedDecimalMarkup() {
DecimalFormat decfmt = (DecimalFormat) NumberFormat.getInstance(ULocale.ENGLISH);
"123,456",
fmt.format(123456.0));
}
-
+
@Test
public void TestFixedDecimalSuperscript() {
DecimalFormat decfmt = (DecimalFormat) NumberFormat.getInstance(ULocale.ENGLISH);
*******************************************************************************
* 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 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}";
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 );
}
/**
//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) );
}
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
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 {
*******************************************************************************
* 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}";
/**
"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}}"
};
}
/**
- * Unit tests for invalid keywords
+ * Unit tests for invalid keywords
*/
@Test
public void TestInvalidKeyword() {
+ "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;
}
};
log("SelectFormat Unit test: Testing applyPattern() and format() ...");
- SelectFormat selFmt = new SelectFormat(SIMPLE_PATTERN);
+ SelectFormat selFmt = new SelectFormat(SIMPLE_PATTERN);
for (int i=0; i<patternTestData.length; ++i) {
try {
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.text.DateFormat;
import com.ibm.icu.text.DecimalFormat;
import com.ibm.icu.text.DecimalFormatSymbols;
import com.ibm.icu.util.TimeZone;
import com.ibm.icu.util.ULocale;
-public class TestMessageFormat extends com.ibm.icu.dev.test.TestFmwk {
+@RunWith(JUnit4.class)
+public class TestMessageFormat extends TestFmwk {
@Test
public void TestBug3()
{
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;
* @author markdavis
*
*/
+@RunWith(JUnit4.class)
public class TimeUnitTest extends TestFmwk {
@Test
public void Test10219FractionalPlurals() {
nf.setMaximumFractionDigits(i);
tuf.setNumberFormat(nf);
assertEquals("Test10219", expected[i], tuf.format(new TimeUnitAmount(1.588, TimeUnit.MINUTE)));
- }
+ }
}
-
+
@Test
public void Test10219FactionalPluralsParse() throws ParseException {
TimeUnitFormat tuf = new TimeUnitFormat(ULocale.ENGLISH, TimeUnitFormat.FULL_NAME);
ParsePosition ppos = new ParsePosition(0);
String parseString = "1 minutes";
tuf.parseObject(parseString, ppos);
-
+
// Parsing should go all the way to the end of the string.
// We want the longest match, and we don't care if the plural form of the unit
// matches the plural form of the number.
TimeUnitFormat[] formats = new TimeUnitFormat[] {
new TimeUnitFormat(new ULocale(locales[locIndex]), TimeUnitFormat.FULL_NAME),
new TimeUnitFormat(new ULocale(locales[locIndex]), TimeUnitFormat.ABBREVIATED_NAME),
-
+
};
for (int style = TimeUnitFormat.FULL_NAME;
style <= TimeUnitFormat.ABBREVIATED_NAME;
format.setNumberFormat(NumberFormat.getNumberInstance(es));
format.setLocale(es);
formatParsing(format);
-
+
format.setLocale(new Locale("pt_BR"));
formatParsing(format);
format = new TimeUnitFormat(new Locale("de"));
format.setNumberFormat(NumberFormat.getNumberInstance(new Locale("en")));
formatParsing(format);
}
-
+
@Test
public void TestClone() {
TimeUnitFormat tuf = new TimeUnitFormat(ULocale.ENGLISH, TimeUnitFormat.ABBREVIATED_NAME);
tuf.setLocale(Locale.GERMAN);
assertEquals("", "1 hr", tufClone.format(new TimeUnitAmount(1, TimeUnit.HOUR)));
}
-
+
@Test
public void TestEqHashCode() {
TimeUnitFormat tf = new TimeUnitFormat(ULocale.ENGLISH, TimeUnitFormat.FULL_NAME);
MeasureFormat tfeq = new TimeUnitFormat(ULocale.ENGLISH, TimeUnitFormat.FULL_NAME);
-
+
MeasureFormat tfne = new TimeUnitFormat(ULocale.ENGLISH, TimeUnitFormat.ABBREVIATED_NAME);
MeasureFormat tfne2 = new TimeUnitFormat(ULocale.GERMAN, TimeUnitFormat.FULL_NAME);
verifyEqualsHashCode(tf, tfeq, tfne);
verifyEqualsHashCode(tf, tfeq, tfne2);
}
-
+
@Test
public void TestGetLocale() {
TimeUnitFormat tf = new TimeUnitFormat(ULocale.GERMAN);
/*
* @bug 7902
- * This tests that requests for short unit names correctly fall back
- * to long unit names for a locale where the locale data does not
+ * This tests that requests for short unit names correctly fall back
+ * to long unit names for a locale where the locale data does not
* provide short unit names. As of CLDR 1.9, Greek is one such language.
*/
@Test
assertEquals(
"locale: " + locales[locIndex]
- + ", style: " + styles[styleIndex]
+ + ", style: " + styles[styleIndex]
+ ", units: " + units[unitIndex]
- + ", value: " + numbers[numIndex],
+ + ", value: " + numbers[numIndex],
expected[counter], formatted);
++counter;
}
}
/**
- * @bug9042
+ * @bug9042
* Performs tests for Greek.
- * This tests that if the plural count listed in time unit format does not
- * match those in the plural rules for the locale, those plural count in
- * time unit format will be ingored and subsequently, fall back will kick in
- * which is tested above.
- * Without data sanitization, setNumberFormat() would crash.
- * As of CLDR shiped in ICU4.8, Greek is one such language.
- */
+ * This tests that if the plural count listed in time unit format does not
+ * match those in the plural rules for the locale, those plural count in
+ * time unit format will be ingored and subsequently, fall back will kick in
+ * which is tested above.
+ * Without data sanitization, setNumberFormat() would crash.
+ * As of CLDR shiped in ICU4.8, Greek is one such language.
+ */
@Test
public void TestGreekWithSanitization() {
ULocale loc = new ULocale("el");
NumberFormat numfmt = NumberFormat.getInstance(loc);
TimeUnitFormat tuf = new TimeUnitFormat(loc);
tuf.parseObject("", new ParsePosition(0));
- tuf.setNumberFormat(numfmt);
+ tuf.setNumberFormat(numfmt);
}
@Test
}
}
}
-
+
/*
* Tests the method public TimeUnitFormat(ULocale locale, int style), public TimeUnitFormat(Locale locale, int style)
*/
}
}
}
-
+
/*
* Tests the method public TimeUnitFormat setLocale(ULocale locale) public TimeUnitFormat setLocale(Locale locale)
*/
tuf1.setNumberFormat(NumberFormat.getInstance());
tuf1.setNumberFormat(null);
}
-
+
/*
* Tests the method public StringBuffer format(Object obj, ...
*/
} catch (Exception e) {
}
}
-
+
/* Tests the method private void setup() from
* public Object parseObject(String source, ParsePosition pos)
- *
+ *
*/
@Test
public void TestSetup(){
TimeUnitFormat tuf = new TimeUnitFormat();
tuf.parseObject("", new ParsePosition(0));
-
+
TimeUnitFormat tuf1 = new TimeUnitFormat();
tuf1.setNumberFormat(NumberFormat.getInstance());
tuf1.parseObject("", new ParsePosition(0));
}
-
+
@Test
public void TestStandInForMeasureFormat() {
TimeUnitFormat tuf = new TimeUnitFormat(ULocale.FRENCH, TimeUnitFormat.ABBREVIATED_NAME);
assertEquals("getNumberFormat", ULocale.FRENCH, tuf.getNumberFormat().getLocale(ULocale.VALID_LOCALE));
assertEquals("getWidth", MeasureFormat.FormatWidth.WIDE, tuf.getWidth());
}
-
+
private void verifyEqualsHashCode(Object o, Object eq, Object ne) {
assertEquals("verifyEqualsHashCodeSame", o, o);
assertEquals("verifyEqualsHashCodeEq", o, eq);
assertNotEquals("verifyEqualsHashCodeNe", o, ne);
assertNotEquals("verifyEqualsHashCodeEqTrans", eq, ne);
assertEquals("verifyEqualsHashCodeHashEq", o.hashCode(), eq.hashCode());
-
+
// May be a flaky test, but generally should be true.
// May need to comment this out later.
assertNotEquals("verifyEqualsHashCodeHashNe", o.hashCode(), ne.hashCode());
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.TZDBTimeZoneNames;
import com.ibm.icu.util.TimeZoneTransition;
import com.ibm.icu.util.ULocale;
-public class TimeZoneFormatTest extends com.ibm.icu.dev.test.TestFmwk {
+@RunWith(JUnit4.class)
+public class TimeZoneFormatTest extends TestFmwk {
private static boolean JDKTZ = (TimeZone.getDefaultTimeZoneType() == TimeZone.TIMEZONE_JDK);
private static final Pattern EXCL_TZ_PATTERN = Pattern.compile(".*/Riyadh8[7-9]");
import java.text.StringCharacterIterator;
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.CSCharacterIterator;
+@RunWith(JUnit4.class)
public class CSCharacterIteratorTest extends TestFmwk {
public CSCharacterIteratorTest() {};
package com.ibm.icu.dev.test.impl;
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.CacheValue;
import com.ibm.icu.impl.CacheValue.Strength;
+@RunWith(JUnit4.class)
public class CacheTest extends TestFmwk {
public CacheTest() {}
import java.text.StringCharacterIterator;
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.ReplaceableString;
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/
+@RunWith(JUnit4.class)
public class TestUCharacterIterator extends TestFmwk{
// constructor -----------------------------------------------------
-
+
/**
* Constructor
*/
public TestUCharacterIterator()
{
}
-
+
// public methods --------------------------------------------------
-
+
/**
* Testing cloning
*/
errln("getText failed for iterator");
}
}
-
+
/**
* Testing iteration
*/
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;
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 {
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");
}
}
}
-
- //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";
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;
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)
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();
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");
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(i<length) {
return s[i];
return -1;
}
}
-
+
public int next() {
if(i<length) {
return s[i++];
return -1;
}
}
-
+
public int previous() {
if(i>0) {
return s[--i];
return -1;
}
}
-
+
public int getIndex() {
return i;
}
-
+
private int[] s;
private int length, i;
}
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;
} 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
+"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
int c1, c2;
char m;
int movesIndex =0;
-
+
while(movesIndex<moves.length()) {
m=moves.charAt(movesIndex++);
if(m=='-') {
} else if(m=='0') {
c1=wrap_ci.current();
c2=ci.current();
- } else {// m=='+'
+ } else {// m=='+'
c1=wrap_ci.next();
c2=ci.next();
}
-
+
// compare results
if(c1!=c2) {
// copy the moves until the current (m) move, and terminate
+"got c1= " + hex(c1) +" != expected c2= "+ hex(c2));
break;
}
-
+
// compare indexes
if(wrap_ci.getIndex()!=ci.getIndex()) {
// copy the moves until the current (m) move, and terminate
}
}
// private data members ---------------------------------------------
-
+
private static final String ITERATION_STRING_ =
"Testing 1 2 3 \ud800\udc00 456";
private static final int ITERATION_SUPPLEMENTARY_INDEX = 14;
-
+
@Test
public void TestJitterbug1952(){
//test previous code point
while((ch=iter.nextCodePoint()) !=UCharacterIterator.DONE){
if(ch!= 0xDC03){
errln("iter.nextCodePoint() failed");
- }
- }
+ }
+ }
}
-
+
}
import java.util.BitSet;
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.UProperty;
import com.ibm.icu.lang.UScript.ScriptUsage;
import com.ibm.icu.text.UnicodeSet;
+@RunWith(JUnit4.class)
public class TestUScript extends TestFmwk {
/**
package com.ibm.icu.dev.test.lang;
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;
import com.ibm.icu.lang.UScriptRun;
+@RunWith(JUnit4.class)
public class TestUScriptRun extends TestFmwk
{
public TestUScriptRun()
{
// nothing
}
-
+
private static final class RunTestData
{
String runText;
int runScript;
-
+
public RunTestData(String theText, int theScriptCode)
{
runText = theText;
runScript = theScriptCode;
}
}
-
+
private static final RunTestData[][] m_testData = {
{
new RunTestData("\u0020\u0946\u0939\u093F\u0928\u094D\u0926\u0940\u0020", UScript.DEVANAGARI),
new RunTestData("((((((((((abc))))))))))", UScript.LATIN)
}
};
-
+
private static final String padding = "This string is used for padding...";
-
+
private void CheckScriptRuns(UScriptRun scriptRun, int[] runStarts, RunTestData[] testData)
{
int run, runStart, runLimit;
runStart = scriptRun.getScriptStart();
runLimit = scriptRun.getScriptLimit();
runScript = scriptRun.getScriptCode();
-
+
if (runStart != runStarts[run]) {
errln("Incorrect start offset for run " + run + ": expected " + runStarts[run] + ", got " + runStart);
}
if (runScript != testData[run].runScript) {
errln("Incorrect script for run " + run + ": expected \"" + UScript.getName(testData[run].runScript) + "\", got \"" + UScript.getName(runScript) + "\"");
}
-
+
run += 1;
/* stop when we've seen all the runs we expect to see */
UScriptRun scriptRun = null;
char[] nullChars = null, dummyChars = {'d', 'u', 'm', 'm', 'y'};
String nullString = null, dummyString = new String(dummyChars);
-
+
try {
scriptRun = new UScriptRun(nullString, 0, 100);
errln("new UScriptRun(nullString, 0, 100) did not produce an IllegalArgumentException!");
} catch (IllegalArgumentException iae) {
logln("PASS: UScriptRun failed as expected");
}
-
+
try {
scriptRun = new UScriptRun(nullString, 100, 0);
errln("new UScriptRun(nullString, 100, 0) did not produce an IllegalArgumentException!");
} catch (IllegalArgumentException iae) {
logln("PASS: UScriptRun failed as expected");
}
-
+
try {
scriptRun = new UScriptRun(nullString, 0, -100);
errln("new UScriptRun(nullString, 0, -100) did not produce an IllegalArgumentException!");
} catch (IllegalArgumentException iae) {
logln("PASS: UScriptRun failed as expected");
}
-
+
try {
scriptRun = new UScriptRun(nullString, -100, 0);
errln("new UScriptRun(nullString, -100, 0) did not produce an IllegalArgumentException!");
} catch (IllegalArgumentException iae) {
logln("PASS: UScriptRun failed as expected");
}
-
+
try {
scriptRun = new UScriptRun(nullChars, 0, 100);
errln("new UScriptRun(nullChars, 0, 100) did not produce an IllegalArgumentException!");
} catch (IllegalArgumentException iae) {
logln("PASS: UScriptRun failed as expected");
}
-
+
try {
scriptRun = new UScriptRun(nullChars, 100, 0);
errln("new UScriptRun(nullChars, 100, 0) did not produce an IllegalArgumentException!");
} catch (IllegalArgumentException iae) {
logln("PASS: UScriptRun failed as expected");
}
-
+
try {
scriptRun = new UScriptRun(nullChars, 0, -100);
errln("new UScriptRun(nullChars, 0, -100) did not produce an IllegalArgumentException!");
} catch (IllegalArgumentException iae) {
logln("PASS: UScriptRun failed as expected");
}
-
+
try {
scriptRun = new UScriptRun(nullChars, -100, 0);
errln("new UScriptRun(nullChars, -100, 0) did not produce an IllegalArgumentException!");
} catch (IllegalArgumentException iae) {
logln("PASS: UScriptRun failed as expected");
}
-
+
try {
scriptRun = new UScriptRun(dummyString, 0, 6);
errln("new UScriptRun(dummyString, 0, 6) did not produce an IllegalArgumentException!");
} catch (IllegalArgumentException iae) {
logln("PASS: UScriptRun failed as expected");
}
-
+
try {
scriptRun = new UScriptRun(dummyString, 6, 0);
errln("new UScriptRun(dummy, 6, 0) did not produce an IllegalArgumentException!");
}catch (IllegalArgumentException iae) {
logln("PASS: UScriptRun failed as expected");
}
-
+
try {
scriptRun = new UScriptRun(dummyString, 0, -100);
errln("new UScriptRun(dummyString, 0, -100) did not produce an IllegalArgumentException!");
} catch (IllegalArgumentException iae) {
logln("PASS: UScriptRun failed as expected");
}
-
+
try {
scriptRun = new UScriptRun(dummyString, -100, 0);
errln("new UScriptRun(dummy, -100, 0) did not produce an IllegalArgumentException!");
} catch (IllegalArgumentException iae) {
logln("PASS: UScriptRun failed as expected");
}
-
+
try {
scriptRun = new UScriptRun(dummyChars, 0, 6);
errln("new UScriptRun(dummyChars, 0, 6) did not produce an IllegalArgumentException!");
} catch (IllegalArgumentException iae) {
logln("PASS: UScriptRun failed as expected");
}
-
+
try {
scriptRun = new UScriptRun(dummyChars, 6, 0);
errln("new UScriptRun(dummyChars, 6, 0) did not produce an IllegalArgumentException!");
}catch (IllegalArgumentException iae) {
logln("PASS: UScriptRun failed as expected");
}
-
+
try {
scriptRun = new UScriptRun(dummyChars, 0, -100);
errln("new UScriptRun(dummyChars, 0, -100) did not produce an IllegalArgumentException!");
} catch (IllegalArgumentException iae) {
logln("PASS: UScriptRun failed as expected");
}
-
+
try {
scriptRun = new UScriptRun(dummyChars, -100, 0);
errln("new UScriptRun(dummy, -100, 0) did not produce an IllegalArgumentException!");
errln("Did not get the expected Exception");
}
}
-
+
@Test
public void TestReset()
{
UScriptRun scriptRun = null;
char[] dummy = {'d', 'u', 'm', 'm', 'y'};
-
+
try {
scriptRun = new UScriptRun();
} catch (IllegalArgumentException iae) {
errln("new UScriptRun() produced an IllegalArgumentException!");
}
-
+
try {
scriptRun.reset(0, 100);
errln("scriptRun.reset(0, 100) did not produce an IllegalArgumentException!");
} catch (IllegalArgumentException iae) {
logln("PASS: scriptRun.reset failed as expected");
}
-
+
try {
scriptRun.reset(100, 0);
errln("scriptRun.reset(100, 0) did not produce an IllegalArgumentException!");
} catch (IllegalArgumentException iae) {
logln("PASS: scriptRun.reset failed as expected");
}
-
+
try {
scriptRun.reset(0, -100);
errln("scriptRun.reset(0, -100) did not produce an IllegalArgumentException!");
} catch (IllegalArgumentException iae) {
logln("PASS: scriptRun.reset failed as expected");
}
-
+
try {
scriptRun.reset(-100, 0);
errln("scriptRun.reset(-100, 0) did not produce an IllegalArgumentException!");
} catch (IllegalArgumentException iae) {
logln("PASS: scriptRun.reset failed as expected");
}
-
+
try {
scriptRun.reset(dummy, 0, 6);
errln("scriptRun.reset(dummy, 0, 6) did not produce an IllegalArgumentException!");
} catch (IllegalArgumentException iae) {
logln("PASS: scriptRun.reset failed as expected");
}
-
+
try {
scriptRun.reset(dummy, 6, 0);
errln("scriptRun.reset(dummy, 6, 0) did not produce an IllegalArgumentException!");
}catch (IllegalArgumentException iae) {
logln("PASS: scriptRun.reset failed as expected");
}
-
+
try {
scriptRun.reset(dummy, 0, -100);
errln("scriptRun.reset(dummy, 0, -100) did not produce an IllegalArgumentException!");
} catch (IllegalArgumentException iae) {
logln("PASS: scriptRun.reset failed as expected");
}
-
+
try {
scriptRun.reset(dummy, -100, 0);
errln("scriptRun.reset(dummy, -100, 0) did not produce an IllegalArgumentException!");
} catch (IllegalArgumentException iae) {
logln("PASS: scriptRun.reset failed as expected");
}
-
+
try {
scriptRun.reset(dummy, 0, dummy.length);
} catch (IllegalArgumentException iae) {
errln("scriptRun.reset(dummy, 0, dummy.length) produced an IllegalArgumentException!");
}
-
-
+
+
try {
scriptRun.reset(0, 6);
errln("scriptRun.reset(0, 6) did not produce an IllegalArgumentException!");
} catch (IllegalArgumentException iae) {
logln("PASS: scriptRun.reset failed as expected");
}
-
+
try {
scriptRun.reset(6, 0);
errln("scriptRun.reset(6, 0) did not produce an IllegalArgumentException!");
} catch (IllegalArgumentException iae) {
logln("PASS: scriptRun.reset failed as expected");
}
-
+
try {
scriptRun.reset(dummy, 0, dummy.length);
scriptRun.reset();
} catch(IllegalArgumentException iae){
errln("scriptRun.reset() produced an IllegalArgumentException!");
}
-
+
try {
scriptRun.reset((char[]) null);
} catch(IllegalArgumentException iae){
errln("scriptRun.reset((char[])null) produced an IllegalArgumentException!");
}
-
+
try {
scriptRun.reset((String) null);
} catch(IllegalArgumentException iae){
errln("scriptRun.reset((String)null) produced an IllegalArgumentException!");
}
}
-
+
@Test
public void TestRuns()
{
int[] runStarts = new int[test.length + 1];
String testString = "";
UScriptRun scriptRun = null;
-
+
/*
* Fill in the test string and the runStarts array.
*/
testString += test[run].runText;
}
- /* The limit of the last run */
+ /* The limit of the last run */
runStarts[test.length] = stringLimit;
-
+
try {
scriptRun = new UScriptRun(testString);
CheckScriptRuns(scriptRun, runStarts, test);
} catch (IllegalArgumentException iae) {
errln("new UScriptRun(testString) produced an IllegalArgumentException!");
}
-
+
try {
scriptRun.reset();
CheckScriptRuns(scriptRun, runStarts, test);
} catch (IllegalArgumentException iae) {
errln("scriptRun.reset() on a valid UScriptRun produced an IllegalArgumentException!");
}
-
+
try {
scriptRun = new UScriptRun(testString.toCharArray());
CheckScriptRuns(scriptRun, runStarts, test);
} catch (IllegalArgumentException iae) {
errln("new UScriptRun(testString.toCharArray()) produced an IllegalArgumentException!");
}
-
+
try {
scriptRun.reset();
CheckScriptRuns(scriptRun, runStarts, test);
} catch (IllegalArgumentException iae) {
errln("scriptRun.reset() on a valid UScriptRun produced an IllegalArgumentException!");
}
-
+
try {
scriptRun = new UScriptRun();
-
+
if (scriptRun.next()) {
errln("scriptRun.next() on an empty UScriptRun returned true!");
}
} catch (IllegalArgumentException iae) {
errln("new UScriptRun() produced an IllegalArgumentException!");
}
-
+
try {
scriptRun.reset(testString, 0, testString.length());
CheckScriptRuns(scriptRun, runStarts, test);
String paddedTestString = padding + testString + padding;
int startOffset = padding.length();
int count = testString.length();
-
+
for (int run = 0; run < runStarts.length; run += 1) {
runStarts[run] += startOffset;
}
-
+
try {
scriptRun.reset(paddedTestString, startOffset, count);
CheckScriptRuns(scriptRun, runStarts, test);
} catch (IllegalArgumentException iae) {
errln("scriptRun.reset(paddedTestString.toCharArray(), startOffset, count) produced an IllegalArgumentException!");
}
-
+
/* Tests "public final void reset()" */
// Tests when "while (stackIsNotEmpty())" is true
try{
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;
* @author Syn Wee Quek
* @since march 14 2002
*/
+@RunWith(JUnit4.class)
public final class UCharacterCaseTest extends TestFmwk
{
// constructor -----------------------------------------------------------
*/
package com.ibm.icu.dev.test.lang;
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.UCharacterCategory;
* @author Syn Wee Quek
* @since April 02 2002
*/
+@RunWith(JUnit4.class)
public class UCharacterCategoryTest extends TestFmwk
{
// constructor -----------------------------------------------------------
-
+
/**
* Private constructor to prevent initialisation
*/
public UCharacterCategoryTest()
{
}
-
+
// public methods --------------------------------------------------------
-
+
/**
* Gets the name of the argument category
* @returns category name
"Symbol, Math",
"Symbol, Currency",
"Symbol, Modifier",
- "Symbol, Other",
+ "Symbol, Other",
"Punctuation, Initial quote",
"Punctuation, Final quote"};
- for (int i = UCharacterCategory.UNASSIGNED;
+ for (int i = UCharacterCategory.UNASSIGNED;
i < UCharacterCategory.CHAR_CATEGORY_COUNT; i ++) {
if (!UCharacterCategory.toString(i).equals(name[i])) {
errln("Error toString for category " + i + " expected " +
package com.ibm.icu.dev.test.lang;
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.UCharacterDirection;
* @author Syn Wee Quek
* @since July 22 2002
*/
+@RunWith(JUnit4.class)
public class UCharacterDirectionTest extends TestFmwk
-{
+{
// constructor -----------------------------------------------------------
-
+
/**
* Private constructor to prevent initialization
*/
public UCharacterDirectionTest()
{
}
-
+
// public methods --------------------------------------------------------
-
+
/**
* Gets the name of the argument category
* @returns category name
public void TestToString()
{
String name[] = {"Left-to-Right",
- "Right-to-Left",
+ "Right-to-Left",
"European Number",
"European Number Separator",
"European Number Terminator",
"Right-to-Left Isolate",
"Pop Directional Isolate",
"Unassigned"};
-
+
for (int i = UCharacterDirection.LEFT_TO_RIGHT;
// Placed <= because we need to consider 'Unassigned'
// when it goes out of bounds of UCharacterDirection
package com.ibm.icu.dev.test.lang;
+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.lang.UCharacter;
/**
* Test JDK 1.5 cover APIs.
*/
+@RunWith(JUnit4.class)
public final class UCharacterSurrogateTest extends TestFmwk {
- @org.junit.Test
+ @Test
public void TestUnicodeBlockForName() {
- String[] names = {"Latin-1 Supplement",
+ String[] names = {"Latin-1 Supplement",
"Optical Character Recognition",
- "CJK Unified Ideographs Extension A",
+ "CJK Unified Ideographs Extension A",
"Supplemental Arrows-B",
- "Supplemental arrows b",
+ "Supplemental arrows b",
"supp-lement-al arrowsb",
"Supplementary Private Use Area-B",
"supplementary_Private_Use_Area-b",
}
}
- @org.junit.Test
+ @Test
public void TestIsValidCodePoint() {
if (UCharacter.isValidCodePoint(-1))
errln("-1");
errln("0x110000");
}
- @org.junit.Test
+ @Test
public void TestIsSupplementaryCodePoint() {
if (UCharacter.isSupplementaryCodePoint(-1))
errln("-1");
errln("0x110000");
}
- @org.junit.Test
+ @Test
public void TestIsHighSurrogate() {
if (UCharacter
.isHighSurrogate((char) (UCharacter.MIN_HIGH_SURROGATE - 1)))
errln("0xdc00");
}
- @org.junit.Test
+ @Test
public void TestIsLowSurrogate() {
if (UCharacter
.isLowSurrogate((char) (UCharacter.MIN_LOW_SURROGATE - 1)))
errln("0xe000");
}
- @org.junit.Test
+ @Test
public void TestIsSurrogatePair() {
if (UCharacter.isSurrogatePair(
(char) (UCharacter.MIN_HIGH_SURROGATE - 1),
errln("0xd800,0xdc00");
}
- @org.junit.Test
+ @Test
public void TestCharCount() {
UCharacter.charCount(-1);
UCharacter.charCount(UCharacter.MAX_CODE_POINT + 1);
errln("0x010000");
}
- @org.junit.Test
+ @Test
public void TestToCodePoint() {
final char[] pairs = {(char) (UCharacter.MIN_HIGH_SURROGATE + 0),
(char) (UCharacter.MIN_LOW_SURROGATE + 0),
}
}
- @org.junit.Test
+ @Test
public void TestCodePointAtBefore() {
String s = "" + UCharacter.MIN_HIGH_SURROGATE + // isolated high
UCharacter.MIN_HIGH_SURROGATE + // pair
}
- @org.junit.Test
+ @Test
public void TestToChars() {
char[] chars = new char[3];
int cp = UCharacter.toCodePoint(UCharacter.MIN_HIGH_SURROGATE,
}
}
- @org.junit.Test
+ @Test
public void TestCodePointCount() {
class Test {
String str(String s, int start, int limit) {
test.test("\ud800\udc00\udc00", 0, 3, 2);
}
- @org.junit.Test
+ @Test
public void TestOffsetByCodePoints() {
class Test {
String str(String s, int start, int count, int index, int offset) {
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;
* @author Syn Wee Quek
* @since nov 04 2000
*/
+@RunWith(JUnit4.class)
public final class UCharacterTest extends TestFmwk
{
// private variables =============================================
import java.util.ListIterator;
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;
* @author aheninger
*
*/
+@RunWith(JUnit4.class)
public class UCharacterThreadTest extends TestFmwk {
// constructor -----------------------------------------------------------
-
+
/**
* Private constructor to prevent initialisation
*/
public UCharacterThreadTest()
{
}
-
+
// public methods --------------------------------------------------------
-
+
//
// Test multi-threaded parallel calls to UCharacter.getName(codePoint)
// Regression test for ticket 6264.
this.correctName = correctName;
}
+ @Override
public void run() {
for(int i=0; i<10000; i++) {
actualName = UCharacter.getName(codePoint);
package com.ibm.icu.dev.test.lang;
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;
import com.ibm.icu.lang.UProperty;
+@RunWith(JUnit4.class)
public class UPropertyAliasesTest extends TestFmwk {
-
+
public UPropertyAliasesTest() {}
-
+
/**
* Test the property names and property value names API.
*/
}
}
}
-
+
int i = UCharacter.getIntPropertyMinValue(
UProperty.CANONICAL_COMBINING_CLASS);
try {
for (; i <= UCharacter.getIntPropertyMaxValue(
UProperty.CANONICAL_COMBINING_CLASS);
- i ++) {
+ i ++) {
UCharacter.getPropertyValueName(
UProperty.CANONICAL_COMBINING_CLASS,
i, UProperty.NameChoice.LONG);
}
- }
+ }
catch (IllegalArgumentException e) {
- errln("0x" + Integer.toHexString(i)
+ errln("0x" + Integer.toHexString(i)
+ " should have a null property value name");
}
}
package com.ibm.icu.dev.test.lang;
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.UTF16Util;
* @author Syn Wee Quek
* @since feb 09 2001
*/
+@RunWith(JUnit4.class)
public final class UTF16Test extends TestFmwk
{
// constructor ===================================================
UTF16.charAt(replaceable, 13) != 0x10002) {
errln("FAIL Getting character from replaceable error" );
}
-
+
StringBuffer strbuffer = new StringBuffer("0xD805");
UTF16.charAt((CharSequence)strbuffer, 0);
}
'A',
-1,
};
-
+
final String cpString = "" +
UCharacter.MIN_HIGH_SURROGATE +
import java.util.Collection;
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;
* @test
* @summary General test of UnicodeSet string span.
*/
+@RunWith(JUnit4.class)
public class UnicodeSetStringSpanTest extends TestFmwk {
// Simple test first, easier to debug.
@Test
}
pattern = "[d{cd}{bcd}{ab}]";
- set = (UnicodeSet)set.cloneAsThawed();
+ set = set.cloneAsThawed();
set.applyPattern(pattern).freeze();
s16 = "abbcdabcdabd";
if ( set.spanBack(s16, 12, SpanCondition.CONTAINED) != 0
* Verify that we get the same results whether we look at text with contains(), span() or spanBack(), using unfrozen
* or frozen versions of the set, and using the set or its complement (switching the spanConditions accordingly).
* The latter verifies that set.span(spanCondition) == set.complement().span(!spanCondition).
- *
+ *
* The expectLimits[] are either provided by the caller (with expectCount>=0) or returned to the caller (with an
* input expectCount<0).
*/
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;
* @test
* @summary General test of UnicodeSet
*/
+@RunWith(JUnit4.class)
public class UnicodeSetTest extends TestFmwk {
static final String NOT = "%%%%";
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;
import com.ibm.icu.text.UnicodeSetIterator;
+@RunWith(JUnit4.class)
public class BasicTest extends TestFmwk {
String[][] canonTests = {
// Input Decomposed Composed
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;
import com.ibm.icu.text.UTF16;
import com.ibm.icu.text.UnicodeSet;
+@RunWith(JUnit4.class)
public class ConformanceTest extends TestFmwk {
Normalizer 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;
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;
UnicodeNormalizer unicode_NFC;
UnicodeNormalizer unicode_NFKD;
UnicodeNormalizer unicode_NFKC;
-
+
public NormalizationMonkeyTest() {
}
-
+
@Test
public void TestNormalize() {
if (unicode_NFD == null) {
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
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() {
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;
// TODO: fit into test framework
+@RunWith(JUnit4.class)
public class TestCanonicalIterator extends TestFmwk {
-
+
static final boolean SHOW_NAMES = false;
static final String testArray[][] = {
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;
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
// 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) {
}
}
}
-
+
private void expectEqual(String message, String item, Object a, Object b) {
if (!a.equals(b)) {
errln("FAIL: " + message + getReadable(item));
logln("\t" + getReadable(b));
}
}
-
+
//Transliterator name = null;
//Transliterator hex = null;
-
+
public String getReadable(Object obj) {
if (obj == null) return "null";
String s = obj.toString();
//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;
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) {
}
}
-
+
// check that zeros optimization doesn't mess up.
/*
if (true) {
}
}
*/
-
+
mixedCounter++;
if (!gotSource || !gotDecomp || !gotComp) {
errln("FAIL CanonicalIterator: " + s + " decomp: " +decomp+" comp: "+comp);
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();
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;
import com.ibm.icu.text.Normalizer;
import com.ibm.icu.text.StringCharacterIterator;
+@RunWith(JUnit4.class)
public class TestDeprecatedNormalizerAPI extends TestFmwk
-{
+{
public TestDeprecatedNormalizerAPI() {
}
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()");
}
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;
* @author Markus Scherer
* @since 2010jul10
*/
+@RunWith(JUnit4.class)
public class UTS46Test extends TestFmwk {
public UTS46Test() {
int commonOptions=
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;
import com.ibm.icu.text.UnicodeSet;
+@RunWith(JUnit4.class)
public class UnicodeNormalizerConformanceTest extends TestFmwk {
UnicodeNormalizer normalizer_C, normalizer_D, normalizer_KC, normalizer_KD;
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"
};
// 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) {
logln("Total: " + passCount + " lines passed");
}
}
-
+
/**
* Verify the conformance of the given line of the Unicode
* normalization (UTR 15) test suite file. For each line,
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
}
// Our field is from pos..delim-1.
buf.setLength(0);
-
+
String toHex = s.substring(pos,delim);
pos = delim;
int index = 0;
index = spacePos+1;
}
}
-
+
if (buf.length() < 1) {
throw new IllegalArgumentException("Empty field " + i + " in " + s);
}
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
hexsplit(line, ';', fields, buf);
checkConformance(fields, line);
}
-
+
}
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;
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
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;
* @author sgill
*
*/
+@RunWith(JUnit4.class)
public class AbstractBreakIteratorTests extends TestFmwk {
private class AbstractBreakIterator extends 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;
import com.ibm.icu.text.BreakIterator;
+@RunWith(JUnit4.class)
public class BreakIteratorRegTest extends TestFmwk
{
@Test
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);
}
//Locale[] locales = BreakIterator.getAvailableLocales();
-
+
assertTrue(BreakIterator.unregister(key2), "unregister us word (thai word)");
assertTrue(!BreakIterator.unregister(key2), "unregister second time");
boolean error = false;
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);
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;
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;
/**
* 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
**/
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;
* older class RBBITestMonkey.
*/
+@RunWith(JUnit4.class)
public class RBBIMonkeyTest extends TestFmwk {
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() {
}
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;
* See the data file for a description of the tests.
*
*/
+@RunWith(JUnit4.class)
public class RBBITestExtended extends TestFmwk {
public RBBITestExtended() {
}
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;
* Ported from ICU4C, original code in file source/test/intltest/rbbitst.cpp
*
*/
+@RunWith(JUnit4.class)
public class RBBITestMonkey extends TestFmwk {
//
// class RBBIMonkeyKind
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;
/**
* Regression test for Arabic shaping.
*/
+@RunWith(JUnit4.class)
public class ArabicShapingRegTest extends TestFmwk {
/* constants copied from ArabicShaping for convenience */
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;
/**
* @author limaoyu
- *
+ *
*/
+@RunWith(JUnit4.class)
public class IDNAConformanceTest extends TestFmwk {
@Test
public void TestConformance() {
TreeMap inputData = null;
-
+
try {
inputData = ReadInput.getInputData();
} catch (UnsupportedEncodingException e) {
errln(e.getMessage());
return;
}
-
+
Set keyMap = inputData.keySet();
for (Iterator iter = keyMap.iterator(); iter.hasNext();) {
Long element = (Long) iter.next();
boolean failed = false;
if ("toascii".equals(tempHash.get("type"))) {
-
+
//get the result
try {
//by default STD3 rules are not used, but if the description
//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,
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");
}
}
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");
}
}
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");
}
}
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 '>'
/**
* This class is used to read test data from TestInput file.
- *
+ *
* @author limaoyu
- *
+ *
*/
public static class ReadInput {
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;
/**
* @author ram
*/
+@RunWith(JUnit4.class)
public class TestIDNA extends TestFmwk {
private StringPrepParseException unassignedException = new StringPrepParseException("",StringPrepParseException.UNASSIGNED_ERROR);
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;
* 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);
// 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{
// 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{
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<TestData.domainNames1Uni.length; i++){
doTestIDNToASCII(TestData.domainNames1Uni[i],TestData.domainNamesToASCIIOut[i],IDNAReference.DEFAULT, null);
doTestIDNToASCII(TestData.domainNames1Uni[i],TestData.domainNamesToASCIIOut[i],IDNAReference.ALLOW_UNASSIGNED, null);
doTestIDNToASCII(TestData.domainNames1Uni[i],TestData.domainNamesToASCIIOut[i],IDNAReference.USE_STD3_RULES, null);
doTestIDNToASCII(TestData.domainNames1Uni[i],TestData.domainNamesToASCIIOut[i],IDNAReference.ALLOW_UNASSIGNED|IDNAReference.USE_STD3_RULES, 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 TestIDNToUnicode() throws Exception{
warnln("Could not load NamePrepTransform data");
}catch(java.lang.NoClassDefFoundError ex){
warnln("Could not load NamePrepTransform data");
- }
+ }
}
-
- private void doTestToUnicode(String src, String expected, int options, Object expectedException)
+
+ private void doTestToUnicode(String src, String expected, int options, Object expectedException)
throws Exception{
if (!IDNAReference.isReady()) {
StringBuffer inBuf = new StringBuffer(src);
UCharacterIterator inIter = UCharacterIterator.getInstance(src);
try{
-
+
StringBuffer out = IDNAReference.convertToUnicode(src,options);
if(expected!=null && out != null && !out.toString().equals(expected)){
- errln("convertToUnicode did not return expected result with options : "+ options +
+ errln("convertToUnicode did not return expected result with options : "+ options +
" Expected: " + prettify(expected)+" Got: "+prettify(out));
}
if(expectedException!=null && !unassignedException.equals(expectedException)){
}
}
try{
-
+
StringBuffer out = IDNAReference.convertToUnicode(inBuf,options);
if(expected!=null && out != null && !out.toString().equals(expected)){
- errln("convertToUnicode did not return expected result with options : "+ options +
+ errln("convertToUnicode did not return expected result with options : "+ options +
" Expected: " + prettify(expected)+" Got: "+out);
}
if(expectedException!=null && !unassignedException.equals(expectedException)){
errln("convertToUnicode did not get the expected exception for source: " + prettify(src) +" Got: "+ ex.toString());
}
}
-
+
try{
StringBuffer out = IDNAReference.convertToUnicode(inIter,options);
if(expected!=null && out != null && !out.toString().equals(expected)){
}
}
}
-
- private void doTestIDNToUnicode(String src, String expected, int options, Object expectedException)
+
+ private void doTestIDNToUnicode(String src, String expected, int options, Object expectedException)
throws Exception{
if (!IDNAReference.isReady()) {
StringBuffer inBuf = new StringBuffer(src);
UCharacterIterator inIter = UCharacterIterator.getInstance(src);
try{
-
+
StringBuffer out = IDNAReference.convertIDNToUnicode(src,options);
if(expected!=null && out != null && !out.toString().equals(expected)){
- errln("convertToUnicode did not return expected result with options : "+ options +
+ errln("convertToUnicode did not return expected result with options : "+ options +
" Expected: " + prettify(expected)+" Got: "+prettify(out));
}
if(expectedException!=null && !unassignedException.equals(expectedException)){
try{
StringBuffer out = IDNAReference.convertIDNToUnicode(inBuf,options);
if(expected!=null && out != null && !out.toString().equals(expected)){
- errln("convertToUnicode did not return expected result with options : "+ options +
+ errln("convertToUnicode did not return expected result with options : "+ options +
" Expected: " + prettify(expected)+" Got: "+out);
}
if(expectedException!=null && !unassignedException.equals(expectedException)){
errln("convertToUnicode did not get the expected exception for source: " +src +" Got: "+ ex.toString());
}
}
-
+
try{
StringBuffer out = IDNAReference.convertIDNToUnicode(inIter,options);
if(expected!=null && out != null && !out.toString().equals(expected)){
}
}
}
- private void doTestToASCII(String src, String expected, int options, Object expectedException)
+ private void doTestToASCII(String src, String expected, int options, Object expectedException)
throws Exception{
if (!IDNAReference.isReady()) {
StringBuffer inBuf = new StringBuffer(src);
UCharacterIterator inIter = UCharacterIterator.getInstance(src);
try{
-
+
StringBuffer out = IDNAReference.convertToASCII(src,options);
if(!unassignedException.equals(expectedException) && expected!=null && out != null && expected!=null && out != null && !out.toString().equals(expected.toLowerCase())){
- errln("convertToASCII did not return expected result with options : "+ options +
+ errln("convertToASCII did not return expected result with options : "+ options +
" Expected: " + expected+" Got: "+out);
- }
+ }
if(expectedException!=null && !unassignedException.equals(expectedException)){
errln("convertToASCII did not get the expected exception. The operation succeeded!");
}
errln("convertToASCII did not get the expected exception for source: " +src +" Got: "+ ex.toString());
}
}
-
- try{
+
+ try{
StringBuffer out = IDNAReference.convertToASCII(inBuf,options);
if(!unassignedException.equals(expectedException) && expected!=null && out != null && expected!=null && out != null && !out.toString().equals(expected.toLowerCase())){
- errln("convertToASCII did not return expected result with options : "+ options +
+ errln("convertToASCII did not return expected result with options : "+ options +
" Expected: " + expected+" Got: "+out);
}
if(expectedException!=null && !unassignedException.equals(expectedException)){
errln("convertToASCII did not get the expected exception for source: " +src +" Got: "+ ex.toString());
}
}
-
+
try{
StringBuffer out = IDNAReference.convertToASCII(inIter,options);
if(!unassignedException.equals(expectedException) && expected!=null && out != null && expected!=null && out != null && !out.toString().equals(expected.toLowerCase())){
}
}
}
- private void doTestIDNToASCII(String src, String expected, int options, Object expectedException)
+ private void doTestIDNToASCII(String src, String expected, int options, Object expectedException)
throws Exception{
if (!IDNAReference.isReady()) {
StringBuffer inBuf = new StringBuffer(src);
UCharacterIterator inIter = UCharacterIterator.getInstance(src);
try{
-
+
StringBuffer out = IDNAReference.convertIDNToASCII(src,options);
if(expected!=null && out != null && !out.toString().equals(expected)){
- errln("convertToIDNAReferenceASCII did not return expected result with options : "+ options +
+ errln("convertToIDNAReferenceASCII did not return expected result with options : "+ options +
" Expected: " + expected+" Got: "+out);
}
if(expectedException!=null && !unassignedException.equals(expectedException)){
try{
StringBuffer out = IDNAReference.convertIDNtoASCII(inBuf,options);
if(expected!=null && out != null && !out.toString().equals(expected)){
- errln("convertToIDNAReferenceASCII did not return expected result with options : "+ options +
+ errln("convertToIDNAReferenceASCII did not return expected result with options : "+ options +
" Expected: " + expected+" Got: "+out);
- }
+ }
if(expectedException!=null && !unassignedException.equals(expectedException)){
errln("convertToIDNAReferenceSCII did not get the expected exception. The operation succeeded!");
}
errln("convertToIDNAReferenceSCII did not get the expected exception for source: " +src +" Got: "+ ex.toString());
}
}
-
+
try{
StringBuffer out = IDNAReference.convertIDNtoASCII(inIter,options);
if(expected!=null && out != null && !out.toString().equals(expected)){
errln("convertIDNToASCII did not return expected result with options : "+ options +
" Expected: " + expected+" Got: "+ out);
}
-
+
if(expectedException!=null && !unassignedException.equals(expectedException)){
errln("convertIDNToASCII did not get the expected exception. The operation succeeded!");
}
public void TestConformance()throws Exception{
try{
for(int i=0; i<TestData.conformanceTestCases.length;i++){
-
+
TestData.ConformanceTestCase testCase = TestData.conformanceTestCases[i];
if(testCase.expected != null){
//Test toASCII
warnln("Could not load NamePrepTransform data");
}catch(java.lang.NoClassDefFoundError ex){
warnln("Could not load NamePrepTransform data");
- }
+ }
}
@Test
public void TestNamePrepConformance() throws Exception{
errln("Did not get the expected exception for source: " +testCase.input +" Got: "+ ex.toString());
}
}
-
+
try{
iter.setToStart();
StringBuffer output = namePrep.prepare(iter,NamePrepTransform.ALLOW_UNASSIGNED);
warnln("Could not load NamePrepTransformData");
}catch(java.lang.NoClassDefFoundError ex){
warnln("Could not load NamePrepTransform data");
- }
-
+ }
+
}
@Test
public void TestErrorCases() throws Exception{
}
}
if(errCase.useSTD3ASCIIRules!=true){
-
+
// Test IDNToASCII
doTestIDNToASCII(new String(errCase.unicode),errCase.ascii,IDNAReference.DEFAULT,errCase.expected);
doTestIDNToASCII(new String(errCase.unicode),errCase.ascii,IDNAReference.ALLOW_UNASSIGNED,errCase.expected);
-
+
}else{
doTestIDNToASCII(new String(errCase.unicode),errCase.ascii,IDNAReference.USE_STD3_RULES,errCase.expected);
}
-
+
//TestToUnicode
if(errCase.testToUnicode==true){
if(errCase.useSTD3ASCIIRules!=true){
// Test IDNToUnicode
doTestIDNToUnicode(errCase.ascii,new String(errCase.unicode),IDNAReference.DEFAULT,errCase.expected);
doTestIDNToUnicode(errCase.ascii,new String(errCase.unicode),IDNAReference.ALLOW_UNASSIGNED,errCase.expected);
-
+
}else{
doTestIDNToUnicode(errCase.ascii,new String(errCase.unicode),IDNAReference.USE_STD3_RULES,errCase.expected);
}
warnln("Could not load NamePrepTransform data");
}catch(java.lang.NoClassDefFoundError ex){
warnln("Could not load NamePrepTransform data");
- }
+ }
}
private void doTestCompare(String s1, String s2, boolean isEqual){
try{
int retVal = IDNAReference.compare(s1,s2,IDNAReference.DEFAULT);
if(isEqual==true && retVal != 0){
- errln("Did not get the expected result for s1: "+ prettify(s1)+
+ errln("Did not get the expected result for s1: "+ prettify(s1)+
" s2: "+prettify(s2));
}
retVal = IDNAReference.compare(new StringBuffer(s1), new StringBuffer(s2), IDNAReference.DEFAULT);
if(isEqual==true && retVal != 0){
- errln("Did not get the expected result for s1: "+ prettify(s1)+
+ errln("Did not get the expected result for s1: "+ prettify(s1)+
" s2: "+prettify(s2));
}
retVal = IDNAReference.compare(UCharacterIterator.getInstance(s1), UCharacterIterator.getInstance(s2), IDNAReference.DEFAULT);
if(isEqual==true && retVal != 0){
- errln("Did not get the expected result for s1: "+ prettify(s1)+
+ errln("Did not get the expected result for s1: "+ prettify(s1)+
" s2: "+prettify(s2));
}
}catch(Exception e){
e.printStackTrace();
errln("Unexpected exception thrown by IDNAReference.compare");
}
-
+
try{
int retVal = IDNAReference.compare(s1,s2,IDNAReference.ALLOW_UNASSIGNED);
if(isEqual==true && retVal != 0){
- errln("Did not get the expected result for s1: "+ prettify(s1)+
+ errln("Did not get the expected result for s1: "+ prettify(s1)+
" s2: "+prettify(s2));
}
retVal = IDNAReference.compare(new StringBuffer(s1), new StringBuffer(s2), IDNAReference.ALLOW_UNASSIGNED);
if(isEqual==true && retVal != 0){
- errln("Did not get the expected result for s1: "+ prettify(s1)+
+ errln("Did not get the expected result for s1: "+ prettify(s1)+
" s2: "+prettify(s2));
}
retVal = IDNAReference.compare(UCharacterIterator.getInstance(s1), UCharacterIterator.getInstance(s2), IDNAReference.ALLOW_UNASSIGNED);
if(isEqual==true && retVal != 0){
- errln("Did not get the expected result for s1: "+ prettify(s1)+
+ errln("Did not get the expected result for s1: "+ prettify(s1)+
" s2: "+prettify(s2));
}
}catch(Exception e){
errln("Unexpected exception thrown by IDNAReference.compare");
- }
+ }
}
@Test
public void TestCompare() throws Exception{
ascii1.append(com);
try{
for(int i=0;i< TestData.unicodeIn.length; i++){
-
+
// for every entry in unicodeIn array
// prepend www. and append .com
source.setLength(4);
source.append(TestData.unicodeIn[i]);
source.append(com);
-
+
// a) compare it with itself
doTestCompare(source.toString(),source.toString(),true);
-
+
// b) compare it with asciiIn equivalent
doTestCompare(source.toString(),www+TestData.asciiIn[i]+com,true);
-
+
// c) compare it with unicodeIn not equivalent
if(i==0){
doTestCompare(source.toString(), uni1.toString(), false);
warnln("Could not load NamePrepTransform data");
}catch(java.lang.NoClassDefFoundError ex){
warnln("Could not load NamePrepTransform data");
- }
+ }
}
// test and ascertain
return;
}
- StringBuffer expected;
+ StringBuffer expected;
StringBuffer chained;
-
+
// test convertIDNToASCII
expected = IDNAReference.convertIDNToASCII(source,IDNAReference.DEFAULT);
chained = expected;
}
if(!expected.toString().equals(chained.toString())){
errln("Chaining test failed for convertToASCII");
- }
-
+ }
+
}
// test and ascertain
// func(func(func(src))) == func(src)
return;
}
- StringBuffer expected;
+ StringBuffer expected;
StringBuffer chained;
-
+
// test convertIDNToUnicode
expected = IDNAReference.convertIDNToUnicode(source,IDNAReference.DEFAULT);
chained = expected;
warnln("Could not load NamePrepTransform data");
}catch(java.lang.NoClassDefFoundError ex){
warnln("Could not load NamePrepTransform data");
- }
+ }
}
@Test
public void TestRootLabelSeparator() throws Exception{
ascii1.append(com);
try{
for(int i=0;i< TestData.unicodeIn.length; i++){
-
+
// for every entry in unicodeIn array
// prepend www. and append .com
source.setLength(4);
source.append(TestData.unicodeIn[i]);
source.append(com);
-
+
// a) compare it with itself
doTestCompare(source.toString(),source.toString(),true);
-
+
// b) compare it with asciiIn equivalent
doTestCompare(source.toString(),www+TestData.asciiIn[i]+com,true);
-
+
// c) compare it with unicodeIn not equivalent
if(i==0){
doTestCompare(source.toString(), uni1.toString(), false);
warnln("Could not load NamePrepTransform data");
}catch(java.lang.NoClassDefFoundError ex){
warnln("Could not load NamePrepTransform data");
- }
+ }
}
}
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.StringPrep;
* @author ram
*
*/
+@RunWith(JUnit4.class)
public class TestStringPrep extends TestFmwk {
/*
There are several special identifiers ("who") which need to be
*/
private String[] mixed_prep_data ={
"OWNER@",
- "GROUP@",
- "EVERYONE@",
- "INTERACTIVE@",
- "NETWORK@",
- "DIALUP@",
- "BATCH@",
- "ANONYMOUS@",
+ "GROUP@",
+ "EVERYONE@",
+ "INTERACTIVE@",
+ "NETWORK@",
+ "DIALUP@",
+ "BATCH@",
+ "ANONYMOUS@",
"AUTHENTICATED@",
"\u0930\u094D\u092E\u094D\u0915\u094D\u0937\u0947\u0924\u094D@slip129-37-118-146.nc.us.ibm.net",
"\u0936\u094d\u0930\u0940\u092e\u0926\u094d@saratoga.pe.utexas.edu",
}catch(Exception e){
errln("mixed_prepare for string: " + mixed_prep_data[i] +" failed with " + e.toString());
}
- }
+ }
/* test the error condition */
{
String src = "OWNER@oss.software.ibm.com";
if(!expected.equals(e)){
errln("Did not get the expected exception");
}
- }
+ }
}
}
@Test
public void TestCSPrep(){
-
+
// Checking for bidi is turned off
String src = "\uC138\uACC4\uC758\uBAA8\uB4E0\uC0AC\uB78C\uB4E4\uC774\u0644\u064A\u0647\uD55C\uAD6D\uC5B4\uB97C\uC774\uD574\uD55C\uB2E4\uBA74";
try{
}catch(Exception e){
errln("Got unexpected exception: " + e.toString());
}
-
+
// normalization is turned off
try{
src = "www.\u00E0\u00B3\u00AF.com";
}catch(Exception e){
errln("Got unexpected exception: " + e.toString());
}
-
+
// test case insensitive string
try{
src = "THISISATEST";
errln("Got unexpected exception: " + e.toString());
}
}
-
+
@Test
public void TestCoverage(){
if (new StringPrepParseException("coverage", 0, "", 0,0) == null){
errln("Construct StringPrepParseException(String, int, String, int, int)");
}
}
-
+
/* Tests the method public static StringPrep getInstance(int profile) */
@Test
public void TestGetInstance(){
} catch(Exception e){
}
}
-
+
int[] max_profile_cases = {StringPrep.RFC4518_LDAP_CI+1, StringPrep.RFC4518_LDAP_CI+2, StringPrep.RFC4518_LDAP_CI+5, StringPrep.RFC4518_LDAP_CI+10};
for(int i=0; i<max_profile_cases.length; i++){
try{
} catch(Exception e){
}
}
-
+
// Tests when "if (instance == null)", "if (stream != null)", "if (instance != null)", and "if (ref != null)" is true
int[] cases = {0, 1, StringPrep.RFC4518_LDAP_CI};
for(int i=0; i<cases.length; i++){
}
}
}
-
+
/* Test the method public String prepare(String src, int options) */
@Test
public void TestPrepare() {
errln("StringPrep.prepare(String,int) was not suppose to return " + "an exception.");
}
}
-
+
/*
* Tests the constructor public StringPrepParseException(String message, int error, String rules, int pos, int
* lineNumber)
exceptions[i] = new StringPrepParseException(locales[i].toString(), i, rules, i, i);
}
}
-
+
/* Tests the method public boolean equals(Object other) for StringPrepParseException */
@Test
public void TestStringPrepParseExceptionEquals(){
StringPrepParseException sppe = new StringPrepParseException("dummy",0,"dummy",0,0);
StringPrepParseException sppe_clone = new StringPrepParseException("dummy",0,"dummy",0,0);
StringPrepParseException sppe1 = new StringPrepParseException("dummy1",1,"dummy1",0,0);
-
+
// Tests when "if(!(other instanceof StringPrepParseException))" is true
if(sppe.equals(0)){
errln("StringPrepParseException.equals(Object) is suppose to return false when " +
errln("StringPrepParseException.equals(Object) is suppose to return false when " +
"passing string '0'");
}
-
+
// Tests when "if(!(other instanceof StringPrepParseException))" is true
if(!sppe.equals(sppe)){
errln("StringPrepParseException.equals(Object) is suppose to return true when " +
"comparing to another object that isn't the same");
}
}
-
+
/* Tests the method public int getError() */
@Test
public void TestGetError(){
}
}
}
-
+
/* Tests the private void setPreContext(char[] str, int pos) */
@Test
public void TestSetPreContext(){
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.StringPrep;
* @author Michael Ow
*
*/
+@RunWith(JUnit4.class)
public class TestStringPrepProfiles extends TestFmwk {
/*
* The format of the test cases should be the following:
* src string2
* expected result2
* ...
- * }
- *
+ * }
+ *
* *Note: For expected failures add FAIL to beginning of the source string and for expected result use "FAIL".
*/
private static String[][] testCases = {
"suffixdomain \u007Ffiend"
}
};
-
+
private int getOptionFromProfileName(String profileName) {
if (profileName.equals("RFC4013_SASLPREP")) {
return StringPrep.RFC4013_SASLPREP;
return StringPrep.RFC3530_NFS4_MIXED_PREP_PREFIX;
} else if (profileName.equals("RFC3530_NFS4_MIXED_PREP_SUFFIX")) {
return StringPrep.RFC3530_NFS4_MIXED_PREP_SUFFIX;
- }
-
+ }
+
// Should not happen.
return -1;
}
-
+
@Test
public void TestProfiles() {
String profileName = null;
String result = null;
String src = null;
String expected = null;
-
+
for (int i = 0; i < testCases.length; i++) {
for (int j = 0; j < testCases[i].length; j++) {
if (j == 0) {
profileName = testCases[i][j];
-
+
sprep = StringPrep.getInstance(getOptionFromProfileName(profileName));
} else {
src = testCases[i][j];
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;
import com.ibm.icu.text.UnicodeSet;
import com.ibm.icu.util.ULocale;
+@RunWith(JUnit4.class)
public class SpoofCheckerTest extends TestFmwk {
/*
* Identifiers for verifying that spoof checking is minimally alive and working.
package com.ibm.icu.dev.test.timescale;
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;
/**
* Test UniversalTimeScale API
*/
+@RunWith(JUnit4.class)
public class TimeScaleAPITest extends TestFmwk
{
/**
- *
+ *
*/
public TimeScaleAPITest()
{
}
-
+
@Test
public void TestBigDecimalFromBigDecimal()
{
BigDecimal bigZero = new BigDecimal(0);
-
+
try {
UniversalTimeScale.bigDecimalFrom(bigZero, -1);
errln("bigDecimalFrom(bigZero, -1) did not throw IllegalArgumentException.");
} catch (IllegalArgumentException iae) {
logln("PASS: UniversalTimeScale.bigDecimalFrom failed as expected");
}
-
+
for (int scale = 0; scale < UniversalTimeScale.MAX_SCALE; scale += 1) {
try {
UniversalTimeScale.bigDecimalFrom(bigZero, scale);
errln("bigDecimalFrom(bigZero, " + scale + ") threw IllegalArgumentException.");
}
}
-
+
try {
UniversalTimeScale.bigDecimalFrom(bigZero, UniversalTimeScale.MAX_SCALE);
errln("from(bigZero, MAX_SCALE) did not throw IllegalArgumetException.");
logln("PASS: UniversalTimeScale.bigDecimalFrom failed as expected");
}
}
-
+
@Test
public void TestBigDecimalFromDouble()
{
} catch (IllegalArgumentException iae) {
logln("PASS: UniversalTimeScale.bigDecimalFrom failed as expected");
}
-
+
for (int scale = 0; scale < UniversalTimeScale.MAX_SCALE; scale += 1) {
try {
UniversalTimeScale.bigDecimalFrom(0.0, scale);
errln("bigDecimalFrom(0.0, " + scale + ") threw IllegalArgumentException.");
}
}
-
+
try {
UniversalTimeScale.bigDecimalFrom(0.0, UniversalTimeScale.MAX_SCALE);
errln("from(0.0, MAX_SCALE) did not throw IllegalArgumetException.");
logln("PASS: UniversalTimeScale.bigDecimalFrom failed as expected");
}
}
-
+
@Test
public void TestBigDecimalFromLong()
{
} catch (IllegalArgumentException iae) {
logln("PASS: UniversalTimeScale.bigDecimalFrom failed as expected");
}
-
+
for (int scale = 0; scale < UniversalTimeScale.MAX_SCALE; scale += 1) {
try {
UniversalTimeScale.bigDecimalFrom(0L, scale);
errln("bigDecimalFrom(0L, " + scale + ") threw IllegalArgumentException.");
}
}
-
+
try {
UniversalTimeScale.bigDecimalFrom(0L, UniversalTimeScale.MAX_SCALE);
errln("from(0L, MAX_SCALE) did not throw IllegalArgumetException.");
logln("PASS: UniversalTimeScale.bigDecimalFrom failed as expected");
}
}
-
+
@Test
public void TestFromLong()
{
long result;
-
+
try {
result = UniversalTimeScale.from(0L, -1);
errln("from(0L, -1) did not throw IllegalArgumentException.");
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);
-
+
try {
result = UniversalTimeScale.from(0L, scale);
logln("from(0L, " + scale + ") returned " + result);
} catch (IllegalArgumentException iae) {
errln("from(fromMin, " + scale + ") threw IllegalArgumentException.");
}
-
+
if (fromMin > Long.MIN_VALUE) {
try {
result = UniversalTimeScale.from(fromMin - 1, scale);
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);
}
}
}
-
+
try {
result = UniversalTimeScale.from(0L, UniversalTimeScale.MAX_SCALE);
errln("from(0L, MAX_SCALE) did not throw IllegalArgumetException.");
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);
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");
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);
errln("toBigDecimal(bigZero, " + scale + ") threw IllegalArgumentException.");
}
}
-
+
try {
UniversalTimeScale.toBigDecimal(bigZero, UniversalTimeScale.MAX_SCALE);
errln("toBigDecimal(bigZero, MAX_SCALE) did not throw IllegalArgumetException.");
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);
errln("toBigDecimalTrunc(bigZero, " + scale + ") threw IllegalArgumentException.");
}
}
-
+
try {
UniversalTimeScale.toBigDecimalTrunc(bigZero, UniversalTimeScale.MAX_SCALE);
errln("toBigDecimalTrunc(bigZero, MAX_SCALE) did not throw IllegalArgumetException.");
logln("PASS: UniversalTimeScale.toBigDecimalTrunc failed as expected");
}
}
-
+
@Test
public void TestToBigDecimalFromLong()
{
} 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);
errln("toBigDecimal(0L, " + scale + ") threw IllegalArgumentException.");
}
}
-
+
try {
UniversalTimeScale.toBigDecimal(0L, UniversalTimeScale.MAX_SCALE);
errln("toBigDecimal(0L, MAX_SCALE) did not throw IllegalArgumetException.");
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);
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);
}
}
}
-
+
try {
result = UniversalTimeScale.toLong(0L, UniversalTimeScale.MAX_SCALE);
errln("toLong(0L, MAX_SCALE) did not throw IllegalArgumetException.");
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;
* 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
{
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);
}
}
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()
{
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);
}
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;
* generating ramdon values in range and making sure
* that they round-trip correctly.
*/
+@RunWith(JUnit4.class)
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()
{
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;
}
}
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;
/**
* Class for testing TimeZones for consistency
* @author Davis
- *
+ *
*/
+@RunWith(JUnit4.class)
public class TimeZoneAliasTest extends TestFmwk {
/**
* There are two things to check aliases for:<br>
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));
}
errln(
"Aliases Unsymmetric: "
+ id + " => " + Zone.bf.join(aliasesSet)
- + "; "
+ + "; "
+ otherId + " => " + Zone.bf.join(otherAliases));
}
if (zone.findOffsetOrdering(otherZone, seconds) != 0) {
}
}
}
-
+
/**
* We check to see that every timezone that is not an alias is actually different!
*/
@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");
last = testZone;
}
}
-
+
/**
* Utility for printing out zones to be translated.
*/
System.out.println(zone.toString(count++));
}
}
-
+
/** Utility; ought to be someplace common
*/
// remove dependency on bagformatter for now
}
}
-
+
/**
* 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,
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();
}
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) {
last = testZone;
}
}
-
+
static public Set getZoneSet() {
return zoneSet;
}
-
+
public static Set getUniqueZoneSet() {
return uniqueZoneSet;
}
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.
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) {
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);
}
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) {
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;
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
}
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
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;
* 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;
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 &&
{
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();
}
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();
}
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);
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;
/**
* 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.
-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
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.util.TimeZone;
import com.ibm.icu.util.ULocale;
+@RunWith(JUnit4.class)
public class TimeZoneRegressionTest extends TestFmwk {
@Test
public void Test4052967() {
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();
Date d3 = tempcal.getTime();
if (z.inDaylightTime(d3)) {
errln("Fail: DST not working as expected");
- }
+ }
}
/**
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");
*/
// Current orgnaization of data in zoneinfor.res allows negative
// values from DOM so comment these tests out
-
+
@Test
public void Test4184229() {
SimpleTimeZone zone = null;
// 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");
} catch(IllegalArgumentException e) {
logln("(h) " + e.getMessage());
}
-
+
}
/**
@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();
+ tzid + ") [13-arg constructor]");
}
}
-
+
// test bug #4265
@Test
public void TestJohannesburg() {
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 {
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 {
try {
wk.join();
} catch (InterruptedException ie) {
-
+
}
}
}
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;
/**
* Test cases for TimeZoneRule and RuleBasedTimeZone
*/
+@RunWith(JUnit4.class)
public class TimeZoneRuleTest extends TestFmwk {
private static final int HOUR = 60 * 60 * 1000;
"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,
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");
}
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");
}
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);
// 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");
// Descending/inclusive
compareTransitionsDescending(tz, rbtz, startTime + 1, until, true);
}
-
+
}
}
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");
}
} catch (IOException ioe) {
errln("FAIL: IO error while writing/reading VTIMEZONE data");
}
-
+
}
/*
}
/*
- * API coverage tests for TimeZoneRule
+ * API coverage tests for TimeZoneRule
*/
@Test
public void TestTimeZoneRuleCoverage() {
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};
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,
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) {
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);
} else {
logln("InitialTimeZoneRule i1 : " + str);
}
-
-
+
+
// TimeArrayTimeZoneRule#getStartTimes
long[] times = t1.getStartTimes();
if (times == null || times.length == 0 || times[0] != 0) {
errln("FAIL: Bad transition returned by SimpleTimeZone#getNextTransition");
}
}
-
+
/*
* API coverage test for VTimeZone
*/
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);
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" +
"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" +
+ tzt.getTime() + " Expected: " + expectedPrev);
}
}
-
+
@Test
public void TestBasicTimeZoneCoverage() {
TimeZone tz = TimeZone.getTimeZone("PST");
(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;
}
(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;
}
* 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;
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;
* @summary test TimeZone
* @build TimeZoneTest
*/
+@RunWith(JUnit4.class)
public class TimeZoneTest extends TestFmwk
{
static final int millisPerHour = 3600000;
*
* 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
public String getID() { return id; }
+ @Override
public boolean equals(Object o) {
ZoneDescriptor that = (ZoneDescriptor)o;
return that != null &&
daylight == that.daylight;
}
+ @Override
public String toString() {
int min = offset;
char sign = '+';
// 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 = {
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",
// 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;
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") &&
"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);
!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);
!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);
-
+
}
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);
}
}
// 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!");
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());
// jb4484
@Test
- public void TestSimpleTimeZoneSerialization()
+ public void TestSimpleTimeZoneSerialization()
{
SimpleTimeZone stz0 = new SimpleTimeZone(32400000, "MyTimeZone");
SimpleTimeZone stz1 = new SimpleTimeZone(32400000, "Asia/Tokyo");
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) {
}
}
}
-
+
@Test
public void TestCoverage(){
class StubTimeZone extends TimeZone{
* 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){
}
if (!stub.hasSameRules(stub2)){
errln("TimeZone.clone() object should hasSameRules");
-
+
}
}
@Test
}
// 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.");
}
}
// 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.");
}
}
}
}
-
+
@Test
public void Test11619_UnrecognizedTimeZoneID() {
VTimeZone vzone = VTimeZone.create("ABadTimeZoneId");
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() {}
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;
import com.ibm.icu.util.CharsTrieBuilder;
import com.ibm.icu.util.StringTrieBuilder;
+@RunWith(JUnit4.class)
public class CharsTrieTest extends TestFmwk {
public CharsTrieTest() {}
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;
/**
* @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();
logln("equals: " + cba4.equals(cba5));
logln("equals: " + cba.equals(cba4));
-
+
cba4.compact(false);
logln("equals: " + cba4.equals(cba5));
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();
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;
* @test
* @summary General test of Currency
*/
+@RunWith(JUnit4.class)
public class CurrencyTest extends TestFmwk {
/**
* Test of basic API.
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;
* @author srl
*
*/
+@RunWith(JUnit4.class)
public class DebugUtilitiesTest extends TestFmwk {
@Test
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;
// 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);
}
{
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;
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]);
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) {
if (strings == null || item >= strings.length) return olsonID;
return strings[item];
}
-
+
static String[][] zonesAliases = {
{"America/Atka", "America/Atka"},
{"America/Ensenada", "America/Ensenada"},
System.arraycopy(strings,0,result,2,strings.length);
return result;
}
-
+
Map bogusZones = null;
-
+
private Map getAliasMap() {
if (bogusZones == null) {
bogusZones = new TreeMap();
}
- 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();
+ ":\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) {
} 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
);
}
}
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"));
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);
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")));
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
*/
ByteBuffer bytes = ByteBuffer.wrap(array);
ICUBinary.Authenticate authenticate
= new ICUBinary.Authenticate() {
+ @Override
public boolean isDataVersionAcceptable(byte version[])
{
return version[0] == 1;
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;
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();
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;
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) {
super("Test Service");
}
+ @Override
public Key createKey(String id) {
return LocaleKey.createWithCanonicalFallback(id, null); // no fallback locale
}
// 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;
}
{
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);
}
}));
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);
}
ls.addListener(l1);
ServiceListener l2 = new ServiceListener() {
private int n;
+ @Override
public void serviceChanged(ICUService s) {
logln("listener 2 report " + n++ + " service changed: " + s);
}
// 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!!!
this.factoryID = factoryID + ": ";
}
+ @Override
protected Object handleCreate(ULocale loc, int kind, ICUService service) {
return factoryID + loc.toString();
}
+ @Override
protected Set getSupportedIDs() {
return ids;
}
supportedIDs = Collections.unmodifiableSet(result);
}
+ @Override
public Set getSupportedIDs() {
return supportedIDs;
}
+ @Override
public String getDisplayName(String id, ULocale locale) {
String prefix = "";
String suffix = "";
{
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);
}
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);
return null;
}
+ @Override
public void updateVisibleIDs(Map result) {
result.put("greeting", this);
}
+ @Override
public String getDisplayName(String id, ULocale locale) {
return "wrap '" + id + "'";
}
}
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) {
}
}
super(visible ? VISIBLE : INVISIBLE);
}
+ @Override
protected Set getSupportedIDs() {
return Collections.EMPTY_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;
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;
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;
}
this.setDaemon(true);
}
+ @Override
public void run() {
while (WAIT) {
Thread.yield();
super("REG " + name, service, delay);
}
+ @Override
protected void iterate() {
Factory f = new TestFactory(getCLV());
service.registerFactory(f);
factories = service.factories();
}
+ @Override
public void iterate() {
int s = factories.size();
if (s == 0) {
this.factories = factories;
}
+ @Override
public void iterate() {
if (n < factories.length) {
Factory f = factories[n++];
super("VIS " + name, service, delay);
}
+ @Override
protected void iterate() {
Set ids = service.getVisibleIDs();
Iterator iter = ids.iterator();
this.locale = locale;
}
+ @Override
protected void iterate() {
Map names = getDisplayNames(service,locale);
Iterator iter = names.entrySet().iterator();
actualID = new String[1];
}
+ @Override
protected void iterate() {
String id = getCLV();
Object o = service.get(id, actualID);
this.list = list;
}
+ @Override
protected void iterate() {
if (--n < 0) {
n = list.length - 1;
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());
}
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;
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 = {
{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")},
{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();
// +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);
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();
}
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);
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);
}
ULocale.setDefault(defLoc);
}
-
+
@Test
public void TestULocale() {
ULocale defLoc = ULocale.getDefault();
}
ULocale ul1 = new ULocale(oldLoc.toString());
ULocale ul2 = new ULocale(newLoc.toString());
-
+
String name1 = ul1.getDisplayName();
String name2 = ul2.getDisplayName();
if (!name1.equals(name2)) {
}
ULocale.setDefault(defLoc);
}
-
+
@Test
public void TestDisplayName() {
ULocale defLoc = ULocale.getDefault();
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());
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);
}
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;
/**
* Test cases for ULocale.LocaleBuilder
*/
+@RunWith(JUnit4.class)
public class LocaleBuilderTest extends TestFmwk {
@Test
public void TestLocaleBuilder() {
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);
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());
}
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;
* 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++){
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);
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){
logln("Got the expected measurement system for locale: " + locale);
}else{
errln("Did not get the expected measurement system for locale: "+ locale);
- }
+ }
}
}
}
set = s;
scs = scriptCodes;
}
+ @Override
public int hashCode() {
int hash = 0;
for (int i=0; i<scs.length && i<4; i++) {
hash = (hash<<8)+scs[i];
}
return hash;
- }
+ }
+ @Override
public boolean equals(Object other) {
ExemplarGroup o = (ExemplarGroup)other;
boolean r = Arrays.equals(scs, o.scs) &&
// such a broken hack !!!!!
// so in effect I can never test the script code for Indonesian :(
if(locale.toString().indexOf(("in"))<0){
- errln("UScript.getCode returned null for locale: " + locale);
+ errln("UScript.getCode returned null for locale: " + locale);
}
continue;
}
}
boolean existsInScript = false;
UnicodeSetIterator iter = new UnicodeSetIterator(exemplarSet);
- // iterate over the
+ // iterate over the
while (!existsInScript && iter.nextRange()) {
if (iter.codepoint != UnicodeSetIterator.IS_STRING) {
for(int j=0; j<sets.length; j++){
int[] scriptCodes = UScript.getCode(locale);
if (scriptCodes==null) {
if(locale.toString().indexOf(("in"))<0){
- errln("UScript.getCode returned null for locale: "+ locale);
+ errln("UScript.getCode returned null for locale: "+ locale);
}
continue;
}
for (int k=0; k<2; ++k) { // for casing option in (normal, uncased)
int option = (k==0) ? 0 : UnicodeSet.CASE;
- for(int h=0; h<2; ++h){
+ for(int h=0; h<2; ++h){
int type = (h==0) ? LocaleData.ES_STANDARD : LocaleData.ES_AUXILIARY;
UnicodeSet exemplarSet = ld.getExemplarSet(option, type);
}
boolean existsInScript = false;
UnicodeSetIterator iter = new UnicodeSetIterator(exemplarSet);
- // iterate over the
+ // iterate over the
while (!existsInScript && iter.nextRange()) {
if (iter.codepoint != UnicodeSetIterator.IS_STRING) {
for(int j=0; j<sets.length; j++){
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.util.LocaleMatcher;
* @author markdavis
*/
@SuppressWarnings("deprecation")
+@RunWith(JUnit4.class)
public class LocaleMatcherTest extends TestFmwk {
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.util.LocalePriorityList;
* Test the LanguagePriorityList
* @author markdavis@google.com
*/
+@RunWith(JUnit4.class)
public class LocalePriorityListTest extends TestFmwk {
@Test
public void testLanguagePriorityList() {
.build();
assertEquals(expected, list3.toString());
assertEquals(list, list3);
-
+
LocalePriorityList list4 = LocalePriorityList
.add(list).build();
assertEquals(expected, list4.toString());
assertEquals(list, list4);
-
+
LocalePriorityList list5 = LocalePriorityList.add("af, fr;q=0.9, en").build(true);
assertEquals("af, en, fr;q=0.9", list5.toString());
}
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.Region;
* @summary General test of Regions
*/
+@RunWith(JUnit4.class)
public class RegionTest extends TestFmwk {
String[][] knownRegions = {
// Code , Numeric , Parent, Type, Containing Continent
/**
* Test for known regions.
- */
+ */
@Test
public void TestKnownRegions() {
}
@Test
- public void TestGetContainedRegions() {
+ public void TestGetContainedRegions() {
for (String [] rd : knownRegions ) {
try {
Region r = Region.getInstance(rd[0]);
Set<Region> 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()));
}
}
}
@Test
- public void TestGetContainedRegionsWithType() {
+ public void TestGetContainedRegionsWithType() {
for (String [] rd : knownRegions ) {
try {
Region r = Region.getInstance(rd[0]);
Set<Region> 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()));
}
}
}
@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()) );
}
}
@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()) );
}
}
} catch (IllegalArgumentException ex ) {
errln("Known region " + data[i] + " was not recognized.");
- }
+ }
}
} catch (IllegalArgumentException ex ) {
errln("Known region " + inputID + " was not recognized.");
}
@Test
- public void TestContains() {
+ public void TestContains() {
for (String [] rd : knownRegions ) {
try {
Region r = Region.getInstance(rd[0]);
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 {
/**
public SimpleFormatterTest()
{
}
-
+
// public methods -----------------------------------------------
-
+
@Test
public void TestWithNoArguments() {
SimpleFormatter fmt = SimpleFormatter.compile("This doesn''t have templates '{0}");
SimpleFormatter.compile(
"Templates {1}{2} and {3} are here.").getTextWithNoArguments());
}
-
+
@Test
public void TestTooFewArgumentValues() {
SimpleFormatter fmt = SimpleFormatter.compile(
// Expected
}
}
-
+
@Test
public void TestWithArguments() {
SimpleFormatter fmt = SimpleFormatter.compile(
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.",
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(
// expected.
}
}
-
+
@Test
public void TestFormatReplaceNoOptimization() {
SimpleFormatter fmt = SimpleFormatter.compile("{2}, {0}, {1} and {3}");
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}");
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}");
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}");
result,
null,
"freddy", "frog", result, "by").toString());
-
+
}
-
+
@Test
public void TestFormatReplaceNoOptimizationNoOffsets() {
SimpleFormatter fmt = SimpleFormatter.compile(
"Arguments previous: and frog",
fmt.formatAndReplace(result, null, result, "frog").toString());
}
-
+
@Test
public void TestFormatReplaceNoOptimizationLeadingArgumentUsedTwice() {
SimpleFormatter fmt = SimpleFormatter.compile(
if (expected[i] != actual[i]) {
errln("Expected "+expected[i]+", got " + actual[i]);
}
- }
+ }
}
-
+
}
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;
* @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
*/
{
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);
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])
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!"};
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");
logln("PASS: Constructor with null string failed as expected");
}
}
-
+
/**
* Testing supplementary
*/
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) + "\"");
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;
if (tokenizer.hasMoreElements()) {
errln("Number of tokens exceeded expected");
}
-
+
str = "string \ud800\udc00 with supplementary character";
delimiter = "\ud800";
String expected2[] = {str};
if (tokenizer.hasMoreElements()) {
errln("Number of tokens exceeded expected");
}
-
+
delimiter = "\ud800\udc00";
String expected3[] = {"string ", " with supplementary character"};
tokenizer = new StringTokenizer(str, delimiter);
if (tokenizer.hasMoreElements()) {
errln("Number of tokens exceeded expected");
}
-
+
str = "\ud800 \ud800\udc00 \ud800 \ud800\udc00";
delimiter = "\ud800";
String expected4[] = {" \ud800\udc00 ", " \ud800\udc00"};
if (tokenizer.hasMoreElements()) {
errln("Number of tokens exceeded expected");
}
-
+
delimiter = "\ud800\udc00";
String expected5[] = {"\ud800 ", " \ud800 "};
i = 0;
errln("Number of tokens exceeded expected");
}
}
-
+
/**
* Testing next api
*/
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()) {
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");
} 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");
}
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");
"AHHHHH!", " ", "5.5", " ", "6", " ", "7", " ",
",", " ", "8\n"};
String delimiter = " ";
-
+
StringTokenizer tokenizer = new StringTokenizer(str, delimiter, true, true);
int currtoken = 0;
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");
} 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");
}
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);
errln("Should have recieved the same string when there are no delimiters");
}
}
-
+
/**
* Testing count tokens
*/
{
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);
|| streturn.countTokens() != expectedreturn.length - i - 1) {
errln("CountTokens with default delimiter and delimiter tokens gives wrong results");
}
- }
+ }
}
-
+
/**
* Next token with new delimiters
*/
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(
}
}
}
-
+
@Test
public void TestBug4423()
{
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");
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 = "";
break;
}
}
-
+
}
@Test
} 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)
*/
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"
} 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, ...
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)
*/
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]);
"for a value of " + invalid[i]);
} catch(Exception e){}
}
-
+
for(int i=0; i < valid.length; i++){
try{
us.indexOf(valid[i]);
}
}
}
-
+
/* 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++){
}
}
}
-
+
/* Tests the method
* private UnicodeSet add_unchecked(int start, int end)
* from public UnicodeSet add(int start, int end)
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{
+ 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{
+ 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)
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{
+ 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)
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<cases.length; i++){
try{
us.contains(cases[i]);
}
}
}
-
+
/* Tests the method
* public final UnicodeSet removeAllStrings()
*/
"exception for a strings size of 0");
}
}
-
+
/* Tests the method
* public UnicodeSet retain(int start, int end)
*/
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{
+ 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{
+ invalid[i]);
} catch (Exception e){}
}
-
+
// Tests when "if (start <= end)" is false
try{
us.retain(UnicodeSet.MIN_VALUE+1, UnicodeSet.MIN_VALUE);
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){
+ "an exception.");
}
}
-
+
/* Tests the method
* public final UnicodeSet retain(String s)
*/
"same UnicodeSet since the string was found in the original.");
}
}
-
+
/* Tests the method
* public UnicodeSet remove(int start, int end)
*/
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{
+ 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{
+ invalid[i]);
} catch (Exception e){}
}
-
+
// Tests when "if (start <= end)" is false
try{
us.remove(UnicodeSet.MIN_VALUE+1, UnicodeSet.MIN_VALUE);
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){
+ "an exception.");
}
}
-
+
/* Tests the method
* public UnicodeSet complement(int start, int end)
*/
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{
+ 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{
+ invalid[i]);
} catch (Exception e){}
}
-
+
// Tests when "if (start <= end)" is false
try{
us.complement(UnicodeSet.MIN_VALUE+1, UnicodeSet.MIN_VALUE);
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){
+ "an exception.");
}
}
-
+
/* Tests the method
* public final UnicodeSet complement(String s)
*/
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");
+ "an exception for '\uDC11'.");
}
}
-
+
/* Tests the method
* public boolean contains(int c)
*/
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{
} catch (Exception e){}
}
}
-
+
/* Tests the method
* public boolean contains(int start, int end)
*/
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{
+ 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{
} catch (Exception e){}
}
}
-
+
/* Tests the method
* public String getRegexEquivalent()
*/
errln("UnicodeSet.getRegexEquivalent is suppose to return '[]' " +
"but got " + res);
}
-
+
/* Tests the method
* public boolean containsNone(int start, int end)
*/
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{
+ 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{
+ invalid[i]);
} catch (Exception e){}
}
-
+
// Tests when "if (start < list[++i])" is false
try{
us.add(0);
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;
* @author markdavis
*
*/
+@RunWith(JUnit4.class)
public class TestLocaleValidity extends TestFmwk {
@Test
public void testBasic() {
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);
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;
import com.ibm.icu.impl.Trie2_16;
import com.ibm.icu.impl.Trie2_32;
+@RunWith(JUnit4.class)
public class Trie2Test extends TestFmwk {
/**
* Constructor
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.
@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();
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
//
{
assertEquals("", trieA, trieB);
assertEquals("", trieA.hashCode(), trieB.hashCode());
}
-
- //
+
+ //
// Iterator creation
//
{
Trie2Writable trie = new Trie2Writable(17,0);
Iterator<Trie2.Range> 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) {
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;
}
assertEquals("", 42, r.value);
assertEquals("", false, r.leadSurrogate);
}
-
-
+
+
// Iteration over a leading surrogate range.
//
{
assertEquals("", 0x2f80f, r.endCodePoint);
assertEquals("", 0xdefa17, r.value);
assertEquals("", false, r.leadSurrogate);
-
+
r = it.next();
assertEquals("", 0x2f810, r.startCodePoint);
assertEquals("", 0x2f810, r.endCodePoint);
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<Trie2.Range> it = trie.iteratorForLeadSurrogate((char)0xd87e, m);
Trie2.Range r = it.next();
assertFalse("", it.hasNext());
}
-
+
// Trie2.serialize()
// Test the implementation in Trie2, which is used with Read Only Tries.
//
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()));
} 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);
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 */);
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)
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));
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);
t1_16 = t1w.toTrie2_16();
assertTrue("", t1w.equals(t1_16));
assertEquals("", 129, t1w.get(152));
-
+
// Trie2_32 getAsFrozen_32()
//
t1w = new Trie2Writable(10, 666);
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);
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);
} 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);
tw.set(0x10001, 'X');
Trie2.CharSequenceIterator it = tw.charSequenceIterator(text, 0);
-
+
// Check forwards iteration.
Trie2.CharSequenceValues ir;
int i;
}
}
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 ...
//
//
// 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 },
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<ranges.length; i++) {
int rangeStart = ranges[i][0];
int rangeEnd = ranges[i][1]-1;
boolean overwrite = (ranges[i][3] != 0);
trie.setRange(rangeStart, rangeEnd, value, overwrite);
}
-
+
// Insert some non-default values for lead surrogates.
// TODO: this should be represented in the data.
trie.setForLeadSurrogateCodeUnit((char)0xd800, 90);
trie.setForLeadSurrogateCodeUnit((char)0xd999, 94);
trie.setForLeadSurrogateCodeUnit((char)0xdbff, 99);
-
+
return trie;
}
-
+
//
// Check the expected values from a single Trie2.
//
private void trieGettersTest(String testName,
Trie2 trie, // The Trie2 to test.
- int[][] checkRanges) // Expected data.
+ int[][] checkRanges) // Expected data.
// Tuples of (value, high limit code point)
// High limit is first code point following the range
// with the indicated value.
while(start<limit) {
value2=trie.get(start);
if (value != value2) {
- // The redundant if, outside of the assert, is for speed.
+ // The redundant if, outside of the assert, is for speed.
// It makes a significant difference for this test.
assertEquals("wrong value for " + testName + " of " + Integer.toHexString(start), value, value2);
}
value2 = trie.getFromU16SingleLead((char)start);
if(value2!=value) {
errln(where() + " testName: " + testName + " getFromU16SingleLead() failed." +
- "char, exected, actual = " + Integer.toHexString(start) + ", " +
+ "char, exected, actual = " + Integer.toHexString(start) + ", " +
Integer.toHexString(value) + ", " + Integer.toHexString(value2));
}
}
errln("trie2.get() error value test. Expected, actual1, actual2 = " +
errorValue + ", " + value + ", " + value2);
}
-
+
// Check that Trie enumeration produces the same contents as simple get()
for (Trie2.Range range: trie) {
for (int cp=range.startCodePoint; cp<=range.endCodePoint; cp++) {
}
}
}
-
+
// Was testTrieRanges in ICU4C. Renamed to not conflict with ICU4J test framework.
private void checkTrieRanges(String testName, String serializedName, boolean withClone,
int[][] setRanges, int [][] checkRanges) throws IOException {
-
+
// Run tests against Tries that were built by ICU4C and serialized.
String fileName16 = "Trie2Test." + serializedName + ".16.tri2";
String fileName32 = "Trie2Test." + serializedName + ".32.tri2";
-
+
InputStream is = Trie2Test.class.getResourceAsStream(fileName16);
Trie2 trie16;
try {
trieGettersTest(testName, trieW, checkRanges);
assertEquals("", trieW, trie16); // Locally built tries must be
assertEquals("", trieW, trie32); // the same as those imported from ICU4C
-
-
+
+
Trie2_32 trie32a = trieW.toTrie2_32();
trieGettersTest(testName, trie32a, checkRanges);
Trie2_16 trie16a = trieW.toTrie2_16();
trieGettersTest(testName, trie16a, checkRanges);
-
+
}
-
- // Was "TrieTest" in trie2test.c
+
+ // Was "TrieTest" in trie2test.c
@Test
public void TestRanges() throws IOException {
- checkTrieRanges("set1", "setRanges1", false, setRanges1, checkRanges1);
+ checkTrieRanges("set1", "setRanges1", false, setRanges1, checkRanges1);
checkTrieRanges("set2-overlap", "setRanges2", false, setRanges2, checkRanges2);
checkTrieRanges("set3-initial-9", "setRanges3", false, setRanges3, checkRanges3);
checkTrieRanges("set-empty", "setRangesEmpty", false, setRangesEmpty, checkRangesEmpty);
- checkTrieRanges("set-single-value", "setRangesSingleValue", false, setRangesSingleValue,
+ checkTrieRanges("set-single-value", "setRangesSingleValue", false, setRangesSingleValue,
checkRangesSingleValue);
checkTrieRanges("set2-overlap.withClone", "setRanges2", true, setRanges2, checkRanges2);
}
-
+
private String where() {
StackTraceElement[] st = new Throwable().getStackTrace();
String w = "File: " + st[1].getFileName() + ", Line " + st[1].getLineNumber();
import org.junit.Before;
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.util.TrieMap.Style;
import com.ibm.icu.util.StringTrieBuilder.Option;
import com.ibm.icu.util.ULocale;
+@RunWith(JUnit4.class)
public class TrieMapTest extends TestFmwk {
static final boolean SHORT = false;
static final boolean HACK_TO_MAKE_TESTS_PASS = false;
}
}
}
- int charCount = 0;
+ int charCount = 0;
for (String key : unicodeTestMap.keySet()) {
charCount += key.length();
}
assertEquals(style + "\tGet of '" + key + "' = {" + Utility.hex(key) + "}", value, foundValue);
}
}
- }
+ }
}
@Ignore
Map<String, Integer> map = comparisonTime == 0 ? new TreeMap<String, Integer>(testMap) : new HashMap<String, Integer>(testMap);
long mapTime = t.timeIterations(new MyLoop() {
+ @Override
public void time(int repeat) {
for (int tt = 0; tt < repeat; ++tt) {
for (Entry<String, Integer> entry : map.entrySet()) {
Integer value = entry.getValue();
}
}
- }
+ }
}, null, map);
if (comparisonTime == 0) {
logln("\titeration time\tTREEMAP\tn/a\t" + t.toString(testMap.size()) + "\t\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) {
for (Entry<CharSequence, Integer> entry : trieMap) {
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) {
} 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) + "|"
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<String, Integer> map2 = new TreeMap<String, Integer>(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<String, Integer> map2 = new HashMap<String, Integer>(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());
int mapKeyByteSize = 0;
TreeMap<String, Integer> map = new TreeMap<String, Integer>(unicodeTestMap);
for (Entry<String, Integer> 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;
Map<String, Integer> map = comparisonTime == 0 ? new TreeMap<String, Integer>(testmap) : new HashMap<String, Integer>(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());
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();
Map<String, Integer> map;
Style style;
Option option;
+ @Override
public void init(Object... params) {
if (params.length > 0) {
keys = (ArrayList<String>) params[0];
option = (Option) params[3];
}
}
+ @Override
abstract public void time(int repeat);
}
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;
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)
{
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;
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;
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;
}
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]));
++ 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) {
boolean overwrite = setRanges[i].overwrite;
if ((limit - start) == 1 && overwrite) {
ok &= newTrie.setValue(start, value);
- }
+ }
else {
ok &= newTrie.setRange(start, limit, value, overwrite);
}
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));
}
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));
}
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[]={
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),
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),
new CheckRange(0xf0020,0x12),
new CheckRange(0x110000, 0)
};
-
- /**
+
+ /**
* set some interesting overlapping ranges
*/
private static SetRange setRanges2[]={
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),
new CheckRange(0x2ffef,2),
new CheckRange(0x110000, 0)
};
-
- /**
+
+ /**
* use a non-zero initial value
*/
private static SetRange setRanges3[]={
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),
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 */
}
@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());
@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());
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;
import com.ibm.icu.util.UResourceBundle;
import com.ibm.icu.util.VersionInfo;
+@RunWith(JUnit4.class)
public class ULocaleTest extends TestFmwk {
// Ticket #8078 and #11674
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;
* @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);
errln("FAIL: Utility.unescape() returned " + result + ", exp. " + expect);
}
}
-
+
@Test
public void TestFormat()
{
"\"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]));
result1[i], Utility.format1ForSource(data[i]));
}
}
-
+
@Test
public void TestHighBit()
{
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]);
}
}
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!");
logln("Assert.fail works");
}
}
-
+
@Test
public void TestCaseInsensitiveString() {
CaseInsensitiveString str1 = new CaseInsensitiveString("ThIs is A tEst");
errln("FAIL: str1("+str1+") != str2("+str2+")");
}
}
-
+
@Test
public void TestSourceLocation() {
String here = TestFmwk.sourceLocation();
String hereAgain = TestFmwk.sourceLocation();
assertTrue("here < there < hereAgain", here.compareTo(there) < 0 && there.compareTo(hereAgain) < 0);
}
-
+
public String CheckSourceLocale() {
return TestFmwk.sourceLocation();
}
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;
* @author Syn Wee Quek
* @since release 2.1 March 01 2002
*/
+@RunWith(JUnit4.class)
public final class VersionInfoTest extends TestFmwk
{
// constructor ---------------------------------------------------
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;
*
* @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
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;
*
* @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
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();
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;
} else {
if (isIcuImpl) {
logln("INFO: " + method + " returned ICU BreakIterator for locale " + loc);
- }
+ }
BreakIterator brkitrIcu = null;
Locale iculoc = TestUtil.toICUExtendedLocale(loc);
switch (type) {
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);
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.
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<Currency> AVAILABLE_CURRENCIES;
private static final Method GETDISPLAYNAME_METHOD;
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.
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.
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.
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;
}
} 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)
} 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)
} 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)
}
} 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)
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;
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<String> ProblematicZones = new HashSet<String>();
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);
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.
*/
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
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() {
}
"DE",
"TH",
};
- String[] expected = LocaleDisplayNamesImpl.haveData(REGION) ?
+ String[] expected = LocaleDisplayNamesImpl.haveData(REGION) ?
expectedWithRegionData : expectedWithoutRegionData;
int n = 0;
: "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);
-
+
}
}
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;
* @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);
@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));
}
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;
// 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
) {
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);
}
-
+
@Test
public void TestCommonDigits() {
UnicodeSet westernDigitSet = new UnicodeSet("[0-9]");
*******************************************************************************
*/
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;
* @test
* @summary General test of CompoundTransliterator
*/
+@RunWith(JUnit4.class)
public class CompoundTransliteratorTest extends TestFmwk {
@Test
public void TestConstruction(){
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]);
// "UnicodeFilter adoptedFilter=0) failed for " + IDs[i]);
// throw ex4;
// }
-//
-//
+//
+//
// try{
// CompoundTransliterator cpdtrans2=new CompoundTransliterator(transarray[i], null);
// cpdtrans2 = null;
// throw ex5;
// }
-
+
}
-
+
}
-
+
@Test
public void TestGetTransliterator(){
logln("Testing the getTransliterator() API of CompoundTransliterator");
}
}
-
+
}
-
-
+
+
@Test
public void TestTransliterate(){
logln("Testing the handleTransliterate() API of CompoundTransliterator");
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();
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<Data.length; i+=3){
}
expect(ct2, Data[i+1], Data[i+2]);
}
-
+
}
-
+
//======================================================================
// Support methods
* Splits a string,
*/
private static String[] split(String s, char divider) {
-
+
// see how many there are
int count = 1;
for (int i = 0; i < s.length(); ++i) {
if (s.charAt(i) == divider) ++count;
}
-
+
// make an array with them
String[] result = new String[count];
int last = 0;
append('|').
append(s.substring(index.start));
}
-
+
// As a final step in keyboard transliteration, we must call
// transliterate to finish off any pending partial matches that
// were waiting for more input.
+ Utility.escape(summary)
+ ", expected " + Utility.escape(expectedResult));
}
- }
+ }
}
*******************************************************************************
*/
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.text.ReplaceableString;
* @test
* @summary Error condition test of Transliterator
*/
+@RunWith(JUnit4.class)
public class ErrorTest extends TestFmwk {
@Test
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;
* @test
* @summary Test the Latin-Jamo transliterator
*/
+@RunWith(JUnit4.class)
public class JamoTest extends TestFmwk {
@Test
public void TestJamo() {
// Column 3 is expected value of L2. If the expected
// value of L2 is L1, then L2 is null.
-
+
// add tests for the update to fix problems where it didn't follow the standard
// see also http://www.unicode.org/cldr/data/charts/transforms/Latin-Hangul.html
"gach", "(Gi)(A)(Cf)", null,
// 'r' in a final position is treated like 'l'
"karka", "(Ki)(A)(L)(Ki)(A)", "kalka",
-
+
};
for (int i=0; i<CASE.length; i+=3) {
public void TestRoundTrip() {
String HANGUL[] = { "\uAC03\uC2F8",
"\uC544\uC5B4"};
-
+
Transliterator latinJamo = Transliterator.getInstance("Latin-Jamo");
Transliterator jamoLatin = latinJamo.getInverse();
Transliterator jamoHangul = Transliterator.getInstance("NFC");
+ " => " + 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): ");
latin + " => " + jamoToName(jamo2)
+ " => " + hangul2
);
- errln(Utility.escape(buf.toString()));
+ errln(Utility.escape(buf.toString()));
} else {
buf.setLength(0);
buf.append("FAIL: ");
"\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 " +
"\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 " +
"\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 " +
"\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 " +
"\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 " +
"\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 " +
"\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 " +
"(Ti)", "\u1110",
"(Pi)", "\u1111",
"(Hi)", "\u1112",
-
+
"(A)", "\u1161",
"(AE)", "\u1162",
"(YA)", "\u1163",
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;
/**
* @author markdavis
*/
+@RunWith(JUnit4.class)
public class RegexUtilitiesTest extends TestFmwk {
/**
* Check basic construction.
String expected = tests[i].length == 1 ? source : tests[i][1];
String actual = UnicodeRegex.fix(source);
assertEquals(source, expected, actual);
- }
+ }
}
Transliterator hex = Transliterator.getInstance("hex");
*/
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;
* @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
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);
} 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.
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();
}
this.styles = new ReplaceableString(s.toString());
}
-
+
public String getStyles() {
return styles.toString();
}
-
+
+ @Override
public String toString() {
return chars.toString() + "{" + styles.toString() + "}";
}
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 +
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!
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 =
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;
* @test
* @summary Round trip test of Transliterator
*/
+@RunWith(JUnit4.class)
public class RoundTripTest extends TestFmwk {
//TODO - revisit test cases referencing FIX_ME
abbreviated = false;
}
+ @Override
public void reset(UnicodeSet newSet) {
reset(newSet, false);
}
}
}
+ @Override
protected void loadRange(int myRange) {
super.loadRange(myRange);
if (abbreviated && (endElement > nextElement + perRange)) {
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
}
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
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");
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);
// 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;
//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.
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.
return "\u03C1\u03A1".indexOf(c) >= 0;
}
+ @Override
public boolean is(String sourceString) {
try {
String decomp = Normalizer.normalize(sourceString, Normalizer.NFD);
}
/**
- * 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
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(", ");
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");
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;
// 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<Worker> threads = new ArrayList<Worker>();
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);
}
}
}
-
+
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<Thread> threads = new ArrayList<Thread>();
for (int i=0; i<8; i++) {
threads.add(new Thread() {
+ @Override
public void run() {
tx.transliterate("διαφορετικούς");
}
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;
* @test
* @summary General test of Transliterator
*/
+@RunWith(JUnit4.class)
public class TransliteratorTest extends TestFmwk {
@Test
public void TestHangul() {
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;
* @test
* @summary General test of UnicodeSet
*/
+@RunWith(JUnit4.class)
public class UnicodeMapTest extends TestFmwk {
static final int MODIFY_TEST_LIMIT = 32;
assertEquals("EntryRange<T>", expected, CollectionUtilities.join(foo.entryRanges(), "\n") + (foo.size() == 0 ? "" : "\n"));
assertEquals("EntryRange<T>", expected, foo.toString());
}
-
+
@Test
public void TestRemove() {
UnicodeMap<Double> foo = new UnicodeMap()
.put("abc", 3d)
.put("mark", 999d)
.freeze();
-
+
UnicodeMap<Double> afterFiiRemoval = new UnicodeMap()
.put(0x20, -2d)
.putAll(0x26, 0x29, -2d)
.put("xy", 2d)
.put("mark", 4d)
.freeze();
-
+
UnicodeMap<Double> afterFiiRetained = new UnicodeMap()
.putAll(0x21, 0x25, -2d)
.put("abc", 3d)
UnicodeMap<Double> test = new UnicodeMap<Double>().putAll(foo)
.removeAll(fii);
assertEquals("removeAll", afterFiiRemoval, test);
-
+
test = new UnicodeMap<Double>().putAll(foo)
.retainAll(fii);
assertEquals("retainAll", afterFiiRetained, test);
}
/**
- * @param rand
+ * @param rand
* @param nextInt
- * @param test
+ * @param test
* @return
*/
private SortedMap<String, Integer> fillRandomMap(Random rand, int max, SortedMap<String, Integer> test) {
}
static Comparator<String> OneFirstComparator = new Comparator<String>() {
+ @Override
public int compare(String o1, String o2) {
int cp1 = UnicodeSet.getSingleCodePoint(o1);
int cp2 = UnicodeSet.getSingleCodePoint(o2);
};
/**
- * @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) {
}
return true;
}
-
+
@Test
public void TestCloneAsThawed11721 () {
UnicodeMap<Integer> test = new UnicodeMap().put("abc", 3).freeze();
}
static Comparator<Map.Entry<Integer, String>> ENTRY_COMPARATOR = new Comparator<Map.Entry<Integer, String>>() {
+ @Override
public int compare(Map.Entry<Integer, String> o1, Map.Entry<Integer, String> o2) {
if (o1 == o2) return 0;
if (o1 == null) return -1;
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() {