-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-162 handle empty point / shape collection in toString
Signed-off-by: Jeen Broekstra <[email protected]>
- Loading branch information
1 parent
86f83bf
commit 12f8b11
Showing
2 changed files
with
59 additions
and
8 deletions.
There are no files selected for viewing
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
40 changes: 40 additions & 0 deletions
40
src/test/java/org/locationtech/spatial4j/io/WKTWriterTest.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,40 @@ | ||
package org.locationtech.spatial4j.io; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import java.util.ArrayList; | ||
import org.junit.Test; | ||
import org.locationtech.spatial4j.context.SpatialContext; | ||
import org.locationtech.spatial4j.shape.Point; | ||
import org.locationtech.spatial4j.shape.ShapeCollection; | ||
|
||
public class WKTWriterTest { | ||
|
||
private SpatialContext ctx; | ||
|
||
protected WKTWriterTest(SpatialContext ctx) { | ||
this.ctx = ctx; | ||
} | ||
|
||
public WKTWriterTest() { | ||
this(SpatialContext.GEO); | ||
} | ||
|
||
@Test | ||
public void testToStringOnEmptyPoint() throws Exception { | ||
ShapeWriter writer = ctx.getFormats().getWktWriter(); | ||
Point emptyPoint = ctx.makePoint(Double.NaN, Double.NaN); | ||
|
||
assertEquals("POINT EMPTY", writer.toString(emptyPoint)); | ||
|
||
} | ||
|
||
@Test | ||
public void testToStringOnEmptyShapeCollection() throws Exception { | ||
ShapeWriter writer = ctx.getFormats().getWktWriter(); | ||
ShapeCollection<Point> emptyCollection = ctx.makeCollection(new ArrayList<Point>()); | ||
|
||
assertEquals("GEOMETRYCOLLECTION EMPTY", writer.toString(emptyCollection)); | ||
|
||
} | ||
|
||
} |