use of java.text.AttributedString in project robovm by robovm.
the class OldAttributedStringTest method test_getIterator.
/**
* java.text.AttributedString#getIterator() Test of method
* java.text.AttributedString#getIterator().
*/
public void test_getIterator() {
String test = "Test string";
try {
AttributedString attrString = new AttributedString(test);
AttributedCharacterIterator it = attrString.getIterator();
assertEquals("Incorrect iteration on AttributedString", it.first(), test.charAt(0));
} catch (Exception e) {
fail("Unexpected exceptiption " + e.toString());
}
}
use of java.text.AttributedString in project robovm by robovm.
the class OldAttributedStringTest method test_ConstructorLAttributedCharacterIterator_2.
public void test_ConstructorLAttributedCharacterIterator_2() {
String testString = "Test string";
AttributedString attrString = new AttributedString(testString);
AttributedCharacterIterator iter = attrString.getIterator();
AttributedString attrString2 = new AttributedString(iter, 2, 7);
assertEqualString("String must match!", "st st", attrString2);
}
use of java.text.AttributedString in project robovm by robovm.
the class OldAttributedStringTest method test_ConstructorLjava_lang_StringLjava_util_Map.
/**
* java.text.AttributedString#AttributedString(AttributedCharacterIterator,
* int, int, Map<? extends AttributedCharacterIterator.Attribute,?>)
* Test of method
* java.text.AttributedString#AttributedString(AttributedCharacterIterator,
* int, int, Map<? extends
* AttributedCharacterIterator.Attribute,?>). Case 1: Try to
* construct AttributedString. Case 2: Try to construct
* AttributedString using 0-length text and not an empty Map
* attributes.
*/
public void test_ConstructorLjava_lang_StringLjava_util_Map() {
String test = "Test string";
// case 1: Try to construct AttributedString
try {
AttributedString attrString = new AttributedString(test, new WeakHashMap<AttributedCharacterIterator.Attribute, String>());
AttributedCharacterIterator it = attrString.getIterator();
StringBuffer buf = new StringBuffer();
buf.append(it.first());
char ch;
while ((ch = it.next()) != CharacterIterator.DONE) buf.append(ch);
assertTrue("Wrong string: " + buf, buf.toString().equals(test));
} catch (Exception e) {
fail("Unexpected exception " + e.toString());
}
// not an empty Map attributes.
try {
Map<AttributedCharacterIterator.Attribute, String> whm = new WeakHashMap<AttributedCharacterIterator.Attribute, String>();
whm.put(new TestAttributedCharacterIteratorAttribute("test"), "value");
new AttributedString("", whm);
fail("Expected IllegalArgumentException was not thrown");
} catch (Exception e) {
// expected
}
}
use of java.text.AttributedString in project robovm by robovm.
the class OldAttributedCharacterIteratorTest method test_getAllAttributeKeys.
public void test_getAllAttributeKeys() {
AttributedString as = new AttributedString("test");
AttributedCharacterIterator it = as.getIterator();
Set<AttributedCharacterIterator.Attribute> emptyAttributes = it.getAllAttributeKeys();
assertTrue(emptyAttributes.isEmpty());
int attrCount = 10;
for (int i = 0; i < attrCount; i++) {
as.addAttribute(AttributedCharacterIterator.Attribute.LANGUAGE, "a");
}
it = as.getIterator();
Set<AttributedCharacterIterator.Attribute> attributes = it.getAllAttributeKeys();
for (AttributedCharacterIterator.Attribute attr : attributes) {
assertEquals(AttributedCharacterIterator.Attribute.LANGUAGE, attr);
}
}
use of java.text.AttributedString in project robovm by robovm.
the class OldAttributedCharacterIteratorTest method setUp.
protected void setUp() {
AttributedString as = new AttributedString(string);
as.addAttribute(AttributedCharacterIterator.Attribute.LANGUAGE, "GERMAN");
as.addAttribute(AttributedCharacterIterator.Attribute.READING, "READ");
as.addAttribute(AttributedCharacterIterator.Attribute.LANGUAGE, "ENGLISH");
it = as.getIterator();
}
Aggregations