Debian Codegraph @

src/find_run/tests.rs

raw symbols SCIP
1 use craterust-analyzer cargo timsort 0.1.3 crate/::{comparatorrust-analyzer cargo timsort 0.1.3 comparator()., neverrust-analyzer cargo timsort 0.1.3 never()., ord_t_comparatorrust-analyzer cargo timsort 0.1.3 ord_t_comparator().};
2
3 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4 fn emptyrust-analyzer cargo timsort 0.1.3 find_run/tests/empty().() {
5 let list: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<usize> = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
6 let (ord, len) = find_runrust-analyzer cargo timsort 0.1.3 find_run/tests/find_run().(&list);
7 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ord, false);
8 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(len, 0);
9 }
10
11 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
12 fn singlerust-analyzer cargo timsort 0.1.3 find_run/tests/single().() {
13 let (ord, len) = find_runrust-analyzer cargo timsort 0.1.3 find_run/tests/find_run().(&[1]);
14 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ord, false);
15 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(len, 1);
16 }
17
18 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
19 fn greaterrust-analyzer cargo timsort 0.1.3 find_run/tests/greater().() {
20 let (ord, len) = find_runrust-analyzer cargo timsort 0.1.3 find_run/tests/find_run().(&[1, 2, 2, 3, 4, 5]);
21 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ord, false);
22 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(len, 6);
23 }
24
25 // Note: I used to have a version that would allow sub-runs of equal elements in a
26 // less ordering. Unfortunately, reversing those sub-runs creates an unstable sort.
27 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
28 fn less_stablerust-analyzer cargo timsort 0.1.3 find_run/tests/less_stable().() {
29 let (ord, len) = find_runrust-analyzer cargo timsort 0.1.3 find_run/tests/find_run().(&[5, 4, 4, 3, 4, 5]);
30 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ord, true);
31 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(len, 2);
32 }
33
34 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
35 fn lessrust-analyzer cargo timsort 0.1.3 find_run/tests/less().() {
36 let (ord, len) = find_runrust-analyzer cargo timsort 0.1.3 find_run/tests/find_run().(&[5, 4, 3, 2, 1, 0]);
37 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ord, true);
38 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(len, 6);
39 }
40
41 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
42 fn equalrust-analyzer cargo timsort 0.1.3 find_run/tests/equal().() {
43 let (ord, len) = find_runrust-analyzer cargo timsort 0.1.3 find_run/tests/find_run().(&[2, 2, 2, 2, 2, 2]);
44 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ord, false);
45 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(len, 6);
46 }
47
48 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
49 fn get_run_reverserust-analyzer cargo timsort 0.1.3 find_run/tests/get_run_reverse().() {
50 let mut list = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![7, 6, 5, 4, 3, 3];
51 let len = get_runrust-analyzer cargo timsort 0.1.3 find_run/tests/get_run().(&mut list);
52 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(len, 5);
53 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(list[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., 3);
54 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(list[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., 4);
55 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(list[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().2]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., 5);
56 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(list[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().3]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., 6);
57 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(list[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().4]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., 7);
58 }
59
60 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
61 fn get_run_noreverserust-analyzer cargo timsort 0.1.3 find_run/tests/get_run_noreverse().() {
62 let mut list = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![3, 4, 5, 6, 7, 3];
63 let len = get_runrust-analyzer cargo timsort 0.1.3 find_run/tests/get_run().(&mut list);
64 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(len, 5);
65 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(list[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., 3);
66 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(list[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., 4);
67 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(list[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().2]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., 5);
68 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(list[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().3]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., 6);
69 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(list[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().4]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., 7);
70 }
71
72 /// With comparator.
73 fn find_runrust-analyzer cargo timsort 0.1.3 find_run/tests/find_run().<T: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#>(list: &[T]) -> (bool, usize) {
74 superrust-analyzer cargo timsort 0.1.3 find_run/::find_runrust-analyzer cargo timsort 0.1.3 find_run/find_run().(list, &comparatorrust-analyzer cargo timsort 0.1.3 comparator().(|a, b| Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialOrd<&B>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialOrd<&B>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialOrd<&B>`]gt().b))).unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or_else().(neverrust-analyzer cargo timsort 0.1.3 never().)
75 }
76
77 /// With comparator.
78 fn get_runrust-analyzer cargo timsort 0.1.3 find_run/tests/get_run().<T: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#>(list: &mut [T]) -> usize {
79 superrust-analyzer cargo timsort 0.1.3 find_run/::get_runrust-analyzer cargo timsort 0.1.3 find_run/get_run().(list, &ord_t_comparatorrust-analyzer cargo timsort 0.1.3 ord_t_comparator().()).unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or_else().(neverrust-analyzer cargo timsort 0.1.3 never().)
80 }