diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2013-08-25 20:45:52 +0200 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2013-08-25 20:45:52 +0200 |
| commit | 38e3af9a7746a07d5ff093496523634e50b82466 (patch) | |
| tree | b3d5b0a15a31def9e2ae2215fa525c913cf4a9fd | |
| parent | 16e1c9199f4fa5106153b176de8c7c2262fe6daa (diff) | |
| download | cgeo-38e3af9a7746a07d5ff093496523634e50b82466.zip cgeo-38e3af9a7746a07d5ff093496523634e50b82466.tar.gz cgeo-38e3af9a7746a07d5ff093496523634e50b82466.tar.bz2 | |
new unit test
| -rw-r--r-- | main/src/cgeo/geocaching/utils/UncertainProperty.java | 5 | ||||
| -rw-r--r-- | tests/src/cgeo/geocaching/utils/UncertainPropertyTest.java | 19 |
2 files changed, 24 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/utils/UncertainProperty.java b/main/src/cgeo/geocaching/utils/UncertainProperty.java index 5f86662..e8686e3 100644 --- a/main/src/cgeo/geocaching/utils/UncertainProperty.java +++ b/main/src/cgeo/geocaching/utils/UncertainProperty.java @@ -2,6 +2,11 @@ package cgeo.geocaching.utils; import cgeo.geocaching.connector.gc.Tile; +/** + * Property with certainty. When merging properties, the one with higher certainty wins. + * + * @param <T> + */ public class UncertainProperty<T> { private final T value; diff --git a/tests/src/cgeo/geocaching/utils/UncertainPropertyTest.java b/tests/src/cgeo/geocaching/utils/UncertainPropertyTest.java new file mode 100644 index 0000000..74aa680 --- /dev/null +++ b/tests/src/cgeo/geocaching/utils/UncertainPropertyTest.java @@ -0,0 +1,19 @@ +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)); + } +} |
