Skip to content

Commit ca2045c

Browse files
committed
tests: Fix invalid custom test
In the custom tests, only the first test case is ever checked, if the value is above zero. Fix this by inverting the conditions and letting the function return Ok later. Returning Ok was already present in the function. Signed-off-by: Esa Laakso <[email protected]>
1 parent fc5ae84 commit ca2045c

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

serde_valid/src/validation/custom.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,13 @@ mod test {
5555
fn test_custom_fn_multiple_errors() {
5656
fn multiple_errors(data: &i32) -> Result<(), Vec<crate::validation::Error>> {
5757
let mut errors = Vec::new();
58-
if *data > 0 {
59-
return Ok(());
60-
} else {
58+
if *data < 1 {
6159
errors.push(crate::validation::Error::Custom(
6260
"Value must be greater than 0".to_string(),
6361
));
6462
}
6563

66-
if *data < 10 {
67-
return Ok(());
68-
} else {
64+
if *data >= 10 {
6965
errors.push(crate::validation::Error::Custom(
7066
"Value must be less than 10".to_string(),
7167
));

0 commit comments

Comments
 (0)