Regenerate sources for tests.
These are tests added in commit ae97726f86aa98a33c33ce09c583aeb3d2e253a6
Bug: 22023363
Change-Id: Ica9fd69ae98fd4e6f4bec490a62f54b28ff87bf6
diff --git a/android_icu4j/src/main/tests/android/icu/dev/test/format/NumberFormatTest.java b/android_icu4j/src/main/tests/android/icu/dev/test/format/NumberFormatTest.java
index 098b102..3db156a 100644
--- a/android_icu4j/src/main/tests/android/icu/dev/test/format/NumberFormatTest.java
+++ b/android_icu4j/src/main/tests/android/icu/dev/test/format/NumberFormatTest.java
@@ -14,12 +14,14 @@
package android.icu.dev.test.format;
import java.io.IOException;
+import java.lang.reflect.Array;
import java.math.BigInteger;
import java.text.AttributedCharacterIterator;
import java.text.FieldPosition;
import java.text.ParseException;
import java.text.ParsePosition;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Locale;
import java.util.Set;
@@ -30,6 +32,7 @@
import android.icu.impl.data.TokenIterator;
import android.icu.math.BigDecimal;
import android.icu.math.MathContext;
+import android.icu.text.CompactDecimalFormat;
import android.icu.text.DecimalFormat;
import android.icu.text.DecimalFormatSymbols;
import android.icu.text.DisplayContext;
@@ -37,6 +40,8 @@
import android.icu.text.NumberFormat;
import android.icu.text.NumberFormat.NumberFormatFactory;
import android.icu.text.NumberFormat.SimpleNumberFormatFactory;
+import android.icu.text.NumberingSystem;
+import android.icu.text.RuleBasedNumberFormat;
import android.icu.util.Currency;
import android.icu.util.CurrencyAmount;
import android.icu.util.ULocale;
@@ -1954,6 +1959,50 @@
}
}
}
+
+ // Coverage tests for methods not being called otherwise.
+ public void TestNumberingSystemCoverage() {
+ // Test getAvaliableNames
+ String[] availableNames = NumberingSystem.getAvailableNames();
+ if (availableNames == null || availableNames.length <= 0) {
+ errln("ERROR: NumberingSystem.getAvailableNames() returned a null or empty array.");
+ } else {
+ boolean latnFound = false;
+ for (String name : availableNames){
+ if ("latn".equals(name)) {
+ latnFound = true;
+ break;
+ }
+ }
+
+ if (!latnFound) {
+ errln("ERROR: 'latn' numbering system not found on NumberingSystem.getAvailableNames().");
+ }
+ }
+
+ // Test NumberingSystem.getInstance()
+ NumberingSystem ns1 = NumberingSystem.getInstance();
+ if (ns1 == null || ns1.isAlgorithmic()) {
+ errln("ERROR: NumberingSystem.getInstance() returned a null or invalid NumberingSystem");
+ }
+
+ // Test NumberingSystem.getInstance(int,boolean,String)
+ /* Parameters used: the ones used in the default constructor
+ * radix = 10;
+ * algorithmic = false;
+ * desc = "0123456789";
+ */
+ NumberingSystem ns2 = NumberingSystem.getInstance(10, false, "0123456789");
+ if (ns2 == null || ns2.isAlgorithmic()) {
+ errln("ERROR: NumberingSystem.getInstance(int,boolean,String) returned a null or invalid NumberingSystem");
+ }
+
+ // Test NumberingSystem.getInstance(Locale)
+ NumberingSystem ns3 = NumberingSystem.getInstance(Locale.ENGLISH);
+ if (ns3 == null || ns3.isAlgorithmic()) {
+ errln("ERROR: NumberingSystem.getInstance(Locale) returned a null or invalid NumberingSystem");
+ }
+ }
public void Test6816() {
Currency cur1 = Currency.getInstance(new Locale("und", "PH"));
@@ -3244,6 +3293,36 @@
}
/*
+ * Coverage tests for the implementation of abstract format methods not being called otherwise
+ */
+ public void TestFormatAbstractImplCoverage() {
+ NumberFormat df = DecimalFormat.getInstance(Locale.ENGLISH);
+ NumberFormat cdf = CompactDecimalFormat.getInstance(Locale.ENGLISH, CompactDecimalFormat.CompactStyle.SHORT);
+ NumberFormat rbf = new RuleBasedNumberFormat(ULocale.ENGLISH, RuleBasedNumberFormat.SPELLOUT);
+
+ /*
+ * Test NumberFormat.format(BigDecimal,StringBuffer,FieldPosition)
+ */
+ StringBuffer sb = new StringBuffer();
+ String result = df.format(new BigDecimal(2000.43), sb, new FieldPosition(0)).toString();
+ if (!"2,000.43".equals(result)) {
+ errln("DecimalFormat failed. Expected: 2,000.43 - Actual: " + result);
+ }
+
+ sb.delete(0, sb.length());
+ result = cdf.format(new BigDecimal(2000.43), sb, new FieldPosition(0)).toString();
+ if (!"2K".equals(result)) {
+ errln("DecimalFormat failed. Expected: 2K - Actual: " + result);
+ }
+
+ sb.delete(0, sb.length());
+ result = rbf.format(new BigDecimal(2000.43), sb, new FieldPosition(0)).toString();
+ if (!"two thousand point four three".equals(result)) {
+ errln("DecimalFormat failed. Expected: 'two thousand point four three' - Actual: '" + result + "'");
+ }
+ }
+
+ /*
* Tests the method public final static NumberFormat getInstance(int style) public static NumberFormat
* getInstance(Locale inLocale, int style) public static NumberFormat getInstance(ULocale desiredLocale, int choice)
*/
@@ -3341,21 +3420,21 @@
* Tests the method public boolean visible()
*/
if (tf.visible() != true) {
- errln("NumberFormatFactor.visible() was suppose to return true.");
+ errln("NumberFormatFactory.visible() was suppose to return true.");
}
/*
* Tests the method public NumberFormat createFormat(Locale loc, int formatType)
*/
if (tf.createFormat(new Locale(""), 0) != null) {
- errln("NumberFormatFactor.createFormat(Locale loc, int formatType) " + "was suppose to return null");
+ errln("NumberFormatFactory.createFormat(Locale loc, int formatType) " + "was suppose to return null");
}
/*
* Tests the method public NumberFormat createFormat(ULocale loc, int formatType)
*/
if (tf1.createFormat(new ULocale(""), 0) != null) {
- errln("NumberFormatFactor.createFormat(ULocale loc, int formatType) " + "was suppose to return null");
+ errln("NumberFormatFactory.createFormat(ULocale loc, int formatType) " + "was suppose to return null");
}
}