test: add tests for geo::Coordinate<f64> and geo::Line<f64> for Postgres

This commit is contained in:
Kristy Brambila
2020-07-21 17:17:10 -07:00
parent 8a1c74bb84
commit 16109926bb
4 changed files with 49 additions and 17 deletions

View File

@@ -386,6 +386,24 @@ test_type!(decimal<sqlx::types::Decimal>(Postgres,
"12345.6789::numeric" == sqlx::types::Decimal::from_str("12345.6789").unwrap(),
));
#[cfg(feature = "geo")]
mod geometric {
use super::*;
use geo_::{Coordinate, Line};
test_type!(point<Coordinate<f64>>(Postgres,
"SELECT ({0} ~= $1)::int4, {0} as _2, $2 as _3",
"point (1, 5)" == Coordinate::<f64>::from((1.0, 5.0)),
"point (1.5, 7)" == Coordinate::<f64>::from((1.5, 7.0)),
"point (5.0, 12.5)" == Coordinate::<f64>::from((5.0, 12.5)),
));
test_type!(line<Line<f64>>(Postgres,
"lseg (point (1, 0), point (2, 0))" == Line::<f64>::new((1.0, 0.0), (2.0, 0.0)),
"lseg (point (2, 0), point (1, 0))" == Line::<f64>::new((2.0, 0.0), (1.0, 0.0)),
));
}
const EXC2: Bound<i32> = Bound::Excluded(2);
const EXC3: Bound<i32> = Bound::Excluded(3);
const INC1: Bound<i32> = Bound::Included(1);