#[cfg(test)]
pub(crate) mod corpus {
pub(crate) const SHAPES: [&str; 12] = [
"* caveman",
"*.md ascii+caveman",
"# a comment",
"",
" ",
"SPEC.md ascii+caveman+box",
"docs/** marks @emoji",
"src/**/*.rs ascii !deny",
"vendor/** any !allow !pedantic=allow",
" *.po pl+typography ",
"locales/** ascii+latin-ext @text",
"Makefile\tascii+cr",
];
pub(crate) struct Noise(pub(crate) u64);
impl Noise {
pub(crate) fn next(&mut self) -> usize {
let stepped = self.0.wrapping_mul(6364136223846793005);
self.0 = stepped.wrapping_add(1442695040888963407);
usize::try_from(self.0 >> 33).unwrap_or(0)
}
fn pick<'a>(&mut self, shapes: &[&'a str]) -> &'a str {
let index = self.next().checked_rem(shapes.len()).unwrap_or(0);
shapes.get(index).copied().unwrap_or_default()
}
}
pub(crate) fn file(
noise: &mut Noise,
shapes: &[&str],
count: usize,
) -> String {
let mut text = String::new();
for _ in 0..count {
text.push_str(noise.pick(shapes));
text.push('\n');
}
text
}
}
#[cfg(test)]
#[path = "property_test.rs"]
mod tests;