Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them.
Page: /drakestapleton/aienux/blob/main/vendor/memchr/src/tests/packedpair.rs
# aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
Sign in to star 0 stars 0 watching
About Files History Releases Proposed changes Issues For developers
branch `main` Branches Tags History
`aienux / vendor / memchr / src / tests / packedpair.rs`
216 lines ยท 8074 bytes Raw Blame History
1 use alloc::{boxed::Box, vec, vec::Vec};
2
3 /// A set of "packed pair" test seeds. Each seed serves as the base for the
4 /// generation of many other tests. In essence, the seed captures the pair of
5 /// bytes we used for a predicate and first byte among our needle. The tests
6 /// generated from each seed essentially vary the length of the needle and
7 /// haystack, while using the rare/first byte configuration from the seed.
8 ///
9 /// The purpose of this is to test many different needle/haystack lengths.
10 /// In particular, some of the vector optimizations might only have bugs
11 /// in haystacks of a certain size.
12 const SEEDS: &[Seed] = &[
13 // Why not use different 'first' bytes? It seemed like a good idea to be
14 // able to configure it, but when I wrote the test generator below, it
15 // didn't seem necessary to use for reasons that I forget.
16 Seed { first: b'x', index1: b'y', index2: b'z' },
17 Seed { first: b'x', index1: b'x', index2: b'z' },
18 Seed { first: b'x', index1: b'y', index2: b'x' },
19 Seed { first: b'x', index1: b'x', index2: b'x' },
20 Seed { first: b'x', index1: b'y', index2: b'y' },
21 ];
22
23 /// Runs a host of "packed pair" search tests.
24 ///
25 /// These tests specifically look for the occurrence of a possible substring
26 /// match based on a pair of bytes matching at the right offsets.
27 pub(crate) struct Runner {
28 fwd: Option<
29 Box<
30 dyn FnMut(&[u8], &[u8], u8, u8) -> Option