diff --git a/.github/workflows/Tests.yml b/.github/workflows/Tests.yml index 853ea1c..5ceb863 100644 --- a/.github/workflows/Tests.yml +++ b/.github/workflows/Tests.yml @@ -26,9 +26,11 @@ jobs: uses: actions/checkout@v2 - name: Install Rust run: | - rustup toolchain install nightly-2021-01-19 - rustup default nightly-2021-01-19 - rustup component add rustfmt miri + MIRI_NIGHTLY=nightly-$(curl -s https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/miri) + echo "Installing latest nightly with Miri: $MIRI_NIGHTLY" + rustup set profile minimal + rustup default "$MIRI_NIGHTLY" + rustup component add miri - name: Run run: | make miri diff --git a/Makefile b/Makefile index 44ec1c7..0974346 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ test: cargo test -- --nocapture + cargo test -- --ignored -- --nocapture miri: cargo miri test -- --nocapture diff --git a/src/lib.rs b/src/lib.rs index ebf2adb..9814c3d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -286,6 +286,22 @@ mod tests { /// verifies the result against std's `sort`. #[test] fn sorted_random_u64_test() { + let mut rng = rand::thread_rng(); + let vec_size = 1025; + let partial_size = (rng.gen::() % vec_size) as usize; + let mut data = (0u64..vec_size) + .map(|_| rng.gen::()) + .collect::>(); + let mut d = data.clone(); + d.sort(); + + data.partial_sort(partial_size, |a, b| a.cmp(b)); + assert_eq!(&d[0..partial_size], &data.as_slice()[0..partial_size]); + } + + #[test] + #[ignore] + fn sorted_expensive_random_u64_test() { for _ in 0..100 { let mut rng = rand::thread_rng(); let vec_size = 1025;