<include name="**/*Test*"/>
<exclude name="**/*Fmwk*"/>
<exclude name="**/*TestUtility*"/>
+ <exclude name="**/*TestHelper*"/>
<exclude name="**/*TestCase*"/>
<exclude name="**/*TestData*"/>
<exclude name="**/*TestSample*"/>
import java.util.ListIterator;
import com.ibm.icu.lang.UCharacter;
+import com.ibm.icu.text.UTF16;
/**
* TextTrieMap is a trie implementation for supporting
startingCp = UCharacter.foldCase(startingCp, true);
}
int count = Character.charCount(startingCp);
- char ch1 = (count == 1) ? (char) startingCp : Character.highSurrogate(startingCp);
+ char ch1 = (count == 1) ? (char) startingCp : UTF16.getLeadSurrogate(startingCp);
if (!_root.hasChildFor(ch1)) {
return null;
}
cp = UCharacter.foldCase(cp, true);
}
int count = Character.charCount(cp);
- char ch1 = (count == 1) ? (char) cp : Character.highSurrogate(cp);
+ char ch1 = (count == 1) ? (char) cp : UTF16.getLeadSurrogate(cp);
node.takeStep(ch1, offset, result);
if (count == 2 && result.node != null) {
- char ch2 = Character.lowSurrogate(cp);
+ char ch2 = UTF16.getTrailSurrogate(cp);
result.node.takeStep(ch2, result.offset, result);
}
node = result.node;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Locale;
import java.util.regex.Pattern;
}
return buffer.toString();
}
+
+ /**
+ * This implementation is equivalent to Java 7+ Objects#equals(Object a, Object b)
+ *
+ * @param a an object
+ * @param b an object to be compared with a for equality
+ * @return true if the arguments are equal to each other and false otherwise
+ */
+ public static boolean equals(Object a, Object b) {
+ return (a == b)
+ || (a != null && b != null && a.equals(b));
+ }
+
+ /**
+ * This implementation is equivalent to Java 7+ Objects#hash(Object... values)
+ * @param values the values to be hashed
+ * @return a hash value of the sequence of input values
+ */
+ public static int hash(Object... values) {
+ return Arrays.hashCode(values);
+ }
+
+ /**
+ * This implementation is equivalent to Java 7+ Objects#hashCode(Object o)
+ * @param o an object
+ * @return a hash value of a non-null argument and 0 for null argument
+ */
+ public static int hashCode(Object o) {
+ return o == null ? 0 : o.hashCode();
+ }
+
+ /**
+ * This implementation is equivalent to Java 7+ Objects#toString(Object o)
+ * @param o an object
+ * @return the result of calling toStirng for a non-null argument and "null" for a
+ * null argument
+ */
+ public static String toString(Object o) {
+ return o == null ? "null" : o.toString();
+ }
}
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.Objects;
import java.util.Set;
import java.util.TreeMap;
import com.ibm.icu.impl.ICUData;
import com.ibm.icu.impl.ICUResourceBundle;
+import com.ibm.icu.impl.Utility;
import com.ibm.icu.impl.locale.XCldrStub.HashMultimap;
import com.ibm.icu.impl.locale.XCldrStub.Multimap;
import com.ibm.icu.impl.locale.XCldrStub.Multimaps;
}
@Override
public int hashCode() {
- return Objects.hash(language, script, region);
+ return Utility.hash(language, script, region);
}
}
if (value instanceof Map) {
show((Map)value, indent+"\t", output);
} else {
- output.append("\t" + Objects.toString(value)).append("\n");
+ output.append("\t" + Utility.toString(value)).append("\n");
}
first = indent;
}
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.Objects;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import com.ibm.icu.impl.ICUResourceBundle;
import com.ibm.icu.impl.Row;
import com.ibm.icu.impl.Row.R4;
+import com.ibm.icu.impl.Utility;
import com.ibm.icu.impl.locale.XCldrStub.CollectionUtilities;
import com.ibm.icu.impl.locale.XCldrStub.ImmutableMap;
import com.ibm.icu.impl.locale.XCldrStub.ImmutableMultimap;
return false;
}
StringDistanceNode other = (StringDistanceNode) obj;
- return distance == other.distance && Objects.equals(distanceTable, other.distanceTable);
+ return distance == other.distance && Utility.equals(distanceTable, other.distanceTable);
}
@Override
public int hashCode() {
- return distance ^ Objects.hashCode(distanceTable);
+ return distance ^ Utility.hashCode(distanceTable);
}
StringDistanceNode(int distance) {
new CurrencyAmount(2.34, Currency.getInstance("XSU")), result);
// pass
} catch (Exception e) {
- throw new AssertionError("Should have been able to parse XSU", e);
+ //throw new AssertionError("Should have been able to parse XSU", e);
+ throw new AssertionError("Should have been able to parse XSU: " + e.getMessage());
}
}
assertEquals("Localized FAIL on maxInt", df.getMaximumIntegerDigits(), f2.getMaximumIntegerDigits());
}catch(IllegalArgumentException ex){
- throw new AssertionError("For locale " + avail[i], ex);
+ //throw new AssertionError("For locale " + avail[i], ex);
+ throw new AssertionError("For locale " + avail[i] + ": " + ex.getMessage());
}
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
-import java.util.concurrent.ThreadLocalRandom;
+import java.util.Random;
import org.junit.Test;
// Generate random doubles
String alert = "UNEXPECTED FAILURE: PLEASE REPORT THIS MESSAGE TO THE ICU TEAM: ";
+ Random rnd = new Random();
for (int i = 0; i < 1000000; i++) {
- double d = Double.longBitsToDouble(ThreadLocalRandom.current().nextLong());
+ double d = Double.longBitsToDouble(rnd.nextLong());
if (Double.isNaN(d) || Double.isInfinite(d)) continue;
checkDoubleBehavior(d, false, alert);
}
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.Objects;
import com.ibm.icu.dev.test.AbstractTestLog;
import com.ibm.icu.dev.test.TestFmwk;
import com.ibm.icu.dev.util.CollectionUtilities;
+import com.ibm.icu.impl.Utility;
import com.ibm.icu.impl.locale.XCldrStub.FileUtilities;
import com.ibm.icu.impl.locale.XCldrStub.Splitter;
import com.ibm.icu.util.ICUUncheckedIOException;
}
protected boolean assertEquals(String message, Object expected, Object actual) {
- return TestFmwk.handleAssert(Objects.equals(expected, actual), message, stringFor(expected), stringFor(actual), null, false);
+ return TestFmwk.handleAssert(Utility.equals(expected, actual), message, stringFor(expected), stringFor(actual), null, false);
}
private final String stringFor(Object obj) {