diff options
Diffstat (limited to 'tests/src/cgeo/geocaching/utils/BaseUtilsTest.java')
-rw-r--r-- | tests/src/cgeo/geocaching/utils/BaseUtilsTest.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/src/cgeo/geocaching/utils/BaseUtilsTest.java b/tests/src/cgeo/geocaching/utils/BaseUtilsTest.java new file mode 100644 index 0000000..e174d1f --- /dev/null +++ b/tests/src/cgeo/geocaching/utils/BaseUtilsTest.java @@ -0,0 +1,26 @@ +package cgeo.geocaching.utils; + +import cgeo.geocaching.connector.gc.GCConstants; +import cgeo.geocaching.test.mock.MockedCache; + +import android.test.AndroidTestCase; + +public class BaseUtilsTest extends AndroidTestCase { + public static void testRegEx() { + String page = MockedCache.readCachePage("GC2CJPF"); + assertEquals("blafoo", BaseUtils.getMatch(page, GCConstants.PATTERN_LOGIN_NAME, true, "???")); + assertTrue(page.contains("id=\"ctl00_hlRenew\"") || "Premium Member".equals(BaseUtils.getMatch(page, GCConstants.PATTERN_MEMBER_STATUS, true, "???"))); + int cachesFound = 0; + try { + cachesFound = Integer.parseInt(BaseUtils.getMatch(page, GCConstants.PATTERN_CACHES_FOUND, true, "0").replaceAll("[,.]", "")); + } catch (NumberFormatException e) { + fail(); + } + assertTrue(cachesFound >= 491); + } + + public static void testReplaceWhitespaces() { + assertEquals("foo bar baz ", BaseUtils.replaceWhitespace(" foo\n\tbar \r baz ")); + } + +} |