Merge "Add a unit test for a NumberFormat.setCurrency regression."
diff --git a/luni/src/test/java/libcore/java/text/NumberFormatTest.java b/luni/src/test/java/libcore/java/text/NumberFormatTest.java
index 4ff063b..0678e96 100644
--- a/luni/src/test/java/libcore/java/text/NumberFormatTest.java
+++ b/luni/src/test/java/libcore/java/text/NumberFormatTest.java
@@ -22,6 +22,7 @@
import java.text.FieldPosition;
import java.text.NumberFormat;
import java.text.ParsePosition;
+import java.util.Currency;
import java.util.Locale;
public class NumberFormatTest extends junit.framework.TestCase {
@@ -80,6 +81,7 @@
// Formatting percentages is confusing but deliberate.
// Ensure we don't accidentally "fix" this.
+ // https://code.google.com/p/android/issues/detail?id=10333
public void test_10333() throws Exception {
NumberFormat nf = NumberFormat.getPercentInstance(Locale.US);
assertEquals("15%", nf.format(0.15));
@@ -91,6 +93,7 @@
}
}
+ // https://code.google.com/p/android/issues/detail?id=62269
public void test_62269() throws Exception {
NumberFormat nf = NumberFormat.getNumberInstance(Locale.US);
try {
@@ -126,4 +129,28 @@
fail();
} catch (NullPointerException expected) {}
}
+
+ // https://code.google.com/p/android/issues/detail?id=79925
+ public void test_setCurrency() throws Exception {
+ NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.US);
+ nf.setCurrency(Currency.getInstance("AMD"));
+ assertEquals("AMD50.00", nf.format(50.0));
+
+ DecimalFormatSymbols decimalFormatSymbols = ((DecimalFormat) nf).getDecimalFormatSymbols();
+ decimalFormatSymbols.setCurrencySymbol("");
+ ((DecimalFormat) nf).setDecimalFormatSymbols(decimalFormatSymbols);
+ assertEquals("50.00", nf.format(50.0));
+
+ nf.setCurrency(Currency.getInstance("AMD"));
+ assertEquals("AMD50.00", nf.format(50.0));
+
+ nf.setCurrency(Currency.getInstance("AMD"));
+ assertEquals("AMD50.00", nf.format(50.0));
+
+ nf.setCurrency(Currency.getInstance("USD"));
+ assertEquals("$50.00", nf.format(50.0));
+
+ nf.setCurrency(Currency.getInstance("AMD"));
+ assertEquals("AMD50.00", nf.format(50.0));
+ }
}