aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/cgeo/geocaching/utils/TextUtilsTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/cgeo/geocaching/utils/TextUtilsTest.java')
-rw-r--r--tests/src/cgeo/geocaching/utils/TextUtilsTest.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/src/cgeo/geocaching/utils/TextUtilsTest.java b/tests/src/cgeo/geocaching/utils/TextUtilsTest.java
index 29c4864..6c6b82d 100644
--- a/tests/src/cgeo/geocaching/utils/TextUtilsTest.java
+++ b/tests/src/cgeo/geocaching/utils/TextUtilsTest.java
@@ -14,7 +14,6 @@ public class TextUtilsTest extends AndroidTestCase {
public static void testRegEx() {
final String page = MockedCache.readCachePage("GC2CJPF");
assertThat(TextUtils.getMatch(page, GCConstants.PATTERN_LOGIN_NAME, true, "???")).isEqualTo(GCConstantsTest.MOCK_LOGIN_NAME);
- assertThat(page.contains("id=\"ctl00_hlRenew\"") || GCConstants.MEMBER_STATUS_PM.equals(TextUtils.getMatch(page, GCConstants.PATTERN_MEMBER_STATUS, true, "???"))).isTrue();
}
public static void testReplaceWhitespaces() {
@@ -26,4 +25,11 @@ public class TextUtilsTest extends AndroidTestCase {
assertThat(TextUtils.getMatch("some" + "\u001C" + "control" + (char) 0x1D + "characters removed", patternAll, "")).isEqualTo("some control characters removed");
assertThat(TextUtils.getMatch("newline\nalso\nremoved", patternAll, "")).isEqualTo("newline also removed");
}
+
+ public static void testGetMatch() {
+ final Pattern patternAll = Pattern.compile("foo(...)");
+ final String text = "abc-foobar-def-fooxyz-ghi-foobaz-jkl";
+ assertThat(TextUtils.getMatch(text, patternAll, false, 1, null, false)).isEqualTo("bar");
+ assertThat(TextUtils.getMatch(text, patternAll, false, 1, null, true)).isEqualTo("baz");
+ }
}