diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
commit | 698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch) | |
tree | 173a775858bd501c378080a10dca74132f05bc50 /vendor/cov-mark/tests | |
parent | Initial commit. (diff) | |
download | rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip |
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/cov-mark/tests')
-rw-r--r-- | vendor/cov-mark/tests/smoke.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/vendor/cov-mark/tests/smoke.rs b/vendor/cov-mark/tests/smoke.rs new file mode 100644 index 000000000..102636a0d --- /dev/null +++ b/vendor/cov-mark/tests/smoke.rs @@ -0,0 +1,27 @@ +fn safe_divide(dividend: u32, divisor: u32) -> u32 { + if divisor == 0 { + cov_mark::hit!(save_divide_zero); + return 0; + } + dividend / divisor +} + +#[test] +fn test_safe_divide_by_zero() { + cov_mark::check!(save_divide_zero); + assert_eq!(safe_divide(92, 0), 0); +} + +struct CoveredDropper; +impl Drop for CoveredDropper { + fn drop(&mut self) { + cov_mark::hit!(covered_dropper_drops); + } +} + +#[test] +fn test_drop_count() { + cov_mark::check_count!(covered_dropper_drops, 2); + let _covered_dropper1 = CoveredDropper; + let _covered_dropper2 = CoveredDropper; +} |