Skip to content

Commit

Permalink
Don't run quick tests under miri
Browse files Browse the repository at this point in the history
  • Loading branch information
fbernier committed Nov 7, 2024
1 parent 665bcec commit f79fa49
Showing 1 changed file with 27 additions and 22 deletions.
49 changes: 27 additions & 22 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -803,36 +803,41 @@ pub fn encode_alternative_buf<T: Into<u128>>(num: T, buf: &mut String) {
mod tests {
use super::*;
use alloc::vec::Vec;
use quickcheck::{quickcheck, TestResult};

quickcheck! {
fn encode_decode(num: u128) -> bool {
decode(encode(num)) == Ok(num)
// Don't run quickcheck tests under miri because that's infinitely slow
#[cfg(not(miri))]
mod quickcheck_tests {
use super::*;
use quickcheck::{quickcheck, TestResult};
quickcheck! {
fn encode_decode(num: u128) -> bool {
decode(encode(num)) == Ok(num)
}
}
}

quickcheck! {
fn encode_decode_alternative(num: u128) -> bool {
decode_alternative(encode_alternative(num)) == Ok(num)
quickcheck! {
fn encode_decode_alternative(num: u128) -> bool {
decode_alternative(encode_alternative(num)) == Ok(num)
}
}
}

quickcheck! {
fn decode_bad(input: Vec<u8>) -> TestResult {
if !input.is_empty() && input.iter().all(|ch| ch.is_ascii_alphanumeric()) {
TestResult::discard()
} else {
TestResult::from_bool(decode(&input).is_err())
quickcheck! {
fn decode_bad(input: Vec<u8>) -> TestResult {
if !input.is_empty() && input.iter().all(|ch| ch.is_ascii_alphanumeric()) {
TestResult::discard()
} else {
TestResult::from_bool(decode(&input).is_err())
}
}
}
}

quickcheck! {
fn decode_good(input: Vec<u8>) -> TestResult {
if !input.is_empty() && input.iter().all(|ch| ch.is_ascii_alphanumeric()) {
TestResult::from_bool(decode(&input).is_ok())
} else {
TestResult::discard()
quickcheck! {
fn decode_good(input: Vec<u8>) -> TestResult {
if !input.is_empty() && input.iter().all(|ch| ch.is_ascii_alphanumeric()) {
TestResult::from_bool(decode(&input).is_ok())
} else {
TestResult::discard()
}
}
}
}
Expand Down

0 comments on commit f79fa49

Please sign in to comment.