martin-g commented on code in PR #2352:
URL: https://github.com/apache/avro/pull/2352#discussion_r1264735881


##########
lang/rust/avro/tests/schema.rs:
##########
@@ -682,6 +684,61 @@ fn test_parse() -> TestResult {
     Ok(())
 }
 
+#[test]
+fn test_parse_reader() -> TestResult {

Review Comment:
   ```suggestion
   fn avro_3799_test_parse_reader() -> TestResult {
   ```



##########
lang/rust/avro/tests/schema.rs:
##########
@@ -682,6 +684,61 @@ fn test_parse() -> TestResult {
     Ok(())
 }
 
+#[test]
+fn test_parse_reader() -> TestResult {
+    init();
+    for (raw_schema, valid) in EXAMPLES.iter() {
+        let schema = Schema::parse_reader(&mut Cursor::new(raw_schema));
+        if *valid {
+            assert!(
+                schema.is_ok(),
+                "schema {raw_schema} was supposed to be valid; error: 
{schema:?}",
+            )
+        } else {
+            assert!(
+                schema.is_err(),
+                "schema {raw_schema} was supposed to be invalid"
+            )
+        }
+    }
+
+    // Ensure it works for trait objects too.
+    for (raw_schema, valid) in EXAMPLES.iter() {
+        let reader: &mut dyn Read = &mut Cursor::new(raw_schema);
+        let schema = Schema::parse_reader(reader);
+        if *valid {
+            assert!(
+                schema.is_ok(),
+                "schema {raw_schema} was supposed to be valid; error: 
{schema:?}",
+            )
+        } else {
+            assert!(
+                schema.is_err(),
+                "schema {raw_schema} was supposed to be invalid"
+            )
+        }
+    }
+    Ok(())
+}
+
+#[test]
+fn test_raise_io_error_from_parse_read() -> Result<(), String> {

Review Comment:
   ```suggestion
   fn avro_3799_test_raise_io_error_from_parse_read() -> Result<(), String> {
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to