Start on a simple randomized test for FragmentList

This commit is contained in:
Antonio Scandurra 2021-12-06 16:08:17 +01:00
parent 8354d1520d
commit e37908cf3b
5 changed files with 99 additions and 6 deletions

View file

@ -12,6 +12,14 @@ impl<T: Rng> Iterator for RandomCharIter<T> {
type Item = char;
fn next(&mut self) -> Option<Self::Item> {
if std::env::var("SIMPLE_TEXT").map_or(false, |v| !v.is_empty()) {
return if self.0.gen_range(0..100) < 5 {
Some('\n')
} else {
Some(self.0.gen_range(b'a'..b'z' + 1).into())
};
}
match self.0.gen_range(0..100) {
// whitespace
0..=19 => [' ', '\n', '\t'].choose(&mut self.0).copied(),