Test failure cases in AndroidCharacter
Add failure test cases. Also correct a test case for mirror
that started failing after recent array bounds checking change
in the code being tested revealed the test to be invalid.
Change-Id: I83d4679b550ddffcb3a6231d6d2dc0b5ee5c31f6
diff --git a/tests/tests/text/src/android/text/cts/AndroidCharacterTest.java b/tests/tests/text/src/android/text/cts/AndroidCharacterTest.java
index 08dcea7..50a3776 100644
--- a/tests/tests/text/src/android/text/cts/AndroidCharacterTest.java
+++ b/tests/tests/text/src/android/text/cts/AndroidCharacterTest.java
@@ -112,6 +112,24 @@
for (int i = 0; i < dest.length; i++) {
assertEquals(expected[i], dest[i]);
}
+ try {
+ AndroidCharacter.getEastAsianWidths(src, 24, 8, dest);
+ fail("Should throw ArrayIndexOutOfBoundsException.");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // expected.
+ }
+ try {
+ AndroidCharacter.getEastAsianWidths(src, -1024, 1, dest);
+ fail("Should throw ArrayIndexOutOfBoundsException.");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // expected.
+ }
+ try {
+ AndroidCharacter.getEastAsianWidths(src, 0, -1, dest);
+ fail("Should throw ArrayIndexOutOfBoundsException.");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // expected.
+ }
}
@TestTargetNew(
@@ -142,9 +160,27 @@
}
assertFalse(AndroidCharacter.mirror(src, 0, 0));
- assertTrue(AndroidCharacter.mirror(src, 40, 50));
+ assertTrue(AndroidCharacter.mirror(src, 40, 24));
try {
- AndroidCharacter.mirror(src, 65, 90);
+ AndroidCharacter.mirror(src, 65, 1);
+ fail("Should throw ArrayIndexOutOfBoundsException.");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // expected.
+ }
+ try {
+ AndroidCharacter.mirror(src, 60, 10);
+ fail("Should throw ArrayIndexOutOfBoundsException.");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // expected.
+ }
+ try {
+ AndroidCharacter.mirror(src, -1024, 1);
+ fail("Should throw ArrayIndexOutOfBoundsException.");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // expected.
+ }
+ try {
+ AndroidCharacter.mirror(src, 0, -1);
fail("Should throw ArrayIndexOutOfBoundsException.");
} catch (ArrayIndexOutOfBoundsException e) {
// expected.