aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/cgeo/geocaching/utils
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2012-04-18 20:23:18 +0200
committerBananeweizen <bananeweizen@gmx.de>2012-04-18 20:23:18 +0200
commit45e1a0dc358e4a02b2394ae5c140692931eed8e7 (patch)
treeefbc3dfdc569f3ca915587f1788dcdd7da2f1d84 /tests/src/cgeo/geocaching/utils
parentfd79c341e2890516494ead8559b108c225549aa8 (diff)
downloadcgeo-45e1a0dc358e4a02b2394ae5c140692931eed8e7.zip
cgeo-45e1a0dc358e4a02b2394ae5c140692931eed8e7.tar.gz
cgeo-45e1a0dc358e4a02b2394ae5c140692931eed8e7.tar.bz2
refactoring: rest in peace, cgBase
Diffstat (limited to 'tests/src/cgeo/geocaching/utils')
-rw-r--r--tests/src/cgeo/geocaching/utils/BaseUtilsTest.java26
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 "));
+ }
+
+}