You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@avro.apache.org by "xxchan (via GitHub)" <gi...@apache.org> on 2024/08/07 14:55:08 UTC
Re: [PR] AVRO-4024: [Rust] Sync the possible String default values for floating numbers with Java and C# [avro]
xxchan commented on code in PR #3073:
URL: https://github.com/apache/avro/pull/3073#discussion_r1707185875
##########
lang/rust/avro/src/types.rs:
##########
@@ -3138,4 +3138,40 @@ Field with name '"b"' is not a member of the map items"#,
)
);
}
+
+ #[test]
+ fn avro_4024_resolve_double_from_unknown_string_err() -> TestResult {
+ let schema = Schema::parse_str(r#"{"type": "double"}"#)?;
+ let value = Value::String("unknown".to_owned());
+ match value.resolve(&schema) {
+ Err(err @ Error::GetDouble(_)) => {
+ assert_eq!(
+ format!("{err:?}"),
+ r#"Double expected, got String("unknown")"#
+ );
+ }
+ other => {
+ panic!("Expected Error::GetDouble, got {other:?}");
+ }
+ }
Review Comment:
Just FYI: there's a tool that can make testing a lot more happier https://github.com/rust-analyzer/expect-test
Basically it's just like
```rust
assert_eq!(format!("{:?}", value.resolve(&schema)), "balabala")
```
We don't manually `match`, but just print out the result.
What's cooler is that `expect_test` can automatically update the actual result for you.
--
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: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org