File tree 4 files changed +72
-1
lines changed
4 files changed +72
-1
lines changed Original file line number Diff line number Diff line change 1
1
[workspace ]
2
- members = [" rustest" , " rustest-macro" ]
2
+ members = [" rustest" , " rustest-macro" , " rustest-testing " ]
3
3
resolver = " 2"
4
4
5
5
[workspace .package ]
Original file line number Diff line number Diff line change
1
+ [package ]
2
+ name = " rustest-testing"
3
+ edition.workspace = true
4
+ version.workspace = true
5
+ authors.workspace = true
6
+ repository.workspace = true
7
+ homepage.workspace = true
8
+ license.workspace = true
9
+ description.workspace = true
10
+ keywords.workspace = true
11
+ categories.workspace = true
12
+
13
+ [dependencies ]
14
+
15
+ [dev-dependencies ]
16
+ rustest = { path = " ../rustest" }
17
+
18
+
19
+ [lib ]
20
+ harness = false
Original file line number Diff line number Diff line change
1
+ mod other_mod;
2
+
3
+ pub use other_mod:: * ;
4
+
5
+ pub fn add ( left : u64 , right : u64 ) -> u64 {
6
+ left + right
7
+ }
8
+
9
+ #[ cfg( test) ]
10
+ mod tests {
11
+ use super :: * ;
12
+ use rustest:: test;
13
+
14
+ #[ test]
15
+ fn it_works ( ) {
16
+ let result = add ( 2 , 2 ) ;
17
+ assert ! ( result == 4 ) ;
18
+ }
19
+ }
20
+
21
+ #[ cfg( test) ]
22
+ #[ rustest:: main]
23
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ pub fn addition ( a : u32 , b : u32 ) -> u32 {
2
+ a + b
3
+ }
4
+
5
+ #[ cfg( test) ]
6
+ pub ( crate ) mod tests {
7
+ use super :: * ;
8
+ use rustest:: test;
9
+
10
+ #[ test( params: ( u32 , u32 , u32 ) =[
11
+ ( 1 , 2 , 3 ) ,
12
+ ( 5 , 6 , 11 ) ,
13
+ ( 598318 , 54876521 , 55474839 )
14
+ ] ) ]
15
+ fn test_addition_ok ( Param ( ( a, b, expected) ) : Param ) {
16
+ assert_eq ! ( addition( a, b) , expected) ;
17
+ }
18
+
19
+ #[ test( params: ( u32 , u32 , u32 ) =[
20
+ ( 1 , 2 , 4 ) ,
21
+ ( 5 , 6 , 5555 ) ,
22
+ ( 598318 , 54876521 , 0 )
23
+ ] ) ]
24
+ #[ xfail]
25
+ fn test_addition_fail ( Param ( ( a, b, expected) ) : Param ) {
26
+ assert_eq ! ( addition( a, b) , expected) ;
27
+ }
28
+ }
You can’t perform that action at this time.
0 commit comments