Skip to content

Commit

Permalink
test invalid things
Browse files Browse the repository at this point in the history
  • Loading branch information
paleolimbot committed Dec 11, 2024
1 parent 581209c commit 00b85c1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/s2geography/geography_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,9 @@ TEST(Geography, EncodedShapeIndex) {
void TestEncodeWKTRoundtrip(const std::string& wkt,
const EncodeOptions& options) {
SCOPED_TRACE(wkt + " / " + ::testing::PrintToString(options) + " (WKT)");
WKTReader reader;
geoarrow::ImportOptions import_options;
import_options.set_check(false);
WKTReader reader(import_options);
std::unique_ptr<Geography> original_geog = reader.read_feature(wkt);
// Make sure the original geography matches the given WKT
ASSERT_THAT(*original_geog, WktEquals6(wkt));
Expand Down Expand Up @@ -370,4 +372,11 @@ TEST(Geography, EncodeRoundtrip) {
}
}

TEST(Geography, EncodeRoundtripInvalid) {
EncodeOptions opt;
ASSERT_NO_FATAL_FAILURE(
TestEncodeWKTRoundtrip("LINESTRING (0 0, 0 0, 1 1)", opt));
ASSERT_NO_FATAL_FAILURE(TestEncodeWKTRoundtrip("POLYGON ((0 0, 0 0))", opt));
}

} // namespace s2geography
9 changes: 9 additions & 0 deletions src/s2geography/wkt-writer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ TEST(WKTWriter, MixedCollection) {
EXPECT_EQ(wktRoundTrip(wkt), wkt);
}

TEST(WKTWriter, InvalidPolyline) {
WKTReader reader;
try {
auto geog = reader.read_feature("LINESTRING (0 0, 0 0, 1 1)");
} catch (std::exception &e) {
EXPECT_EQ(std::string(e.what()), "Vertices 0 and 1 are identical");
}
}

TEST(WKTWriter, InvalidPolygon) {
WKTReader reader;
try {
Expand Down

0 comments on commit 00b85c1

Please sign in to comment.