ICU-12812 Fixed some build and test issues introduced by LoicaleMatcher changes (and DecimalFormat changes done by #7467)
X-SVN-Rev: 39883
This commit is contained in:
parent
8529f1b528
commit
634c4a2023
@ -292,6 +292,7 @@
|
||||
<include name="**/*Test*"/>
|
||||
<exclude name="**/*Fmwk*"/>
|
||||
<exclude name="**/*TestUtility*"/>
|
||||
<exclude name="**/*TestHelper*"/>
|
||||
<exclude name="**/*TestCase*"/>
|
||||
<exclude name="**/*TestData*"/>
|
||||
<exclude name="**/*TestSample*"/>
|
||||
|
@ -14,6 +14,7 @@ import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
import com.ibm.icu.lang.UCharacter;
|
||||
import com.ibm.icu.text.UTF16;
|
||||
|
||||
/**
|
||||
* TextTrieMap is a trie implementation for supporting
|
||||
@ -118,7 +119,7 @@ public class TextTrieMap<V> {
|
||||
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;
|
||||
}
|
||||
@ -152,10 +153,10 @@ public class TextTrieMap<V> {
|
||||
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;
|
||||
|
@ -10,6 +10,7 @@ package com.ibm.icu.impl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@ -1807,4 +1808,44 @@ public final class Utility {
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -8,12 +8,12 @@ import java.util.Enumeration;
|
||||
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;
|
||||
@ -206,7 +206,7 @@ public class XLikelySubtags {
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(language, script, region);
|
||||
return Utility.hash(language, script, region);
|
||||
}
|
||||
}
|
||||
|
||||
@ -483,7 +483,7 @@ public class XLikelySubtags {
|
||||
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;
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ import java.util.LinkedHashSet;
|
||||
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;
|
||||
@ -22,6 +21,7 @@ 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;
|
||||
@ -357,11 +357,11 @@ public class XLocaleDistance {
|
||||
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) {
|
||||
|
@ -4903,7 +4903,8 @@ public class NumberFormatTest extends TestFmwk {
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1573,7 +1573,8 @@ public class NumberRegressionTests extends TestFmwk {
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
|
@ -8,7 +8,7 @@ import java.math.RoundingMode;
|
||||
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;
|
||||
|
||||
@ -404,8 +404,9 @@ public class FormatQuantityTest extends TestFmwk {
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
@ -7,11 +7,11 @@ import java.io.IOException;
|
||||
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;
|
||||
@ -165,7 +165,7 @@ abstract public class DataDrivenTestHelper {
|
||||
}
|
||||
|
||||
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user