use of android.icu.text.StringSearch in project j2objc by google.
the class SearchTest method TestContractionCanonical.
@Test
public void TestContractionCanonical() {
String rules = CONTRACTIONRULE;
RuleBasedCollator collator = null;
try {
collator = new RuleBasedCollator(rules);
collator.setStrength(TERTIARY);
collator.setDecomposition(Collator.CANONICAL_DECOMPOSITION);
} catch (Exception e) {
errln("Error opening collator ");
}
String text = "text";
String pattern = "pattern";
StringSearch strsrch = null;
try {
strsrch = new StringSearch(pattern, new StringCharacterIterator(text), collator, null);
strsrch.setCanonical(true);
} catch (Exception e) {
errln("Error opening string search");
}
for (int count = 0; count < CONTRACTIONCANONICAL.length; count++) {
text = CONTRACTIONCANONICAL[count].text;
pattern = CONTRACTIONCANONICAL[count].pattern;
strsrch.setTarget(new StringCharacterIterator(text));
strsrch.setPattern(pattern);
if (!assertEqualWithStringSearch(strsrch, CONTRACTIONCANONICAL[count])) {
errln("Error at test number " + count);
}
}
}
use of android.icu.text.StringSearch in project j2objc by google.
the class SearchTest method TestTextCanonical.
@Test
public void TestTextCanonical() {
StringCharacterIterator t = new StringCharacterIterator(TEXTCANONICAL[0].text);
StringSearch strsrch = new StringSearch(TEXTCANONICAL[0].pattern, t, m_en_us_, null);
strsrch.setCanonical(true);
if (!t.equals(strsrch.getTarget())) {
errln("Error setting text");
}
if (!assertEqualWithStringSearch(strsrch, TEXTCANONICAL[0])) {
strsrch = null;
return;
}
t = new StringCharacterIterator(TEXTCANONICAL[1].text);
strsrch.setTarget(t);
if (!t.equals(strsrch.getTarget())) {
errln("Error setting text");
strsrch = null;
return;
}
if (!assertEqualWithStringSearch(strsrch, TEXTCANONICAL[1])) {
strsrch = null;
return;
}
t = new StringCharacterIterator(TEXTCANONICAL[0].text);
strsrch.setTarget(t);
if (!t.equals(strsrch.getTarget())) {
errln("Error setting text");
strsrch = null;
return;
}
if (!assertEqualWithStringSearch(strsrch, TEXTCANONICAL[0])) {
errln("Error at assertEqualWithStringSearch");
strsrch = null;
return;
}
}
Aggregations