Skip to content

Commit 2bf3d8a

Browse files
Update closest_points.rs
Adding edge case for large dataset.
1 parent a45a382 commit 2bf3d8a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/geometry/closest_points.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,4 +241,19 @@ mod tests {
241241
Some((Point::new(0., 40.), Point::new(0., 42.)))
242242
);
243243
}
244+
#[test]
245+
fn large_number_of_points() {
246+
let mut vals = vec![];
247+
for i in 0..1000 {
248+
vals.push(Point::new(i as f64, (i * i % 100) as f64));
249+
}
250+
vals.push(Point::new(500.0, 20.0));
251+
vals.push(Point::new(500.000001, 20.0));
252+
253+
assert_display!(
254+
closest_points(&vals),
255+
Some((Point::new(500.0, 20.0), Point::new(500.000001, 20.0)))
256+
);
257+
}
258+
244259
}

0 commit comments

Comments
 (0)