Skip to content

Commit

Permalink
Add some sanity / ergonomic tests for the multithreading impls
Browse files Browse the repository at this point in the history
  • Loading branch information
urschrei committed Nov 6, 2024
1 parent 76200e7 commit 2c2141d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
14 changes: 14 additions & 0 deletions geo-types/src/geometry/multi_line_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,20 @@ mod test {
use super::*;
use crate::{line_string, wkt};

#[test]
fn test_multithreading_linestring() {
let multi: MultiLineString<i32> = wkt! {
MULTILINESTRING((0 0,2 0,1 2,0 0), (10 10,12 10,11 12,10 10))
};
let mut multimut: MultiLineString<i32> = wkt! {
MULTILINESTRING((0 0,2 0,1 2,0 0), (10 10,12 10,11 12,10 10))
};
let _ = multi.par_iter().for_each(|_p| ());
let _ = multimut.par_iter_mut().for_each(|_p| ());
let _ = &multi.into_par_iter().for_each(|_p| ());
let _ = &mut multimut.par_iter_mut().for_each(|_p| ());
}

#[test]
fn test_iter() {
let multi: MultiLineString<i32> = wkt! {
Expand Down
15 changes: 15 additions & 0 deletions geo-types/src/geometry/multi_polygon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,21 @@ mod test {
}
}

#[test]
fn test_par_iter() {
let multi = MultiPolygon::new(vec![
polygon![(x: 0, y: 0), (x: 2, y: 0), (x: 1, y: 2), (x:0, y:0)],
polygon![(x: 10, y: 10), (x: 12, y: 10), (x: 11, y: 12), (x:10, y:10)],
]);
let mut multimut = MultiPolygon::new(vec![
polygon![(x: 0, y: 0), (x: 2, y: 0), (x: 1, y: 2), (x:0, y:0)],
polygon![(x: 10, y: 10), (x: 12, y: 10), (x: 11, y: 12), (x:10, y:10)],
]);
let _ = multi.par_iter().for_each(|_p| ());
let _ = &multimut.par_iter_mut().for_each(|_p| ());
let _ = &multi.into_par_iter().for_each(|_p| ());
let _ = &mut multimut.par_iter_mut().for_each(|_p| ());
}
#[test]
fn test_iter_mut() {
let mut multi = MultiPolygon::new(vec![
Expand Down

0 comments on commit 2c2141d

Please sign in to comment.