From e7661fd71ff17acff3052db22bcf8223faeaae2e Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Mon, 25 May 2020 05:48:40 -0700 Subject: [PATCH] Fix geo-types tests --- .../types/{geo_010.rs => geo_types_04.rs} | 2 +- .../tests/test/types/geo_types_05.rs | 60 +++++++++++++++++++ tokio-postgres/tests/test/types/mod.rs | 6 +- 3 files changed, 65 insertions(+), 3 deletions(-) rename tokio-postgres/tests/test/types/{geo_010.rs => geo_types_04.rs} (95%) create mode 100644 tokio-postgres/tests/test/types/geo_types_05.rs diff --git a/tokio-postgres/tests/test/types/geo_010.rs b/tokio-postgres/tests/test/types/geo_types_04.rs similarity index 95% rename from tokio-postgres/tests/test/types/geo_010.rs rename to tokio-postgres/tests/test/types/geo_types_04.rs index 6e3d835b..b26fb409 100644 --- a/tokio-postgres/tests/test/types/geo_010.rs +++ b/tokio-postgres/tests/test/types/geo_types_04.rs @@ -1,4 +1,4 @@ -use geo_010::{Coordinate, LineString, Point, Rect}; +use geo_types_04::{Coordinate, LineString, Point, Rect}; use crate::types::test_type; diff --git a/tokio-postgres/tests/test/types/geo_types_05.rs b/tokio-postgres/tests/test/types/geo_types_05.rs new file mode 100644 index 00000000..b53951c1 --- /dev/null +++ b/tokio-postgres/tests/test/types/geo_types_05.rs @@ -0,0 +1,60 @@ +use geo_types_05::{Coordinate, LineString, Point, Rect}; + +use crate::types::test_type; + +#[tokio::test] +async fn test_point_params() { + test_type( + "POINT", + &[ + (Some(Point::new(0.0, 0.0)), "POINT(0, 0)"), + (Some(Point::new(-3.14, 1.618)), "POINT(-3.14, 1.618)"), + (None, "NULL"), + ], + ) + .await; +} + +#[tokio::test] +async fn test_box_params() { + test_type( + "BOX", + &[ + ( + Some(Rect::new( + Coordinate { x: -3.14, y: 1.618 }, + Coordinate { + x: 160.0, + y: 69701.5615, + }, + )), + "BOX(POINT(160.0, 69701.5615), POINT(-3.14, 1.618))", + ), + (None, "NULL"), + ], + ) + .await; +} + +#[tokio::test] +async fn test_path_params() { + let points = vec![ + Coordinate { x: 0., y: 0. }, + Coordinate { x: -3.14, y: 1.618 }, + Coordinate { + x: 160.0, + y: 69701.5615, + }, + ]; + test_type( + "PATH", + &[ + ( + Some(LineString(points)), + "path '((0, 0), (-3.14, 1.618), (160.0, 69701.5615))'", + ), + (None, "NULL"), + ], + ) + .await; +} diff --git a/tokio-postgres/tests/test/types/mod.rs b/tokio-postgres/tests/test/types/mod.rs index 5d292db5..9f96019f 100644 --- a/tokio-postgres/tests/test/types/mod.rs +++ b/tokio-postgres/tests/test/types/mod.rs @@ -18,8 +18,10 @@ mod bit_vec_06; mod chrono_04; #[cfg(feature = "with-eui48-0_4")] mod eui48_04; -#[cfg(feature = "with-geo-0_10")] -mod geo_010; +#[cfg(feature = "with-geo-types-0_4")] +mod geo_types_04; +#[cfg(feature = "with-geo-types-0_5")] +mod geo_types_05; #[cfg(feature = "with-serde_json-1")] mod serde_json_1; #[cfg(feature = "with-time-0_2")]