From b9b9efef83c7417661a56c27269edda37840d0f7 Mon Sep 17 00:00:00 2001 From: dcooley Date: Tue, 31 May 2022 08:42:43 +1000 Subject: [PATCH] test for #95 --- inst/tinytest/test-errors.R | 48 +++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/inst/tinytest/test-errors.R b/inst/tinytest/test-errors.R index d0bcb37..63c31ec 100644 --- a/inst/tinytest/test-errors.R +++ b/inst/tinytest/test-errors.R @@ -1,25 +1,27 @@ ##"errors are handled", { - expect_error(geojson_sf(1:5), "Numeric vectors are not valid GeoJSON") - expect_error(geojson_sf("a"), "Invalid JSON") - expect_error(geojson_sf()) - expect_error(geojson_sf(NULL)) - expect_error(geojson_sf(NA), "Invalid JSON") - expect_error(geojson_sf('{ "type" : "Point" }'), "No 'coordinates' member at object index 0 - invalid GeoJSON") - #expect_error(geojson_sf('{"type" : "MultiPoint","coordinates" : [0,0] }'), "Invalid array object") - expect_error(geojson_sf('{"type" : "Point", "coordinates" : null }'), "No 'array' member at object index 0 - invalid GeoJSON") - #expect_error(geojson_sf('{"type" : "LineString", "coordinates" : [ 0, 0 ] }'), "Invalid array object") - expect_error(geojson_sf('{"type" : "MultiLineString", "coordinates" : [ 0, 0 ] }'), "Invalid array object") - #expect_error(geojson_sf('{"type" : "MultiLineString", "coordinates" : [ [0, 0] ] }'), "Invalid array object") - expect_error(geojson_sf('{"type" : "Polygon", "coordinates" : [0, 0] }'), "Invalid array object") - #expect_error(geojson_sf('{"type" : "Polygon", "coordinates" : [ [ 0, 0 ] ] }'), "Invalid array object") - expect_error(geojson_sf('{"type" : "MultiPolygon", "coordinates" : [ [0, 0] ] }'), "Invalid array object") - #expect_error(geojson_sf('{"type" : "MultiPolygon", "coordinates" : [ [ [0, 0] ] ] }'), "Invalid array object") - expect_error(geojson_wkt('{"type" : "LineString", "coordinates" : [ 0, 0 ] }'), "Invalid array object") - expect_error(geojson_wkt('{"type" : "MultiLineString", "coordinates" : [ 0, 0 ] }'), "Invalid array object") - expect_error(geojson_wkt('{"type" : "MultiLineString", "coordinates" : [ [0, 0] ] }'), "Invalid array object") - expect_error(geojson_wkt('{"type" : "Polygon", "coordinates" : [0, 0] }'), "Invalid array object") - expect_error(geojson_wkt('{"type" : "Polygon", "coordinates" : [ [ 0, 0 ] ] }'), "Invalid array object") - expect_error(geojson_wkt('{"type" : "MultiPolygon", "coordinates" : [ [0, 0] ] }'), "Invalid array object") - expect_error(geojson_wkt('{"type" : "MultiPolygon", "coordinates" : [ [ [0, 0] ] ] }'), "Invalid array object") - expect_error(geojson_sf('{"type" : "Point" , "coordinates" : {} }'), "No 'array' member at object index 0 - invalid GeoJSON") +expect_error(geojson_sf(1:5), "Numeric vectors are not valid GeoJSON") +expect_error(geojson_sf("a"), "Invalid JSON") +expect_error(geojson_sf()) +expect_error(geojson_sf(NULL)) +expect_error(geojson_sf(NA), "Invalid JSON") +expect_error(geojson_sf('{ "type" : "Point" }'), "No 'coordinates' member at object index 0 - invalid GeoJSON") +#expect_error(geojson_sf('{"type" : "MultiPoint","coordinates" : [0,0] }'), "Invalid array object") +expect_error(geojson_sf('{"type" : "Point", "coordinates" : null }'), "No 'array' member at object index 0 - invalid GeoJSON") +#expect_error(geojson_sf('{"type" : "LineString", "coordinates" : [ 0, 0 ] }'), "Invalid array object") +expect_error(geojson_sf('{"type" : "MultiLineString", "coordinates" : [ 0, 0 ] }'), "Invalid array object") +#expect_error(geojson_sf('{"type" : "MultiLineString", "coordinates" : [ [0, 0] ] }'), "Invalid array object") +expect_error(geojson_sf('{"type" : "Polygon", "coordinates" : [0, 0] }'), "Invalid array object") +#expect_error(geojson_sf('{"type" : "Polygon", "coordinates" : [ [ 0, 0 ] ] }'), "Invalid array object") +expect_error(geojson_sf('{"type" : "MultiPolygon", "coordinates" : [ [0, 0] ] }'), "Invalid array object") +#expect_error(geojson_sf('{"type" : "MultiPolygon", "coordinates" : [ [ [0, 0] ] ] }'), "Invalid array object") +expect_error(geojson_wkt('{"type" : "LineString", "coordinates" : [ 0, 0 ] }'), "Invalid array object") +expect_error(geojson_wkt('{"type" : "MultiLineString", "coordinates" : [ 0, 0 ] }'), "Invalid array object") +expect_error(geojson_wkt('{"type" : "MultiLineString", "coordinates" : [ [0, 0] ] }'), "Invalid array object") +expect_error(geojson_wkt('{"type" : "Polygon", "coordinates" : [0, 0] }'), "Invalid array object") +expect_error(geojson_wkt('{"type" : "Polygon", "coordinates" : [ [ 0, 0 ] ] }'), "Invalid array object") +expect_error(geojson_wkt('{"type" : "MultiPolygon", "coordinates" : [ [0, 0] ] }'), "Invalid array object") +expect_error(geojson_wkt('{"type" : "MultiPolygon", "coordinates" : [ [ [0, 0] ] ] }'), "Invalid array object") +expect_error(geojson_sf('{"type" : "Point" , "coordinates" : {} }'), "No 'array' member at object index 0 - invalid GeoJSON") +## Issue 95 +expect_error(geojson_sf("{\"type\": \"Polygon\", \"coordinates\": [[-70.7355,-33.2402],[-70.7355,-33.2404],[-70.7351,-33.2403],[-70.7351,-33.2401],[-70.7355,-33.2402]]}"), "Invalid array object")