From 2a9b40f033dcd2566f5a8e90c7a04d11b9d47d82 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Thu, 22 Feb 2018 10:15:03 -0800 Subject: [PATCH] shapefiles: add tests verifying roundtrip save-and-load. --- extra/shapefiles/shapefiles-tests.factor | 53 ++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 extra/shapefiles/shapefiles-tests.factor diff --git a/extra/shapefiles/shapefiles-tests.factor b/extra/shapefiles/shapefiles-tests.factor new file mode 100644 index 0000000000..5c8620d8b6 --- /dev/null +++ b/extra/shapefiles/shapefiles-tests.factor @@ -0,0 +1,53 @@ +USING: kernel sequences shapefiles tools.test ; +IN: shapefiles.tests + +: save-and-load? ( shapes -- ? ) + [ + [ save-shapes ] [ load-shapes sequence= ] 2bi + ] with-test-file ; + +{ t } [ + { null-shape } save-and-load? +] unit-test + +{ t } [ + { null-shape T{ point f 1.0 2.0 } } save-and-load? +] unit-test + +{ t } [ + { T{ point-m f 1.0 2.0 3.0 } } save-and-load? +] unit-test + +{ t } [ + { T{ point-z f 1.0 2.0 3.0 4.0 } } save-and-load? +] unit-test + +{ t } [ + { T{ polygon + { box { 1.0 3.0 2.0 4.0 } } + { parts { } } + { points { T{ point f 1.0 2.0 } T{ point f 3.0 4.0 } } } } + } save-and-load? +] unit-test + +{ t } [ + { T{ polygon-m + { box { 1.0 3.0 2.0 4.0 } } + { parts { } } + { points { T{ point f 1.0 2.0 } T{ point f 3.0 4.0 } } } + { m-range { 10.0 20.0 } } + { m-array { 10.0 20.0 } } } + } save-and-load? +] unit-test + +{ t } [ + { T{ polygon-z + { box { 1.0 3.0 2.0 4.0 } } + { parts { } } + { points { T{ point f 1.0 2.0 } T{ point f 3.0 4.0 } } } + { z-range { -10.0 -20.0 } } + { z-array { -10.0 -20.0 } } + { m-range { 10.0 20.0 } } + { m-array { 10.0 20.0 } } } + } save-and-load? +] unit-test