-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add some more javadoc and unit tests
- Loading branch information
Showing
4 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
oshdb/src/main/java/org/heigit/ohsome/oshdb/OSHDBBoundable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
oshdb/src/test/java/org/heigit/ohsome/oshdb/util/OSHDBBoundableTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package org.heigit.ohsome.oshdb.util; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.heigit.ohsome.oshdb.OSHDBBoundable; | ||
import org.heigit.ohsome.oshdb.OSHDBBoundingBox; | ||
import org.junit.Test; | ||
|
||
public class OSHDBBoundableTest { | ||
private OSHDBBoundable point = new OSHDBBoundingBox(0L, 0L, 0L, 0L); | ||
private OSHDBBoundable box = new OSHDBBoundingBox(-1L, -1L, 1L, 1L); | ||
|
||
@Test | ||
public void testPoint() { | ||
assertTrue(point.isPoint()); | ||
assertFalse(box.isPoint()); | ||
} | ||
|
||
@Test | ||
public void testValid() { | ||
assertTrue(point.isValid()); | ||
assertTrue(box.isValid()); | ||
OSHDBBoundable invalid = new OSHDBBoundingBox(1L, 1L, -1L, -1L); | ||
assertFalse(invalid.isValid()); | ||
} | ||
|
||
@Test | ||
public void testCovered() { | ||
assertTrue(point.coveredBy(box)); | ||
assertFalse(point.coveredBy(null)); | ||
} | ||
|
||
@Test | ||
public void testIntersects() { | ||
assertTrue(point.intersects(box)); | ||
assertFalse(point.intersects(null)); | ||
} | ||
|
||
@Test | ||
public void testIntersection() { | ||
OSHDBBoundable box2 = new OSHDBBoundingBox(0L, 0L, 2L, 2L); | ||
OSHDBBoundable intersection = box2.intersection(box); | ||
assertEquals(0, intersection.getMinLonLong()); | ||
assertEquals(0, intersection.getMinLatLong()); | ||
assertEquals(1, intersection.getMaxLonLong()); | ||
assertEquals(1, intersection.getMaxLatLong()); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
oshdb/src/test/java/org/heigit/ohsome/oshdb/util/OSHDBTemporalTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.heigit.ohsome.oshdb.util; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.heigit.ohsome.oshdb.OSHDBTemporal; | ||
import org.heigit.ohsome.oshdb.OSHDBTimestamp; | ||
import org.junit.Test; | ||
|
||
public class OSHDBTemporalTest { | ||
@Test | ||
public void testBeforeAfter() { | ||
OSHDBTemporal t1 = new OSHDBTimestamp(0); | ||
OSHDBTemporal t2 = new OSHDBTimestamp(1); | ||
assertTrue(t1.isBefore(t2)); | ||
assertTrue(t2.isAfter(t1)); | ||
assertEquals(0, OSHDBTemporal.compare(t1, t1)); | ||
assertTrue(OSHDBTemporal.compare(t1, t2) < 0); | ||
assertTrue(OSHDBTemporal.compare(t2, t1) > 0); | ||
} | ||
} |