@@ -933,10 +933,10 @@ impl Value {
933933 /// IEEE 754 NaN and infinities are not valid JSON numbers.
934934 /// So they are represented in JSON as strings.
935935 fn parse_special_float ( value : & str ) -> Option < f32 > {
936- match value. trim ( ) . to_ascii_lowercase ( ) . as_str ( ) {
937- "nan" | "+nan" | "-nan " => Some ( f32:: NAN ) ,
938- "inf " | "+inf" | "infinity" | "+infinity " => Some ( f32:: INFINITY ) ,
939- "-inf " | "-infinity " => Some ( f32:: NEG_INFINITY ) ,
936+ match value {
937+ "NaN " => Some ( f32:: NAN ) ,
938+ "INF " | "Infinity " => Some ( f32:: INFINITY ) ,
939+ "-INF " | "-Infinity " => Some ( f32:: NEG_INFINITY ) ,
940940 _ => None ,
941941 }
942942 }
@@ -3142,10 +3142,13 @@ Field with name '"b"' is not a member of the map items"#,
31423142 #[ test]
31433143 fn avro_4024_resolve_double_from_unknown_string_err ( ) -> TestResult {
31443144 let schema = Schema :: parse_str ( r#"{"type": "double"}"# ) ?;
3145- let value = Value :: String ( "blah " . to_owned ( ) ) ;
3145+ let value = Value :: String ( "unknown " . to_owned ( ) ) ;
31463146 match value. resolve ( & schema) {
31473147 Err ( err @ Error :: GetDouble ( _) ) => {
3148- assert_eq ! ( format!( "{err:?}" ) , r#"Double expected, got String("blah")"# ) ;
3148+ assert_eq ! (
3149+ format!( "{err:?}" ) ,
3150+ r#"Double expected, got String("unknown")"#
3151+ ) ;
31493152 }
31503153 other => {
31513154 panic ! ( "Expected Error::GetDouble, got {other:?}" ) ;
@@ -3157,10 +3160,13 @@ Field with name '"b"' is not a member of the map items"#,
31573160 #[ test]
31583161 fn avro_4024_resolve_float_from_unknown_string_err ( ) -> TestResult {
31593162 let schema = Schema :: parse_str ( r#"{"type": "float"}"# ) ?;
3160- let value = Value :: String ( "blah " . to_owned ( ) ) ;
3163+ let value = Value :: String ( "unknown " . to_owned ( ) ) ;
31613164 match value. resolve ( & schema) {
31623165 Err ( err @ Error :: GetFloat ( _) ) => {
3163- assert_eq ! ( format!( "{err:?}" ) , r#"Float expected, got String("blah")"# ) ;
3166+ assert_eq ! (
3167+ format!( "{err:?}" ) ,
3168+ r#"Float expected, got String("unknown")"#
3169+ ) ;
31643170 }
31653171 other => {
31663172 panic ! ( "Expected Error::GetFloat, got {other:?}" ) ;
0 commit comments