Debian Codegraph @

tests/check.rs

raw symbols SCIP
1 extern crate bytecountrust-analyzer cargo bytecount 0.6.9 bytecount/;
2 #[macro_use]
3 extern crate quickcheckrust-analyzer cargo bytecount 0.6.9 quickcheck/;
4 extern crate randrust-analyzer cargo bytecount 0.6.9 rand/;
5
6 use bytecountrust-analyzer cargo bytecount 0.6.9 crate/::{countrust-analyzer cargo bytecount 0.6.9 count()., naive_countrust-analyzer cargo bytecount 0.6.9 naive/naive_count()., naive_num_charsrust-analyzer cargo bytecount 0.6.9 naive/naive_num_chars()., num_charsrust-analyzer cargo bytecount 0.6.9 num_chars().};
7 use randrust-analyzer cargo rand 0.8.5 crate/::RngCorerust-analyzer cargo rand_core 0.6.4 RngCore#;
8
9 fn random_bytesrust-analyzer cargo bytecount 0.6.9 random_bytes().(len: usize) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> {
10 let mut result = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0; len];
11 randrust-analyzer cargo rand 0.8.5 crate/::thread_rngrust-analyzer cargo rand 0.8.5 rngs/thread/thread_rng().().fill_bytesrust-analyzer cargo rand 0.8.5 rngs/thread/impl#[ThreadRng][RngCore]fill_bytes().(&mut result);
12 result
13 }
14
15 quickcheckrust-analyzer cargo quickcheck 1.0.3 quickcheck!! {
16 fn check_count_correctrust-analyzer cargo bytecount 0.6.9 check_count_correct().(x: (Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>, u8)) -> bool {
17 let (haystack, needle) = x;
18 countrust-analyzer cargo bytecount 0.6.9 count().(&haystack, needle) == naive_countrust-analyzer cargo bytecount 0.6.9 naive/naive_count().(&haystack, needle)
19 }
20 }
21
22 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
23 fn check_count_largerust-analyzer cargo bytecount 0.6.9 check_count_large().() {
24 let haystack = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0u8; if cfgrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/cfg!!(miri) { 2_000 } else { 10_000_000 }];
25 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(naive_countrust-analyzer cargo bytecount 0.6.9 naive/naive_count().(&haystack, 0), countrust-analyzer cargo bytecount 0.6.9 count().(&haystack, 0));
26 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(naive_countrust-analyzer cargo bytecount 0.6.9 naive/naive_count().(&haystack, 1), countrust-analyzer cargo bytecount 0.6.9 count().(&haystack, 1));
27 }
28
29 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
30 fn check_count_large_randrust-analyzer cargo bytecount 0.6.9 check_count_large_rand().() {
31 let haystack = random_bytesrust-analyzer cargo bytecount 0.6.9 random_bytes().(if cfgrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/cfg!!(miri) { 200 } else { 100_000 });
32 for i in 0..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#255 {
33 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(naive_countrust-analyzer cargo bytecount 0.6.9 naive/naive_count().(&haystack, i), countrust-analyzer cargo bytecount 0.6.9 count().(&haystack, i));
34 }
35 }
36
37 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
38 fn check_count_somerust-analyzer cargo bytecount 0.6.9 check_count_some().() {
39 let haystack = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 68];
40 let needle = 68;
41 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(countrust-analyzer cargo bytecount 0.6.9 count().(&haystack, needle), naive_countrust-analyzer cargo bytecount 0.6.9 naive/naive_count().(&haystack, needle));
42 }
43
44 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
45 fn check_count_overflowrust-analyzer cargo bytecount 0.6.9 check_count_overflow().() {
46 let haystack = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
47 let needle = 2;
48 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(countrust-analyzer cargo bytecount 0.6.9 count().(&haystack, needle), naive_countrust-analyzer cargo bytecount 0.6.9 naive/naive_count().(&haystack, needle));
49 }
50
51 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
52 fn check_count_overflow_manyrust-analyzer cargo bytecount 0.6.9 check_count_overflow_many().() {
53 let string = [b'x'; 20000];
54 for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#20000 {
55 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(countrust-analyzer cargo bytecount 0.6.9 count().(&string[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()., b'x'), i);
56 }
57 }
58
59 quickcheckrust-analyzer cargo quickcheck 1.0.3 quickcheck!! {
60 fn check_num_chars_correctrust-analyzer cargo bytecount 0.6.9 check_num_chars_correct().(haystack: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>) -> bool {
61 num_charsrust-analyzer cargo bytecount 0.6.9 num_chars().(&haystack) == naive_num_charsrust-analyzer cargo bytecount 0.6.9 naive/naive_num_chars().(&haystack)
62 }
63 }
64
65 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
66 fn check_num_chars_largerust-analyzer cargo bytecount 0.6.9 check_num_chars_large().() {
67 let haystack = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0u8; if cfgrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/cfg!!(miri) { 2_000 } else { 10_000_000 }];
68 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(naive_num_charsrust-analyzer cargo bytecount 0.6.9 naive/naive_num_chars().(&haystack), num_charsrust-analyzer cargo bytecount 0.6.9 num_chars().(&haystack));
69 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(naive_num_charsrust-analyzer cargo bytecount 0.6.9 naive/naive_num_chars().(&haystack), num_charsrust-analyzer cargo bytecount 0.6.9 num_chars().(&haystack));
70 }
71
72 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
73 fn check_num_chars_somerust-analyzer cargo bytecount 0.6.9 check_num_chars_some().() {
74 let haystack = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 68];
75 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(num_charsrust-analyzer cargo bytecount 0.6.9 num_chars().(&haystack), naive_num_charsrust-analyzer cargo bytecount 0.6.9 naive/naive_num_chars().(&haystack));
76 }
77
78 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
79 fn check_num_chars_overflowrust-analyzer cargo bytecount 0.6.9 check_num_chars_overflow().() {
80 let haystack = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
81 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(num_charsrust-analyzer cargo bytecount 0.6.9 num_chars().(&haystack), naive_num_charsrust-analyzer cargo bytecount 0.6.9 naive/naive_num_chars().(&haystack));
82 }
83
84 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
85 fn check_num_chars_overflow_manyrust-analyzer cargo bytecount 0.6.9 check_num_chars_overflow_many().() {
86 let string = [b'x'; 20000];
87 for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#20000 {
88 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(num_charsrust-analyzer cargo bytecount 0.6.9 num_chars().(&string[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().), i);
89 }
90 }