Skip to content

Commit e45a5d1

Browse files
committed
init simple proptest
1 parent a50bc83 commit e45a5d1

File tree

5 files changed

+149
-3
lines changed

5 files changed

+149
-3
lines changed

Cargo.lock

Lines changed: 128 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pulsebeam-simulator/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ authors.workspace = true
1010
license.workspace = true
1111

1212
[dependencies]
13+
proptest = "1.9.0"
14+
test-strategy = "0.4.3"

pulsebeam-simulator/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pub fn add(a: u32, b: u32) -> u32 {
2+
a + b
3+
}

pulsebeam-simulator/src/main.rs

Lines changed: 0 additions & 3 deletions
This file was deleted.

pulsebeam-simulator/tests/mod.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
use pulsebeam_simulator::add;
2+
use test_strategy::{Arbitrary, proptest};
3+
4+
#[derive(Arbitrary, Debug)]
5+
struct TestInputStruct {
6+
#[strategy(1..10u32)]
7+
a: u32,
8+
9+
#[strategy(0..#a)]
10+
b: u32,
11+
}
12+
13+
#[proptest]
14+
fn my_test(input: TestInputStruct) {
15+
assert_eq!(add(input.a, input.b), input.a + input.b);
16+
}

0 commit comments

Comments
 (0)