Debian Codegraph @

src/tests/read_write.rs

raw symbols SCIP
1 use craterust-analyzer cargo ringbuf 0.3.3 crate/::HeapRbrust-analyzer cargo ringbuf 0.3.3 alias/HeapRb#;
2 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/;
3
4 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5 fn fromrust-analyzer cargo ringbuf 0.3.3 tests/read_write/from().() {
6 let buf0 = HeapRbrust-analyzer cargo ringbuf 0.3.3 alias/HeapRb#::<u8>::newrust-analyzer cargo ringbuf 0.3.3 ring_buffer/init/impl#[`SharedRb<T, Vec<MaybeUninit<T>>>`]new().(4);
7 let buf1 = HeapRbrust-analyzer cargo ringbuf 0.3.3 alias/HeapRb#::<u8>::newrust-analyzer cargo ringbuf 0.3.3 ring_buffer/init/impl#[`SharedRb<T, Vec<MaybeUninit<T>>>`]new().(4);
8 let (mut prod0, mut cons0) = buf0.splitrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`]split().();
9 let (mut prod1, mut cons1) = buf1.splitrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`]split().();
10
11 let mut tmp = [0; 5];
12
13 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);
14
15 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod1.read_fromrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<u8, R>`]read_from().(&mut cons0, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 3);
16 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
17 prod1.read_fromrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<u8, R>`]read_from().(&mut cons0, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().().kindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]kind().(),
18 iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::WouldBlockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#WouldBlock#
19 );
20
21 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);
22 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]);
23
24 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);
25
26 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod1.read_fromrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<u8, R>`]read_from().(&mut cons0, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 1);
27 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);
28 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()., [3]);
29
30 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod1.read_fromrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<u8, R>`]read_from().(&mut cons0, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 2);
31 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);
32 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()., [4, 5]);
33
34 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);
35 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);
36
37 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod1.read_fromrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<u8, R>`]read_from().(&mut cons0, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 1);
38 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod1.read_fromrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<u8, R>`]read_from().(&mut cons0, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 0);
39
40 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);
41 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]);
42 }
43
44 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
45 fn intorust-analyzer cargo ringbuf 0.3.3 tests/read_write/into().() {
46 let buf0 = HeapRbrust-analyzer cargo ringbuf 0.3.3 alias/HeapRb#::<u8>::newrust-analyzer cargo ringbuf 0.3.3 ring_buffer/init/impl#[`SharedRb<T, Vec<MaybeUninit<T>>>`]new().(4);
47 let buf1 = HeapRbrust-analyzer cargo ringbuf 0.3.3 alias/HeapRb#::<u8>::newrust-analyzer cargo ringbuf 0.3.3 ring_buffer/init/impl#[`SharedRb<T, Vec<MaybeUninit<T>>>`]new().(4);
48 let (mut prod0, mut cons0) = buf0.splitrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`]split().();
49 let (mut prod1, mut cons1) = buf1.splitrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`]split().();
50
51 let mut tmp = [0; 5];
52
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().(&[0, 1, 2]), 3);
54
55 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons0.write_intorust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<u8, R>`]write_into().(&mut prod1, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 3);
56 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons0.write_intorust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<u8, R>`]write_into().(&mut prod1, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 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), 3);
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..3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()., [0, 1, 2]);
60
61 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);
62
63 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons0.write_intorust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<u8, R>`]write_into().(&mut prod1, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 1);
64 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);
65 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()., [3]);
66
67 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons0.write_intorust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<u8, R>`]write_into().(&mut prod1, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 2);
68 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);
69 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()., [4, 5]);
70
71 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);
72 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);
73
74 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons0.write_intorust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<u8, R>`]write_into().(&mut prod1, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 1);
75 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
76 cons0.write_intorust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<u8, R>`]write_into().(&mut prod1, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().().kindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]kind().(),
77 iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::WouldBlockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#WouldBlock#
78 );
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), 4);
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..4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()., [6, 7, 8, 9]);
82 }
83
84 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
85 fn countrust-analyzer cargo ringbuf 0.3.3 tests/read_write/count().() {
86 let buf0 = HeapRbrust-analyzer cargo ringbuf 0.3.3 alias/HeapRb#::<u8>::newrust-analyzer cargo ringbuf 0.3.3 ring_buffer/init/impl#[`SharedRb<T, Vec<MaybeUninit<T>>>`]new().(4);
87 let buf1 = HeapRbrust-analyzer cargo ringbuf 0.3.3 alias/HeapRb#::<u8>::newrust-analyzer cargo ringbuf 0.3.3 ring_buffer/init/impl#[`SharedRb<T, Vec<MaybeUninit<T>>>`]new().(4);
88 let (mut prod0, mut cons0) = buf0.splitrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`]split().();
89 let (mut prod1, mut cons1) = buf1.splitrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`]split().();
90
91 let mut tmp = [0; 5];
92
93 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]), 4);
94
95 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod1.read_fromrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<u8, R>`]read_from().(&mut cons0, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3)).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 3);
96
97 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);
98 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]);
99
100 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().(&[4, 5, 6]), 3);
101
102 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons0.write_intorust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<u8, R>`]write_into().(&mut prod1, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3)).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 1);
103 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons0.write_intorust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<u8, R>`]write_into().(&mut prod1, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 2);
104 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons0.write_intorust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<u8, R>`]write_into().(&mut prod1, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 1);
105
106 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);
107 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()., [3, 4, 5, 6]);
108 }