diff options
| author | Brett Chabot <brettchabot@android.com> | 2010-01-21 14:25:46 -0800 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2010-01-21 14:25:46 -0800 |
| commit | ff3a96c9055888140893158fff8b33831b949e49 (patch) | |
| tree | f990eb8435aa870e1b6bdfa1d4d099cc8eb0d3f7 | |
| parent | 82e86144b0ccd04282249012130ec0f6101d1e32 (diff) | |
| parent | c4f93305d1fe3d31660af2b47a90d2ebbc6d58f9 (diff) | |
| download | android_dalvik-ff3a96c9055888140893158fff8b33831b949e49.tar.gz android_dalvik-ff3a96c9055888140893158fff8b33831b949e49.tar.bz2 android_dalvik-ff3a96c9055888140893158fff8b33831b949e49.zip | |
am c4f93305: Fix for DecimalFormatTest#test_formatToCharacterIteratorLjava_lang_Object
Merge commit 'c4f93305d1fe3d31660af2b47a90d2ebbc6d58f9' into eclair-plus-aosp
* commit 'c4f93305d1fe3d31660af2b47a90d2ebbc6d58f9':
Fix for DecimalFormatTest#test_formatToCharacterIteratorLjava_lang_Object
3 files changed, 46 insertions, 47 deletions
diff --git a/libcore/support/src/test/java/tests/support/Support_DecimalFormat.java b/libcore/support/src/test/java/tests/support/Support_DecimalFormat.java index d86f1a2dc..55bea1e79 100644 --- a/libcore/support/src/test/java/tests/support/Support_DecimalFormat.java +++ b/libcore/support/src/test/java/tests/support/Support_DecimalFormat.java @@ -1,13 +1,13 @@ -/* +/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -132,60 +132,66 @@ public class Support_DecimalFormat extends Support_Format { public void t_formatToCharacterIterator() { Number number = new Double(350.76); + Number longNumber = new Long(100300400); + Number zeroNumber = new Long(0); Number negativeNumber = new Double(-350.76); Locale us = Locale.US; Locale tr = new Locale("de", "CH"); - // test number instance - t_Format(1, number, NumberFormat.getNumberInstance(us), - getNumberVectorUS()); + if (Support_Locale.areLocalesAvailable(us)) { + // locale dependent test, bug 1943269 - // test integer instance - t_Format(2, number, NumberFormat.getIntegerInstance(us), - getIntegerVectorUS()); + // test number instance + t_Format(1, number, NumberFormat.getNumberInstance(us), + getNumberVectorUS()); - // test percent instance - t_Format(3, number, NumberFormat.getPercentInstance(us), - getPercentVectorUS()); + // test integer instance + t_Format(2, number, NumberFormat.getIntegerInstance(us), + getIntegerVectorUS()); + + // test percent instance + t_Format(3, number, NumberFormat.getPercentInstance(us), + getPercentVectorUS()); + + // test currency instance with US Locale + t_Format(4, number, NumberFormat.getCurrencyInstance(us), + getPositiveCurrencyVectorUS()); + + // test negative currency instance with US Locale + t_Format(5, negativeNumber, NumberFormat.getCurrencyInstance(us), + getNegativeCurrencyVectorUS()); + + // test multiple grouping seperators + t_Format(6, longNumber, NumberFormat.getNumberInstance(us), + getNumberVector2US()); + + // test 0 + t_Format(7, zeroNumber, NumberFormat.getNumberInstance(us), + getZeroVector()); + } // test permille pattern DecimalFormat format = new DecimalFormat("###0.##\u2030"); - t_Format(4, number, format, getPermilleVector()); + t_Format(8, number, format, getPermilleVector()); // test exponential pattern with positive exponent format = new DecimalFormat("00.0#E0"); - t_Format(5, number, format, getPositiveExponentVector()); + t_Format(9, number, format, getPositiveExponentVector()); // test exponential pattern with negative exponent format = new DecimalFormat("0000.0#E0"); - t_Format(6, number, format, getNegativeExponentVector()); - - // test currency instance with US Locale - t_Format(7, number, NumberFormat.getCurrencyInstance(us), - getPositiveCurrencyVectorUS()); + t_Format(10, number, format, getNegativeExponentVector()); - // test negative currency instance with US Locale - t_Format(8, negativeNumber, NumberFormat.getCurrencyInstance(us), - getNegativeCurrencyVectorUS()); + if (Support_Locale.areLocalesAvailable(tr)) { + // test currency instance with TR Locale + t_Format(11, number, NumberFormat.getCurrencyInstance(tr), + getPositiveCurrencyVectorCH()); - // test currency instance with TR Locale - t_Format(9, number, NumberFormat.getCurrencyInstance(tr), - getPositiveCurrencyVectorCH()); - - // test negative currency instance with TR Locale - t_Format(10, negativeNumber, NumberFormat.getCurrencyInstance(tr), - getNegativeCurrencyVectorCH()); - - // test multiple grouping seperators - number = new Long(100300400); - t_Format(11, number, NumberFormat.getNumberInstance(us), - getNumberVector2US()); - - // test 0 - number = new Long(0); - t_Format(12, number, NumberFormat.getNumberInstance(us), - getZeroVector()); + // test negative currency instance with TR Locale + t_Format(12, negativeNumber, NumberFormat.getCurrencyInstance(tr), + getNegativeCurrencyVectorCH()); + } } private static Vector<FieldContainer> getNumberVectorUS() { diff --git a/libcore/support/src/test/java/tests/support/Support_Locale.java b/libcore/support/src/test/java/tests/support/Support_Locale.java index c5776cc55..92426e3d0 100644 --- a/libcore/support/src/test/java/tests/support/Support_Locale.java +++ b/libcore/support/src/test/java/tests/support/Support_Locale.java @@ -35,7 +35,7 @@ public class Support_Locale { * * @return true if all requiredLocales are available. */ - public static boolean areLocalesAvailable(Locale[] requiredLocales) { + public static boolean areLocalesAvailable(Locale... requiredLocales) { Locale[] availableLocales = Locale.getAvailableLocales(); Set<Locale> localeSet = new HashSet<Locale>(Arrays.asList(availableLocales)); for (Locale requiredLocale : requiredLocales) { @@ -45,5 +45,4 @@ public class Support_Locale { } return true; } - }
\ No newline at end of file diff --git a/libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java b/libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java index e908e4a52..c2e091ee2 100644 --- a/libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java +++ b/libcore/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java @@ -1809,12 +1809,6 @@ public class DecimalFormatTest extends TestCase { args = {java.lang.Object.class} ) public void test_formatToCharacterIteratorLjava_lang_Object() { - Locale[] requiredLocales = {Locale.US}; - if (!Support_Locale.areLocalesAvailable(requiredLocales)) { - // locale dependent test, bug 1943269 - return; - } - try { // Regression for HARMONY-466 new DecimalFormat().formatToCharacterIterator(null); |
