We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 057e035 commit 7d42916Copy full SHA for 7d42916
src/insertion_sort.rs
@@ -251,3 +251,22 @@ where
251
// Didn't manage to sort the slice in the limited number of steps.
252
false
253
}
254
+
255
+#[cfg(feature = "std")]
256
+#[cfg(test)]
257
+mod test {
258
+ use super::insertion_sort_shift_left;
259
+ use ndarray::Array1;
260
+ use quickcheck_macros::quickcheck;
261
262
+ #[quickcheck]
263
+ fn sorted(xs: Vec<u32>) {
264
+ let mut array = Array1::from_vec(xs);
265
+ if !array.is_empty() {
266
+ insertion_sort_shift_left(array.view_mut(), 1, &mut u32::lt);
267
+ }
268
+ for i in 1..array.len() {
269
+ assert!(array[i - 1] <= array[i]);
270
271
272
+}
0 commit comments