use of android.icu.text.UnicodeSet in project j2objc by google.
the class StringTokenizerTest method TestContains_int_int.
/* Tests the method
* public boolean contains(int start, int end)
*/
@Test
public void TestContains_int_int() {
UnicodeSet us = new UnicodeSet();
int[] invalid = { UnicodeSet.MIN_VALUE - 1, UnicodeSet.MIN_VALUE - 2, UnicodeSet.MAX_VALUE + 1, UnicodeSet.MAX_VALUE + 2 };
// Tests when "if (start < MIN_VALUE || start > MAX_VALUE)" is true
for (int i = 0; i < invalid.length; i++) {
try {
us.contains(invalid[i], UnicodeSet.MAX_VALUE);
errln("UnicodeSet.contains(int start, int end) was suppose to give " + "an exception for an start invalid input of " + invalid[i]);
} catch (Exception e) {
}
}
// Tests when "if (end < MIN_VALUE || end > MAX_VALUE)" is true
for (int i = 0; i < invalid.length; i++) {
try {
us.contains(UnicodeSet.MIN_VALUE, invalid[i]);
errln("UnicodeSet.contains(int start, int end) was suppose to give " + "an exception for an end invalid input of " + invalid[i]);
} catch (Exception e) {
}
}
}
use of android.icu.text.UnicodeSet in project j2objc by google.
the class StringTokenizerTest method TestRetain_int_int.
/* Tests the method
* public UnicodeSet retain(int start, int end)
*/
@Test
public void TestRetain_int_int() {
UnicodeSet us = new UnicodeSet();
int[] invalid = { UnicodeSet.MIN_VALUE - 1, UnicodeSet.MIN_VALUE - 2, UnicodeSet.MAX_VALUE + 1, UnicodeSet.MAX_VALUE + 2 };
// Tests when "if (start < MIN_VALUE || start > MAX_VALUE)" is true
for (int i = 0; i < invalid.length; i++) {
try {
us.retain(invalid[i], UnicodeSet.MAX_VALUE);
errln("UnicodeSet.retain(int start, int end) was suppose to give " + "an exception for an start invalid input of " + invalid[i]);
} catch (Exception e) {
}
}
// Tests when "if (end < MIN_VALUE || end > MAX_VALUE)" is true
for (int i = 0; i < invalid.length; i++) {
try {
us.retain(UnicodeSet.MIN_VALUE, invalid[i]);
errln("UnicodeSet.retain(int start, int end) was suppose to give " + "an exception for an end invalid input of " + invalid[i]);
} catch (Exception e) {
}
}
// Tests when "if (start <= end)" is false
try {
us.retain(UnicodeSet.MIN_VALUE + 1, UnicodeSet.MIN_VALUE);
} catch (Exception e) {
errln("UnicodeSet.retain(int start, int end) was not suppose to give " + "an exception.");
}
try {
us.retain(UnicodeSet.MAX_VALUE, UnicodeSet.MAX_VALUE - 1);
} catch (Exception e) {
errln("UnicodeSet.retain(int start, int end) was not suppose to give " + "an exception.");
}
}
use of android.icu.text.UnicodeSet in project j2objc by google.
the class StringTokenizerTest method TestAdd_int.
/* Tests the method
* private final UnicodeSet add_unchecked(int c)
* from public final UnicodeSet add(int c)
*/
@Test
public void TestAdd_int() {
UnicodeSet us = new UnicodeSet();
int[] invalid = { UnicodeSet.MIN_VALUE - 1, UnicodeSet.MIN_VALUE - 2, UnicodeSet.MAX_VALUE + 1, UnicodeSet.MAX_VALUE + 2 };
// Tests when "if (c < MIN_VALUE || c > MAX_VALUE)" is true
for (int i = 0; i < invalid.length; i++) {
try {
us.add(invalid[i]);
errln("UnicodeSet.add(int c) was suppose to give " + "an exception for an start invalid input of " + invalid[i]);
} catch (Exception e) {
}
}
// Tests when "if (c == MAX_VALUE)" is true
// TODO: Check comment in UnicodeSet.java
}
use of android.icu.text.UnicodeSet in project j2objc by google.
the class StringTokenizerTest method TestIndexOf.
/* Tests the method
* public int indexOf(int c)
*/
@Test
public void TestIndexOf() {
// Tests when "if (c < MIN_VALUE || c > MAX_VALUE)" is true
UnicodeSet us = new UnicodeSet();
int[] invalid = { UnicodeSet.MIN_VALUE - 1, UnicodeSet.MIN_VALUE - 2, UnicodeSet.MAX_VALUE + 1, UnicodeSet.MAX_VALUE + 2 };
int[] valid = { UnicodeSet.MIN_VALUE, UnicodeSet.MIN_VALUE + 1, UnicodeSet.MAX_VALUE, UnicodeSet.MAX_VALUE - 1 };
for (int i = 0; i < invalid.length; i++) {
try {
us.indexOf(invalid[i]);
errln("UnicodeSet.indexOf is suppose to return an exception " + "for a value of " + invalid[i]);
} catch (Exception e) {
}
}
for (int i = 0; i < valid.length; i++) {
try {
us.indexOf(valid[i]);
} catch (Exception e) {
errln("UnicodeSet.indexOf is not suppose to return an exception " + "for a value of " + valid[i]);
}
}
}
use of android.icu.text.UnicodeSet in project j2objc by google.
the class StringTokenizerTest method TestCharAt.
/* Tests the method
* public int charAt(int index)
*/
@Test
public void TestCharAt() {
UnicodeSet us = new UnicodeSet();
// Test when "if (index >= 0)" is false
int[] invalid = { -100, -10, -5, -2, -1 };
for (int i = 0; i < invalid.length; i++) {
if (us.charAt(invalid[i]) != -1) {
errln("UnicodeSet.charAt(int index) was suppose to return -1 " + "for an invalid input of " + invalid[i]);
}
}
}
Aggregations