diff options
Diffstat (limited to 'crates/shirabe/tests/json/json_validation_exception_test.rs')
| -rw-r--r-- | crates/shirabe/tests/json/json_validation_exception_test.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/crates/shirabe/tests/json/json_validation_exception_test.rs b/crates/shirabe/tests/json/json_validation_exception_test.rs index 12620ba..271ca9b 100644 --- a/crates/shirabe/tests/json/json_validation_exception_test.rs +++ b/crates/shirabe/tests/json/json_validation_exception_test.rs @@ -1 +1,25 @@ //! ref: composer/tests/Composer/Test/Json/JsonValidationExceptionTest.php + +use shirabe::json::json_validation_exception::JsonValidationException; + +#[test] +fn test_get_errors() { + for (message, errors, expected_message, expected_errors) in error_provider() { + let object = JsonValidationException::new(message.to_string(), errors.clone()); + assert_eq!(expected_message, object.get_message()); + assert_eq!(&expected_errors, object.get_errors()); + } +} + +#[test] +fn test_get_errors_when_no_errors_provided() { + let object = JsonValidationException::new("test message".to_string(), vec![]); + assert_eq!(&Vec::<String>::new(), object.get_errors()); +} + +fn error_provider() -> Vec<(&'static str, Vec<String>, &'static str, Vec<String>)> { + vec![ + ("test message", vec![], "test message", vec![]), + ("", vec!["foo".to_string()], "", vec!["foo".to_string()]), + ] +} |
