summaryrefslogtreecommitdiff
path: root/android_icu4j/cts-coverage/src/main/tests/android/icu/cts
diff options
context:
space:
mode:
authorPaul Duffin <paulduffin@google.com>2016-03-21 12:38:49 +0000
committerPaul Duffin <paulduffin@google.com>2016-03-21 16:30:46 +0000
commit11bc9330131107580b9cf84037eee279b5b3dfd2 (patch)
treeaaecbfaee9a804047fb677261c2ebf8f9086d901 /android_icu4j/cts-coverage/src/main/tests/android/icu/cts
parent20ffdaa18feec3a1373d355d1bc5acae357e633b (diff)
downloadicu-11bc9330131107580b9cf84037eee279b5b3dfd2.tar.gz
Added some tests to improve CTS ICU4J coverage
The main purpose of this is to add the infrastructure necessary to add additional CTS coverage tests to ICU4J, a couple of tests are provided because otherwise the code will not build. Bug: 22023363 Change-Id: Iefe35bd1c3ecb74c99ab9c50f0e8969c40cb76db
Diffstat (limited to 'android_icu4j/cts-coverage/src/main/tests/android/icu/cts')
-rw-r--r--android_icu4j/cts-coverage/src/main/tests/android/icu/cts/coverage/TestAll.java32
-rw-r--r--android_icu4j/cts-coverage/src/main/tests/android/icu/cts/coverage/lang/TestAll.java30
-rw-r--r--android_icu4j/cts-coverage/src/main/tests/android/icu/cts/coverage/lang/UCharacterTest.java39
-rw-r--r--android_icu4j/cts-coverage/src/main/tests/android/icu/cts/coverage/text/RelativeDateTimeFormatterTest.java56
-rw-r--r--android_icu4j/cts-coverage/src/main/tests/android/icu/cts/coverage/text/TestAll.java31
-rw-r--r--android_icu4j/cts-coverage/src/main/tests/android/icu/cts/coverage/text/TimeZoneNamesTest.java51
-rw-r--r--android_icu4j/cts-coverage/src/main/tests/android/icu/cts/coverage/util/CurrencyTest.java68
-rw-r--r--android_icu4j/cts-coverage/src/main/tests/android/icu/cts/coverage/util/TestAll.java30
8 files changed, 337 insertions, 0 deletions
diff --git a/android_icu4j/cts-coverage/src/main/tests/android/icu/cts/coverage/TestAll.java b/android_icu4j/cts-coverage/src/main/tests/android/icu/cts/coverage/TestAll.java
new file mode 100644
index 000000000..cb32763c9
--- /dev/null
+++ b/android_icu4j/cts-coverage/src/main/tests/android/icu/cts/coverage/TestAll.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.icu.cts.coverage;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * A suite of all the tests in this package and child packages.
+ */
+@RunWith(Suite.class)
+// Add classes in alphabetical order with a trailing comma even if it's the last entry.
+@Suite.SuiteClasses({
+ android.icu.cts.coverage.lang.TestAll.class,
+ android.icu.cts.coverage.text.TestAll.class,
+ android.icu.cts.coverage.util.TestAll.class,
+})
+public class TestAll {
+}
diff --git a/android_icu4j/cts-coverage/src/main/tests/android/icu/cts/coverage/lang/TestAll.java b/android_icu4j/cts-coverage/src/main/tests/android/icu/cts/coverage/lang/TestAll.java
new file mode 100644
index 000000000..285624434
--- /dev/null
+++ b/android_icu4j/cts-coverage/src/main/tests/android/icu/cts/coverage/lang/TestAll.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.icu.cts.coverage.lang;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * A suite of all the tests in this package.
+ */
+@RunWith(Suite.class)
+// Add classes in alphabetical order with a trailing comma even if it's the last entry.
+@Suite.SuiteClasses({
+ UCharacterTest.class,
+})
+public class TestAll {
+}
diff --git a/android_icu4j/cts-coverage/src/main/tests/android/icu/cts/coverage/lang/UCharacterTest.java b/android_icu4j/cts-coverage/src/main/tests/android/icu/cts/coverage/lang/UCharacterTest.java
new file mode 100644
index 000000000..f821e5a8a
--- /dev/null
+++ b/android_icu4j/cts-coverage/src/main/tests/android/icu/cts/coverage/lang/UCharacterTest.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.icu.cts.coverage.lang;
+
+import android.icu.lang.UCharacter;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Extra tests to improve CTS Test Coverage.
+ */
+@RunWith(JUnit4.class)
+public class UCharacterTest {
+
+ @Test
+ public void testNameAliasing() {
+ int input = '\u01a2';
+ String alias = UCharacter.getNameAlias(input);
+ assertEquals("LATIN CAPITAL LETTER GHA", alias);
+ int output = UCharacter.getCharFromNameAlias(alias);
+ assertEquals("alias for '" + input + "'", input, output);
+ }
+}
diff --git a/android_icu4j/cts-coverage/src/main/tests/android/icu/cts/coverage/text/RelativeDateTimeFormatterTest.java b/android_icu4j/cts-coverage/src/main/tests/android/icu/cts/coverage/text/RelativeDateTimeFormatterTest.java
new file mode 100644
index 000000000..9fc50442a
--- /dev/null
+++ b/android_icu4j/cts-coverage/src/main/tests/android/icu/cts/coverage/text/RelativeDateTimeFormatterTest.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.icu.cts.coverage.text;
+
+import android.icu.text.RelativeDateTimeFormatter;
+import android.icu.util.ULocale;
+import java.util.Locale;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Extra tests to improve CTS Test Coverage.
+ */
+@RunWith(JUnit4.class)
+public class RelativeDateTimeFormatterTest {
+
+ /**
+ * Ensure that it behaves the same with an implicit default locale as it does with explicitly
+ * specifying the default locale.
+ */
+ @Test
+ public void testGetInstance() {
+ RelativeDateTimeFormatter withImplicitDefaultLocale
+ = RelativeDateTimeFormatter.getInstance(Locale.CANADA);
+ RelativeDateTimeFormatter withExplicitDefaultLocale
+ = RelativeDateTimeFormatter.getInstance(ULocale.getDefault());
+
+ String formatWithImplicitDefaultLocale =
+ withImplicitDefaultLocale.format(5,
+ RelativeDateTimeFormatter.Direction.NEXT,
+ RelativeDateTimeFormatter.RelativeUnit.MINUTES);
+
+ String formatWithExplicitDefaultLocale =
+ withExplicitDefaultLocale.format(5,
+ RelativeDateTimeFormatter.Direction.NEXT,
+ RelativeDateTimeFormatter.RelativeUnit.MINUTES);
+
+ assertEquals(formatWithExplicitDefaultLocale, formatWithImplicitDefaultLocale);
+ }
+}
diff --git a/android_icu4j/cts-coverage/src/main/tests/android/icu/cts/coverage/text/TestAll.java b/android_icu4j/cts-coverage/src/main/tests/android/icu/cts/coverage/text/TestAll.java
new file mode 100644
index 000000000..5938896a3
--- /dev/null
+++ b/android_icu4j/cts-coverage/src/main/tests/android/icu/cts/coverage/text/TestAll.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.icu.cts.coverage.text;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * A suite of all the tests in this package.
+ */
+@RunWith(Suite.class)
+// Add classes in alphabetical order with a trailing comma even if it's the last entry.
+@Suite.SuiteClasses({
+ RelativeDateTimeFormatterTest.class,
+ TimeZoneNamesTest.class,
+})
+public class TestAll {
+}
diff --git a/android_icu4j/cts-coverage/src/main/tests/android/icu/cts/coverage/text/TimeZoneNamesTest.java b/android_icu4j/cts-coverage/src/main/tests/android/icu/cts/coverage/text/TimeZoneNamesTest.java
new file mode 100644
index 000000000..5af46b94f
--- /dev/null
+++ b/android_icu4j/cts-coverage/src/main/tests/android/icu/cts/coverage/text/TimeZoneNamesTest.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.icu.cts.coverage.text;
+
+import android.icu.text.TimeZoneNames;
+import android.icu.util.ULocale;
+import java.util.Locale;
+import java.util.Set;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Extra tests to improve CTS Test Coverage.
+ */
+@RunWith(JUnit4.class)
+public class TimeZoneNamesTest {
+
+ @Test
+ public void testGetInstance_Locale() {
+ TimeZoneNames uLocaleInstance = TimeZoneNames.getInstance(ULocale.CANADA);
+ TimeZoneNames localeInstance = TimeZoneNames.getInstance(Locale.CANADA);
+
+ Set<String> uLocaleAvailableIds = uLocaleInstance.getAvailableMetaZoneIDs();
+ Set<String> localeAvailableIds = localeInstance.getAvailableMetaZoneIDs();
+ assertEquals("Available ids", uLocaleAvailableIds, localeAvailableIds);
+
+ for (String availableId : uLocaleAvailableIds) {
+ long date = 1458385200000L;
+ TimeZoneNames.NameType nameType = TimeZoneNames.NameType.SHORT_GENERIC;
+ String uLocaleName = uLocaleInstance.getDisplayName(availableId, nameType, date);
+ String localeName = localeInstance.getDisplayName(availableId, nameType, date);
+ assertEquals("Id: " + availableId, uLocaleName, localeName);
+ }
+ }
+}
diff --git a/android_icu4j/cts-coverage/src/main/tests/android/icu/cts/coverage/util/CurrencyTest.java b/android_icu4j/cts-coverage/src/main/tests/android/icu/cts/coverage/util/CurrencyTest.java
new file mode 100644
index 000000000..26f530f46
--- /dev/null
+++ b/android_icu4j/cts-coverage/src/main/tests/android/icu/cts/coverage/util/CurrencyTest.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.icu.cts.coverage.util;
+
+import android.icu.util.Currency;
+import android.icu.util.ULocale;
+import java.util.Locale;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Extra tests to improve CTS Test Coverage.
+ */
+@RunWith(JUnit4.class)
+public class CurrencyTest {
+
+ @Test
+ public void testGetName_Locale_Int_String_BooleanArray() {
+ Currency currency = Currency.getInstance(ULocale.CHINA);
+ boolean[] isChoiceFormat = new boolean[1];
+ int nameStyle = Currency.LONG_NAME;
+ String pluralCount = "";
+ String ulocaleName =
+ currency.getName(ULocale.CANADA, nameStyle, pluralCount, isChoiceFormat);
+ assertEquals("Chinese Yuan", ulocaleName);
+ String localeName = currency.getName(Locale.CANADA, nameStyle, pluralCount, isChoiceFormat);
+ assertEquals("currency name mismatch", ulocaleName, localeName);
+ }
+
+ @Test
+ public void testGetDefaultFractionDigits_CurrencyUsage() {
+ Currency currency = Currency.getInstance(ULocale.CHINA);
+ int cashFractionDigits = currency.getDefaultFractionDigits(Currency.CurrencyUsage.CASH);
+ assertEquals(2, cashFractionDigits);
+ }
+
+ @Test
+ public void testGetRoundingIncrement() {
+ Currency currency = Currency.getInstance(ULocale.JAPAN);
+ // It appears as though this always returns 0 irrespective of the currency.
+ double roundingIncrement = currency.getRoundingIncrement();
+ assertEquals(0, roundingIncrement, 0);
+ }
+
+ @Test
+ public void testGetRoundingIncrement_CurrencyUsage() {
+ Currency currency = Currency.getInstance(ULocale.JAPAN);
+ // It appears as though this always returns 0 irrespective of the currency or usage.
+ double roundingIncrement = currency.getRoundingIncrement(Currency.CurrencyUsage.CASH);
+ assertEquals(0, roundingIncrement, 0);
+ }
+}
diff --git a/android_icu4j/cts-coverage/src/main/tests/android/icu/cts/coverage/util/TestAll.java b/android_icu4j/cts-coverage/src/main/tests/android/icu/cts/coverage/util/TestAll.java
new file mode 100644
index 000000000..d1e78d213
--- /dev/null
+++ b/android_icu4j/cts-coverage/src/main/tests/android/icu/cts/coverage/util/TestAll.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.icu.cts.coverage.util;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * A suite of all the tests in this package.
+ */
+@RunWith(Suite.class)
+// Add classes in alphabetical order with a trailing comma even if it's the last entry.
+@Suite.SuiteClasses({
+ CurrencyTest.class,
+})
+public class TestAll {
+}