Debian Codegraph @

src/tests/fmt_write.rs

raw symbols SCIP
1 use craterust-analyzer cargo ringbuf 0.3.3 crate/::StaticRbrust-analyzer cargo ringbuf 0.3.3 alias/StaticRb#;
2 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Write#;
3
4 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5 fn writerust-analyzer cargo ringbuf 0.3.3 tests/fmt_write/write().() {
6 let mut buf = StaticRbrust-analyzer cargo ringbuf 0.3.3 alias/StaticRb#::<u8, 40>::defaultrust-analyzer cargo ringbuf 0.3.3 ring_buffer/init/impl#[`SharedRb<T, [MaybeUninit<T>; N]>`][Default]default().();
7
8 let (mut prod, mut cons) = buf.split_refrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`]split_ref().();
9
10 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(prod, "Hello world!\n"), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()));
11 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(prod, "The answer is {}\n", 42), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()));
12
13 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons.lenrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]len().(), 30);
14 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cons
15 .pop_iterrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]pop_iter().()
16 .eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#eq().(b"Hello world!\nThe answer is 42\n".iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().()));
17 }
18
19 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
20 fn write_overflowrust-analyzer cargo ringbuf 0.3.3 tests/fmt_write/write_overflow().() {
21 let mut buf = StaticRbrust-analyzer cargo ringbuf 0.3.3 alias/StaticRb#::<u8, 10>::defaultrust-analyzer cargo ringbuf 0.3.3 ring_buffer/init/impl#[`SharedRb<T, [MaybeUninit<T>; N]>`][Default]default().();
22
23 let (mut prod, mut cons) = buf.split_refrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`]split_ref().();
24
25 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
26 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(
27 prod,
28 "This is a very long string that will overflow the small buffer\n"
29 ),
30 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Error#::defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[Error][Default]default().())
31 );
32
33 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons.lenrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]len().(), 10);
34 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cons.pop_iterrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]pop_iter().().eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#eq().(b"This is a ".iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().()));
35
36 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
37 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(
38 prod,
39 "{} {} {} {} {}\n",
40 "This", "string", "will", "also", "overflow"
41 ),
42 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Error#::defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[Error][Default]default().())
43 );
44
45 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons.lenrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]len().(), 10);
46 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cons.pop_iterrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]pop_iter().().eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#eq().(b"This strin".iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().()));
47 }