From 53f027302ebcb91f6fb9b177f5e7e9e2d00c5089 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 21 Jun 2026 00:51:40 +0900 Subject: test: port BufferIO, Runtime, JsonValidationException tests JsonValidationExceptionTest passes. BufferIOTest (set_user_inputs is todo!()) and RuntimeTest (html_entity_decode is todo!()) are marked #[ignore]. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../tests/json/json_validation_exception_test.rs | 24 ++++++++++++++++++++++ crates/shirabe/tests/json/main.rs | 1 + 2 files changed, 25 insertions(+) create mode 100644 crates/shirabe/tests/json/main.rs (limited to 'crates/shirabe/tests/json') 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::::new(), object.get_errors()); +} + +fn error_provider() -> Vec<(&'static str, Vec, &'static str, Vec)> { + vec![ + ("test message", vec![], "test message", vec![]), + ("", vec!["foo".to_string()], "", vec!["foo".to_string()]), + ] +} diff --git a/crates/shirabe/tests/json/main.rs b/crates/shirabe/tests/json/main.rs new file mode 100644 index 0000000..a98ebc5 --- /dev/null +++ b/crates/shirabe/tests/json/main.rs @@ -0,0 +1 @@ +mod json_validation_exception_test; -- cgit v1.3.1