Debian Codegraph @

src/tests/slice.rs

raw symbols SCIP
1 use craterust-analyzer cargo ringbuf 0.3.3 crate/::{transferrust-analyzer cargo ringbuf 0.3.3 transfer/, HeapRbrust-analyzer cargo ringbuf 0.3.3 alias/HeapRb#, Rbrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#};
2
3 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
4 fn push_pop_slicerust-analyzer cargo ringbuf 0.3.3 tests/slice/push_pop_slice().() {
5 let buf = HeapRbrust-analyzer cargo ringbuf 0.3.3 alias/HeapRb#::<i32>::newrust-analyzer cargo ringbuf 0.3.3 ring_buffer/init/impl#[`SharedRb<T, Vec<MaybeUninit<T>>>`]new().(4);
6 let (mut prod, mut cons) = buf.splitrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`]split().();
7
8 let mut tmp = [0; 5];
9
10 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod.push_slicerust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push_slice().(&[]), 0);
11 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod.push_slicerust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push_slice().(&[0, 1, 2]), 3);
12
13 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons.pop_slicerust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]pop_slice().(&mut tmp[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().0..2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().), 2);
14 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tmp[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0..2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()., [0, 1]);
15
16 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod.push_slicerust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push_slice().(&[3, 4]), 2);
17 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod.push_slicerust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push_slice().(&[5, 6]), 1);
18
19 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons.pop_slicerust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]pop_slice().(&mut tmp[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().0..3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().), 3);
20 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tmp[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0..3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()., [2, 3, 4]);
21
22 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod.push_slicerust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push_slice().(&[6, 7, 8, 9]), 3);
23
24 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons.pop_slicerust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]pop_slice().(&mut tmp), 4);
25 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tmp[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0..4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()., [5, 6, 7, 8]);
26 }
27
28 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
29 fn move_slicerust-analyzer cargo ringbuf 0.3.3 tests/slice/move_slice().() {
30 let buf0 = HeapRbrust-analyzer cargo ringbuf 0.3.3 alias/HeapRb#::<i32>::newrust-analyzer cargo ringbuf 0.3.3 ring_buffer/init/impl#[`SharedRb<T, Vec<MaybeUninit<T>>>`]new().(4);
31 let buf1 = HeapRbrust-analyzer cargo ringbuf 0.3.3 alias/HeapRb#::<i32>::newrust-analyzer cargo ringbuf 0.3.3 ring_buffer/init/impl#[`SharedRb<T, Vec<MaybeUninit<T>>>`]new().(4);
32 let (mut prod0, mut cons0) = buf0.splitrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`]split().();
33 let (mut prod1, mut cons1) = buf1.splitrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`]split().();
34
35 let mut tmp = [0; 5];
36
37 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod0.push_slicerust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push_slice().(&[0, 1, 2]), 3);
38
39 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(transferrust-analyzer cargo ringbuf 0.3.3 transfer/transfer().(&mut cons0, &mut prod1, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), 3);
40 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(transferrust-analyzer cargo ringbuf 0.3.3 transfer/transfer().(&mut cons0, &mut prod1, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), 0);
41
42 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons1.pop_slicerust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]pop_slice().(&mut tmp), 3);
43 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tmp[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0..3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()., [0, 1, 2]);
44
45 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod0.push_slicerust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push_slice().(&[3, 4, 5]), 3);
46
47 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(transferrust-analyzer cargo ringbuf 0.3.3 transfer/transfer().(&mut cons0, &mut prod1, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), 3);
48
49 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons1.pop_slicerust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]pop_slice().(&mut tmp), 3);
50 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tmp[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0..3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()., [3, 4, 5]);
51
52 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod1.push_slicerust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push_slice().(&[6, 7, 8]), 3);
53 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod0.push_slicerust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push_slice().(&[9, 10]), 2);
54
55 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(transferrust-analyzer cargo ringbuf 0.3.3 transfer/transfer().(&mut cons0, &mut prod1, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), 1);
56 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(transferrust-analyzer cargo ringbuf 0.3.3 transfer/transfer().(&mut cons0, &mut prod1, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), 0);
57
58 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons1.pop_slicerust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]pop_slice().(&mut tmp), 4);
59 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tmp[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0..4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()., [6, 7, 8, 9]);
60 }
61
62 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
63 fn move_slice_countrust-analyzer cargo ringbuf 0.3.3 tests/slice/move_slice_count().() {
64 let buf0 = HeapRbrust-analyzer cargo ringbuf 0.3.3 alias/HeapRb#::<i32>::newrust-analyzer cargo ringbuf 0.3.3 ring_buffer/init/impl#[`SharedRb<T, Vec<MaybeUninit<T>>>`]new().(4);
65 let buf1 = HeapRbrust-analyzer cargo ringbuf 0.3.3 alias/HeapRb#::<i32>::newrust-analyzer cargo ringbuf 0.3.3 ring_buffer/init/impl#[`SharedRb<T, Vec<MaybeUninit<T>>>`]new().(4);
66 let (mut prod0, mut cons0) = buf0.splitrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`]split().();
67 let (mut prod1, mut cons1) = buf1.splitrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`]split().();
68
69 let mut tmp = [0; 5];
70
71 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod0.push_slicerust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push_slice().(&[0, 1, 2]), 3);
72
73 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(transferrust-analyzer cargo ringbuf 0.3.3 transfer/transfer().(&mut cons0, &mut prod1, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)), 2);
74
75 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons1.pop_slicerust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]pop_slice().(&mut tmp), 2);
76 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tmp[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0..2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()., [0, 1]);
77
78 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(transferrust-analyzer cargo ringbuf 0.3.3 transfer/transfer().(&mut cons0, &mut prod1, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)), 1);
79
80 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons1.pop_slicerust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]pop_slice().(&mut tmp), 1);
81 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tmp[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0..1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()., [2]);
82
83 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod0.push_slicerust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push_slice().(&[3, 4, 5, 6]), 4);
84
85 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(transferrust-analyzer cargo ringbuf 0.3.3 transfer/transfer().(&mut cons0, &mut prod1, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3)), 3);
86
87 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons1.pop_slicerust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]pop_slice().(&mut tmp), 3);
88 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tmp[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0..3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()., [3, 4, 5]);
89
90 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod0.push_slicerust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push_slice().(&[7, 8, 9]), 3);
91
92 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(transferrust-analyzer cargo ringbuf 0.3.3 transfer/transfer().(&mut cons0, &mut prod1, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(5)), 4);
93
94 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons1.pop_slicerust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]pop_slice().(&mut tmp), 4);
95 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tmp[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0..4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()., [6, 7, 8, 9]);
96 }
97
98 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
99 #[should_panic]
100 fn push_slice_panicrust-analyzer cargo ringbuf 0.3.3 tests/slice/push_slice_panic().() {
101 let mut rb = HeapRbrust-analyzer cargo ringbuf 0.3.3 alias/HeapRb#::<i32>::newrust-analyzer cargo ringbuf 0.3.3 ring_buffer/init/impl#[`SharedRb<T, Vec<MaybeUninit<T>>>`]new().(2);
102 rb.push_slicerust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#push_slice().(&[1, 2, 3]);
103 }
104
105 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
106 #[should_panic]
107 fn pop_slice_panicrust-analyzer cargo ringbuf 0.3.3 tests/slice/pop_slice_panic().() {
108 let mut rb = HeapRbrust-analyzer cargo ringbuf 0.3.3 alias/HeapRb#::<i32>::newrust-analyzer cargo ringbuf 0.3.3 ring_buffer/init/impl#[`SharedRb<T, Vec<MaybeUninit<T>>>`]new().(2);
109 rb.pushrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#push().(1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
110 let mut tmp = [0; 2];
111 rb.pop_slicerust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#pop_slice().(&mut tmp);
112 }