2 * Copyright (C) 2010 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package libcore.java.util;
19 import java.util.Currency;
20 import java.util.Locale;
22 public class CurrencyTest extends junit.framework.TestCase {
23 // Regression test to ensure that Currency.getSymbol(Locale) returns the
24 // currency code if ICU doesn't have a localization of the symbol. The
25 // harmony Currency tests don't test this, and their DecimalFormat tests
26 // only test it as a side-effect, and in a way that only detected my
27 // specific mistake of returning null (returning "stinky" would have
29 public void test_getSymbol_fallback() throws Exception {
30 // This assumes that AED never becomes a currency important enough to
31 // Canada that Canadians give it a localized (to Canada) symbol.
32 assertEquals("AED", Currency.getInstance("AED").getSymbol(Locale.CANADA));
35 // Regression test to ensure that Currency.getInstance(String) throws if
36 // given an invalid ISO currency code.
37 public void test_getInstance_illegal_currency_code() throws Exception {
38 Currency.getInstance("USD");
40 Currency.getInstance("BOGO-DOLLARS");
41 fail("expected IllegalArgumentException for invalid ISO currency code");
42 } catch (IllegalArgumentException expected) {