Skip to content

Commit fc5ae84

Browse files
committed
tests: Add negative case for custom validation
In order to cover more cases with the custom validation, add tests to check for the values out of valid bounds. Signed-off-by: Esa Laakso <[email protected]>
1 parent 204e76f commit fc5ae84

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

serde_valid/src/validation/custom.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ mod test {
4747
}
4848

4949
assert!(wrap_closure_validation(&1i32, single_error).is_ok());
50+
assert!(wrap_closure_validation(&0i32, single_error).is_err());
51+
assert!(wrap_closure_validation(&-1i32, single_error).is_err());
5052
}
5153

5254
#[test]
@@ -77,5 +79,9 @@ mod test {
7779
}
7880

7981
assert!(wrap_closure_validation(&1i32, multiple_errors).is_ok());
82+
assert!(wrap_closure_validation(&10i32, multiple_errors).is_err());
83+
assert!(wrap_closure_validation(&11i32, multiple_errors).is_err());
84+
assert!(wrap_closure_validation(&0i32, multiple_errors).is_err());
85+
assert!(wrap_closure_validation(&-1i32, multiple_errors).is_err());
8086
}
8187
}

0 commit comments

Comments
 (0)