use of android.icu.text.UnicodeSet in project j2objc by google.
the class StringTokenizerTest method TestRemove.
/* Tests the method
* public UnicodeSet remove(int start, int end)
*/
@Test
public void TestRemove() {
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.remove(invalid[i], UnicodeSet.MAX_VALUE);
errln("UnicodeSet.remove(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.remove(UnicodeSet.MIN_VALUE, invalid[i]);
errln("UnicodeSet.remove(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.remove(UnicodeSet.MIN_VALUE + 1, UnicodeSet.MIN_VALUE);
} catch (Exception e) {
errln("UnicodeSet.remove(int start, int end) was not suppose to give " + "an exception.");
}
try {
us.remove(UnicodeSet.MAX_VALUE, UnicodeSet.MAX_VALUE - 1);
} catch (Exception e) {
errln("UnicodeSet.remove(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 TestContains_int.
/* Tests the method
* public boolean contains(int c)
*/
@Test
public void TestContains_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.contains(invalid[i]);
errln("UnicodeSet.contains(int c) was suppose to give " + "an exception for an start invalid input of " + invalid[i]);
} catch (Exception e) {
}
}
}
use of android.icu.text.UnicodeSet in project j2objc by google.
the class UtilityTest method TestUnicodeSet.
@Test
public void TestUnicodeSet() {
String[] array = new String[] { "a", "b", "c", "{de}" };
List list = Arrays.asList(array);
Set aset = new HashSet(list);
logln(" *** The source set's size is: " + aset.size());
// The size reads 4
UnicodeSet set = new UnicodeSet();
set.clear();
set.addAll(aset);
logln(" *** After addAll, the UnicodeSet size is: " + set.size());
// The size should also read 4, but 0 is seen instead
}
use of android.icu.text.UnicodeSet in project j2objc by google.
the class UnicodeMap method composeWith.
public UnicodeMap<T> composeWith(UnicodeMap<T> other, Composer<T> composer) {
for (T value : other.getAvailableValues()) {
UnicodeSet set = other.keySet(value);
composeWith(set, value, composer);
}
return this;
}
use of android.icu.text.UnicodeSet in project j2objc by google.
the class UnicodeMap method toString.
public String toString(Comparator<T> collected) {
StringBuffer result = new StringBuffer();
if (collected == null) {
for (int i = 0; i < length - 1; ++i) {
T value = values[i];
if (value == null)
continue;
int start = transitions[i];
int end = transitions[i + 1] - 1;
result.append(Utility.hex(start));
if (start != end)
result.append("-").append(Utility.hex(end));
result.append("=").append(value.toString()).append("\n");
}
if (stringMap != null) {
for (String s : stringMap.keySet()) {
result.append(Utility.hex(s)).append("=").append(stringMap.get(s).toString()).append("\n");
}
}
} else {
Set<T> set = values(new TreeSet<T>(collected));
for (Iterator<T> it = set.iterator(); it.hasNext(); ) {
T value = it.next();
UnicodeSet s = keySet(value);
result.append(value).append("=").append(s.toString()).append("\n");
}
}
return result.toString();
}
Aggregations