Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Test round up #335

Merged
merged 3 commits into from
Jul 27, 2022
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

## [Unreleased]

- [#335] Add unit tests for `fn round_up`
- [#334] Simplify snapshot tests
- [#333] Clean up `enum Outcome`
- [#331] Refactor stack painting
Expand All @@ -20,6 +21,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- [#314] Clarify documentation in README
- [#293] Update snapshot tests to new TRACE output

[#335]: https://github.com/knurling-rs/probe-run/pull/335
[#334]: https://github.com/knurling-rs/probe-run/pull/334
[#333]: https://github.com/knurling-rs/probe-run/pull/333
[#331]: https://github.com/knurling-rs/probe-run/pull/331
Expand Down
19 changes: 19 additions & 0 deletions src/canary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,3 +297,22 @@ fn prepare_subroutine<const N: usize>(

Ok(previous_pc)
}

#[cfg(test)]
mod tests {
use super::*;

use rstest::rstest;

#[rstest]
#[case(2, 4, 4)]
#[case(4, 4, 4)]
#[case(6, 4, 8)]
#[case(8, 4, 8)]
#[case::odd(5, 3, 6)]
#[should_panic]
#[case::div_zero(4, 0, 0)]
fn test_round_up(#[case] n: u32, #[case] k: u32, #[case] res: u32) {
assert_eq!(round_up(n, k), res);
}
}