aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests/json/json_validation_exception_test.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-21 00:51:40 +0900
committernsfisis <nsfisis@gmail.com>2026-06-21 00:51:40 +0900
commit53f027302ebcb91f6fb9b177f5e7e9e2d00c5089 (patch)
tree8e5253105ca5abea99208cc47caae3fb118f734a /crates/shirabe/tests/json/json_validation_exception_test.rs
parent7bea9042a79d3cbfe31cc2595e8b8c6a3788ba15 (diff)
downloadphp-shirabe-53f027302ebcb91f6fb9b177f5e7e9e2d00c5089.tar.gz
php-shirabe-53f027302ebcb91f6fb9b177f5e7e9e2d00c5089.tar.zst
php-shirabe-53f027302ebcb91f6fb9b177f5e7e9e2d00c5089.zip
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) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests/json/json_validation_exception_test.rs')
-rw-r--r--crates/shirabe/tests/json/json_validation_exception_test.rs24
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()]),
+ ]
+}