Skip to content

Commit

Permalink
assert that attributes are still there
Browse files Browse the repository at this point in the history
  • Loading branch information
jdroenner committed Jan 20, 2022
1 parent 929f0fd commit 84054c1
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 6 deletions.
17 changes: 16 additions & 1 deletion datatypes/src/collections/multi_line_string_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ mod tests {
use super::*;

use crate::collections::{BuilderProvider, FeatureCollectionModifications};
use crate::primitives::TimeInterval;
use crate::primitives::{FeatureDataRef, TimeInterval};

#[test]
fn single_line() {
Expand Down Expand Up @@ -579,6 +579,7 @@ mod tests {

let proj_collection = collection.reproject(&projector).unwrap();

// Assert geometrys are approx equal
proj_collection
.geometries()
.into_iter()
Expand All @@ -591,5 +592,19 @@ mod tests {
epsilon = 0.00001
));
});

// Assert that feature time intervals did not move around
assert_eq!(proj_collection.time_intervals().len(), 2);
assert_eq!(
proj_collection.time_intervals(),
&[TimeInterval::default(), TimeInterval::default()]
);

// Assert that feature data did not magicaly disappear
if let FeatureDataRef::Int(numbers) = proj_collection.data("A").unwrap() {
assert_eq!(numbers.as_ref(), &[1, 2]);
} else {
unreachable!();
}
}
}
33 changes: 29 additions & 4 deletions datatypes/src/collections/multi_point_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1163,31 +1163,56 @@ mod tests {
],
{
let mut map = HashMap::new();
map.insert("numbers".into(), FeatureData::Float(vec![0., 1.]));
map.insert("numbers".into(), FeatureData::Int(vec![0, 1]));
map.insert(
"number_nulls".into(),
FeatureData::NullableFloat(vec![Some(0.), None]),
FeatureData::NullableInt(vec![Some(0), None]),
);
map
},
)
.unwrap();

let expected = MultiPoint::many(vec![
let expected_points = MultiPoint::many(vec![
vec![MARBURG_EPSG_900_913, COLOGNE_EPSG_900_913],
vec![HAMBURG_EPSG_900_913],
])
.unwrap();

let proj_pc = pc.reproject(&projector).unwrap();

// Assert geometrys are approx equal
proj_pc
.geometries()
.into_iter()
.zip(expected.iter())
.zip(expected_points.iter())
.for_each(|(a, e)| {
assert!(approx_eq!(&MultiPoint, &a.into(), e, epsilon = 0.000_001));
});

// Assert that feature time intervals did not move around
assert_eq!(proj_pc.time_intervals().len(), 2);
assert_eq!(
proj_pc.time_intervals(),
&[
TimeInterval::new_unchecked(0, 1),
TimeInterval::new_unchecked(1, 2),
]
);

// Assert that feature data did not magicaly disappear
if let FeatureDataRef::Int(numbers) = proj_pc.data("numbers").unwrap() {
assert_eq!(numbers.as_ref(), &[0, 1]);
} else {
unreachable!();
}

if let FeatureDataRef::Int(numbers) = proj_pc.data("number_nulls").unwrap() {
assert_eq!(numbers.as_ref()[1], 0);
assert_eq!(numbers.nulls(), vec![false, true]);
} else {
unreachable!();
}
}

#[test]
Expand Down
17 changes: 16 additions & 1 deletion datatypes/src/collections/multi_polygon_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ mod tests {
use super::*;

use crate::collections::{BuilderProvider, FeatureCollectionModifications};
use crate::primitives::TimeInterval;
use crate::primitives::{FeatureDataRef, TimeInterval};

#[test]
fn single_polygons() {
Expand Down Expand Up @@ -896,13 +896,28 @@ mod tests {

let proj_collection = collection.reproject(&projector).unwrap();

// Assert geometrys are approx equal
proj_collection
.geometries()
.into_iter()
.zip(expected.iter())
.for_each(|(a, e)| {
assert!(approx_eq!(&MultiPolygon, &a.into(), e, epsilon = 0.00001));
});

// Assert that feature time intervals did not move around
assert_eq!(proj_collection.time_intervals().len(), 2);
assert_eq!(
proj_collection.time_intervals(),
&[TimeInterval::default(), TimeInterval::default()]
);

// Assert that feature data did not magicaly disappear
if let FeatureDataRef::Int(numbers) = proj_collection.data("A").unwrap() {
assert_eq!(numbers.as_ref(), &[1, 2]);
} else {
unreachable!();
}
}

#[test]
Expand Down

0 comments on commit 84054c1

Please sign in to comment.