diff options
Diffstat (limited to 'tests/src/cgeo/geocaching/utils')
| -rw-r--r-- | tests/src/cgeo/geocaching/utils/FormatterTest.java | 33 | ||||
| -rw-r--r-- | tests/src/cgeo/geocaching/utils/UncertainPropertyTest.java | 19 |
2 files changed, 33 insertions, 19 deletions
diff --git a/tests/src/cgeo/geocaching/utils/FormatterTest.java b/tests/src/cgeo/geocaching/utils/FormatterTest.java new file mode 100644 index 0000000..c91445d --- /dev/null +++ b/tests/src/cgeo/geocaching/utils/FormatterTest.java @@ -0,0 +1,33 @@ +package cgeo.geocaching.utils; + +import static org.assertj.core.api.Assertions.assertThat; + +import cgeo.geocaching.CgeoApplication; +import cgeo.geocaching.R; +import cgeo.geocaching.Waypoint; +import cgeo.geocaching.enumerations.WaypointType; +import cgeo.geocaching.utils.Formatter; + +import android.test.AndroidTestCase; + +public class FormatterTest extends AndroidTestCase { + + public static void testParkingWaypoint() { + assertFormatting(new Waypoint("you can park here", WaypointType.PARKING, false), WaypointType.PARKING.getL10n()); + } + + public static void testOriginalWaypoint() { + assertFormatting(new Waypoint("an original", WaypointType.ORIGINAL, false), WaypointType.ORIGINAL.getL10n()); + } + + public static void testOwnWaypoint() { + final Waypoint own = new Waypoint("my own", WaypointType.OWN, true); + own.setPrefix(Waypoint.PREFIX_OWN); + assertFormatting(own, CgeoApplication.getInstance().getString(R.string.waypoint_custom)); + } + + private static void assertFormatting(Waypoint waypoint, String expected) { + assertThat(Formatter.formatWaypointInfo(waypoint)).isEqualTo(expected); + } + +} diff --git a/tests/src/cgeo/geocaching/utils/UncertainPropertyTest.java b/tests/src/cgeo/geocaching/utils/UncertainPropertyTest.java deleted file mode 100644 index 74aa680..0000000 --- a/tests/src/cgeo/geocaching/utils/UncertainPropertyTest.java +++ /dev/null @@ -1,19 +0,0 @@ -package cgeo.geocaching.utils; - -import junit.framework.TestCase; - -public class UncertainPropertyTest extends TestCase { - - public static void testHigherCertaintyWins() throws Exception { - final UncertainProperty<String> prop1 = new UncertainProperty<String>("prop1", 10); - final UncertainProperty<String> prop2 = new UncertainProperty<String>("prop2", 20); - assertEquals(prop2, UncertainProperty.getMergedProperty(prop1, prop2)); - } - - public static void testAvoidNull() throws Exception { - final UncertainProperty<String> prop1 = new UncertainProperty<String>("prop1", 10); - final UncertainProperty<String> prop2 = new UncertainProperty<String>(null, 20); - assertEquals(prop1, UncertainProperty.getMergedProperty(prop1, prop2)); - assertEquals(prop1, UncertainProperty.getMergedProperty(prop2, prop1)); - } -} |
