Skip to content

Commit

Permalink
relax uid restriction in fuzzer after #32
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf committed Mar 27, 2024
1 parent 99b8505 commit 42a0933
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions fuzz/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,16 @@ impl Arbitrary<'_> for Timestamp {
}
}

#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[derive(Copy, Clone, Debug, Eq, Arbitrary)]
struct Uid(u32);

impl Arbitrary<'_> for Uid {
fn arbitrary(u: &mut Unstructured<'_>) -> arbitrary::Result<Self> {
u.int_in_range(0..=999_999).map(Uid) // TODO: Deal with entire range (#29)
impl PartialEq for Uid {
fn eq(&self, other: &Uid) -> bool {
truncated_ascii(self.0.to_string(), 6) == truncated_ascii(other.0.to_string(), 6)
}
}

fn truncated_ascii(mut ascii: String, width: usize) -> String {
ascii.truncate(width);
ascii
}

0 comments on commit 42a0933

Please sign in to comment.