Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/ub-detection.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ jobs:
- run: |
rustup +nightly component add miri
cargo +nightly miri setup
MIRIFLAGS="-Zmiri-strict-provenance" cargo +nightly miri test --lib
PROPTEST_DISABLE_FAILURE_PERSISTENCE=true \
MIRIFLAGS="-Zmiri-env-forward=PROPTEST_DISABLE_FAILURE_PERSISTENCE -Zmiri-strict-provenance" \
cargo +nightly miri test --lib
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ license = "Apache-2.0" # TODO(template) update license if needed
publish = false

[workspace.dependencies]
proptest = "1"

[workspace.lints.rust]
missing_docs = "deny"
Expand Down
3 changes: 3 additions & 0 deletions template_crate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ license.workspace = true
# code break after upgrades
thiserror = { version = "1.0", default-features = false }

[dev-dependencies]
proptest = { workspace = true }

# TODO(template)
# don't forget to put this at every crate
# to inherit workspace's lints
Expand Down
11 changes: 11 additions & 0 deletions template_crate/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pub fn sub_small_integers(a: u8, b: u8) -> Result<u8, ParameterError> {
#[cfg(test)]
mod tests {
use super::*;
use proptest::proptest;

#[test]
fn addition_of_bounded() {
Expand All @@ -67,4 +68,14 @@ mod tests {
add_small_integers(UPPER_BOUND - 1, UPPER_BOUND - 1)
);
}

proptest! {
#[test]
fn addition_proptest(a in 0_u8..20, b in 0_u8..20) {
assert_eq!(
a.checked_add(b),
add_small_integers(a, b).ok()
);
}
}
}