From f79fa49e5215c0bd588fb8c1ad8bda13da14d80e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Bernier?= Date: Thu, 7 Nov 2024 00:32:38 -0500 Subject: [PATCH] Don't run quick tests under miri --- src/lib.rs | 49 +++++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 886c037..03c7d48 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -803,36 +803,41 @@ pub fn encode_alternative_buf>(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) -> 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) -> 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) -> 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) -> TestResult { + if !input.is_empty() && input.iter().all(|ch| ch.is_ascii_alphanumeric()) { + TestResult::from_bool(decode(&input).is_ok()) + } else { + TestResult::discard() + } } } }