Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
greyblake committed Feb 25, 2024
1 parent 56f6f34 commit 1eed81d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
10 changes: 8 additions & 2 deletions test_suite/tests/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,10 @@ mod traits {

{
let err = "5,5".parse::<Position>().unwrap_err();
assert_eq!(err.to_string(), "Failed to parse Position: invalid");
assert_eq!(
err.to_string(),
"Failed to parse Position: Position failed the predicate test."
);
}
}
}
Expand Down Expand Up @@ -284,7 +287,10 @@ mod traits {

{
let err = serde_json::from_str::<LinePoint>("{\"x\":7,\"y\":9}").unwrap_err();
assert_eq!(err.to_string(), "invalid, expected valid LinePoint");
assert_eq!(
err.to_string(),
"LinePoint failed the predicate test. Expected valid LinePoint"
);
}

{
Expand Down
10 changes: 8 additions & 2 deletions test_suite/tests/float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,10 @@ mod validators {

let err = Percentage::try_from(-0.1).unwrap_err();

assert_eq!(err.to_string(), "too small");
assert_eq!(
err.to_string(),
"Percentage is too small. The value must be greater or equal to 0.0."
);
}
}
}
Expand Down Expand Up @@ -457,7 +460,10 @@ mod traits {

// Unhappy path: validation error
let err: DistParseError = "12.35".parse::<Dist>().unwrap_err();
assert_eq!(err.to_string(), "Failed to parse Dist: too big");
assert_eq!(
err.to_string(),
"Failed to parse Dist: Dist is too big. The value must be less than 12.34."
);
}

#[test]
Expand Down
10 changes: 8 additions & 2 deletions test_suite/tests/integer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@ mod validators {

let err = Age::try_from(17).unwrap_err();

assert_eq!(err.to_string(), "too small");
assert_eq!(
err.to_string(),
"Age is too small. The value must be greater or equal to 18."
);
}
}
}
Expand Down Expand Up @@ -608,7 +611,10 @@ mod traits {

// Unhappy path: validation error
let err: AgeParseError = "101".parse::<Age>().unwrap_err();
assert_eq!(err.to_string(), "Failed to parse Age: too big");
assert_eq!(
err.to_string(),
"Failed to parse Age: Age is too big. The value must be less or equal to 99."
);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion test_suite/tests/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ mod validators {
#[nutype(validate(not_empty))]
pub struct Email(String);

assert_eq!(EmailError::NotEmptyViolated.to_string(), "empty");
assert_eq!(EmailError::NotEmptyViolated.to_string(), "Email is empty.");
}

mod when_boundaries_defined_as_constants {
Expand Down

0 comments on commit 1eed81d

Please sign in to comment.