@@ -42,14 +42,14 @@ mod tests {
4242 #[ test_case( MessageWithComplexOneOf :: new( ) . set_double_value( 1.5 ) , json!( { "doubleValue" : 1.5 } ) ) ]
4343 #[ test_case( MessageWithComplexOneOf :: new( ) . set_double_value( 2.5 ) , json!( { "doubleValue" : 2.5 } ) ) ]
4444 #[ test_case( MessageWithComplexOneOf :: new( ) . set_double_value( 3.0 ) , json!( { "doubleValue" : 3.0 } ) ) ]
45- #[ test_case( MessageWithComplexOneOf :: new( ) . set_int ( 0 ) , json!( { "int " : 0 } ) ) ]
46- #[ test_case( MessageWithComplexOneOf :: new( ) . set_int ( 1 ) , json!( { "int " : 1 } ) ) ]
47- #[ test_case( MessageWithComplexOneOf :: new( ) . set_int ( 2 ) , json!( { "int " : 2 } ) ) ]
48- #[ test_case( MessageWithComplexOneOf :: new( ) . set_int ( 3 ) , json!( { "int " : 3 } ) ) ]
49- #[ test_case( MessageWithComplexOneOf :: new( ) . set_long ( 0 ) , json!( { "long " : "0" } ) ) ]
50- #[ test_case( MessageWithComplexOneOf :: new( ) . set_long ( 1 ) , json!( { "long " : "1" } ) ) ]
51- #[ test_case( MessageWithComplexOneOf :: new( ) . set_long ( 2 ) , json!( { "long " : "2" } ) ) ]
52- #[ test_case( MessageWithComplexOneOf :: new( ) . set_long ( 3 ) , json!( { "long " : "3" } ) ) ]
45+ #[ test_case( MessageWithComplexOneOf :: new( ) . set_int32 ( 0 ) , json!( { "int32 " : 0 } ) ) ]
46+ #[ test_case( MessageWithComplexOneOf :: new( ) . set_int32 ( 1 ) , json!( { "int32 " : 1 } ) ) ]
47+ #[ test_case( MessageWithComplexOneOf :: new( ) . set_int32 ( 2 ) , json!( { "int32 " : 2 } ) ) ]
48+ #[ test_case( MessageWithComplexOneOf :: new( ) . set_int32 ( 3 ) , json!( { "int32 " : 3 } ) ) ]
49+ #[ test_case( MessageWithComplexOneOf :: new( ) . set_int64 ( 0 ) , json!( { "int64 " : "0" } ) ) ]
50+ #[ test_case( MessageWithComplexOneOf :: new( ) . set_int64 ( 1 ) , json!( { "int64 " : "1" } ) ) ]
51+ #[ test_case( MessageWithComplexOneOf :: new( ) . set_int64 ( 2 ) , json!( { "int64 " : "2" } ) ) ]
52+ #[ test_case( MessageWithComplexOneOf :: new( ) . set_int64 ( 3 ) , json!( { "int64 " : "3" } ) ) ]
5353 #[ test_case( MessageWithComplexOneOf :: new( ) . set_enum( TestEnum :: default ( ) ) , json!( { "enum" : 0 } ) ) ]
5454 #[ test_case( MessageWithComplexOneOf :: new( ) . set_inner( Inner :: default ( ) . set_strings( [ "a" , "b" ] ) ) , json!( { "inner" : { "strings" : [ "a" , "b" ] } } ) ) ]
5555 #[ test_case( MessageWithComplexOneOf :: new( ) . set_duration( Duration :: clamp( -1 , -750_000_000 ) ) , json!( { "duration" : "-1.75s" } ) ) ]
@@ -76,14 +76,14 @@ mod tests {
7676 #[ test_case( MessageWithComplexOneOf :: new( ) . set_double_value( 1.5 ) , json!( { "doubleValue" : "1.5" } ) ) ]
7777 #[ test_case( MessageWithComplexOneOf :: new( ) . set_double_value( 2.5 ) , json!( { "doubleValue" : 2.5 } ) ) ]
7878 #[ test_case( MessageWithComplexOneOf :: new( ) . set_double_value( 3.0 ) , json!( { "doubleValue" : 3 } ) ) ]
79- #[ test_case( MessageWithComplexOneOf :: new( ) . set_int ( 0 ) , json!( { "int " : 0 } ) ) ]
80- #[ test_case( MessageWithComplexOneOf :: new( ) . set_int ( 1 ) , json!( { "int " : "1" } ) ) ]
81- #[ test_case( MessageWithComplexOneOf :: new( ) . set_int ( 2 ) , json!( { "int " : 2.0 } ) ) ]
82- #[ test_case( MessageWithComplexOneOf :: new( ) . set_int ( 3 ) , json!( { "int " : 3e0 } ) ) ]
83- #[ test_case( MessageWithComplexOneOf :: new( ) . set_long ( 0 ) , json!( { "long " : 0 } ) ) ]
84- #[ test_case( MessageWithComplexOneOf :: new( ) . set_long ( 1 ) , json!( { "long " : "1" } ) ) ]
85- #[ test_case( MessageWithComplexOneOf :: new( ) . set_long ( 2 ) , json!( { "long " : 2.0 } ) ) ]
86- #[ test_case( MessageWithComplexOneOf :: new( ) . set_long ( 3 ) , json!( { "long " : 3e0 } ) ) ]
79+ #[ test_case( MessageWithComplexOneOf :: new( ) . set_int32 ( 0 ) , json!( { "int32 " : 0 } ) ) ]
80+ #[ test_case( MessageWithComplexOneOf :: new( ) . set_int32 ( 1 ) , json!( { "int32 " : "1" } ) ) ]
81+ #[ test_case( MessageWithComplexOneOf :: new( ) . set_int32 ( 2 ) , json!( { "int32 " : 2.0 } ) ) ]
82+ #[ test_case( MessageWithComplexOneOf :: new( ) . set_int32 ( 3 ) , json!( { "int32 " : 3e0 } ) ) ]
83+ #[ test_case( MessageWithComplexOneOf :: new( ) . set_int64 ( 0 ) , json!( { "int64 " : 0 } ) ) ]
84+ #[ test_case( MessageWithComplexOneOf :: new( ) . set_int64 ( 1 ) , json!( { "int64 " : "1" } ) ) ]
85+ #[ test_case( MessageWithComplexOneOf :: new( ) . set_int64 ( 2 ) , json!( { "int64 " : 2.0 } ) ) ]
86+ #[ test_case( MessageWithComplexOneOf :: new( ) . set_int64 ( 3 ) , json!( { "int64 " : 3e0 } ) ) ]
8787 #[ test_case( MessageWithComplexOneOf :: new( ) . set_enum( TestEnum :: default ( ) ) , json!( { "enum" : 0 } ) ) ]
8888 #[ test_case( MessageWithComplexOneOf :: new( ) . set_inner( Inner :: default ( ) . set_strings( [ "a" , "b" ] ) ) , json!( { "inner" : { "strings" : [ "a" , "b" ] } } ) ) ]
8989 #[ test_case( MessageWithComplexOneOf :: new( ) . set_duration( Duration :: clamp( -1 , -750_000_000 ) ) , json!( { "duration" : "-1.75s" } ) ) ]
@@ -107,8 +107,8 @@ mod tests {
107107 #[ test_case( r#"{"string_value": null}"# , MessageWithComplexOneOf :: new( ) . set_string_value( "" ) ) ]
108108 #[ test_case( r#"{"float_value": null}"# , MessageWithComplexOneOf :: new( ) . set_float_value( 0_f32 ) ) ]
109109 #[ test_case( r#"{"double_value": null}"# , MessageWithComplexOneOf :: new( ) . set_double_value( 0_f64 ) ) ]
110- #[ test_case( r#"{"int ": null}"# , MessageWithComplexOneOf :: new( ) . set_int ( 0 ) ) ]
111- #[ test_case( r#"{"long ": null}"# , MessageWithComplexOneOf :: new( ) . set_long ( 0_i64 ) ) ]
110+ #[ test_case( r#"{"int32 ": null}"# , MessageWithComplexOneOf :: new( ) . set_int32 ( 0 ) ) ]
111+ #[ test_case( r#"{"int64 ": null}"# , MessageWithComplexOneOf :: new( ) . set_int64 ( 0_i64 ) ) ]
112112 #[ test_case( r#"{"enum": null}"# , MessageWithComplexOneOf :: new( ) . set_enum( TestEnum :: default ( ) ) ) ]
113113 #[ test_case( r#"{"inner": null}"# , MessageWithComplexOneOf :: new( ) . set_inner( Inner :: default ( ) ) ) ]
114114 #[ test_case( r#"{"duration": null}"# , MessageWithComplexOneOf :: new( ) . set_duration( Duration :: default ( ) ) ) ]
@@ -131,10 +131,10 @@ mod tests {
131131 #[ test_case( r#"{"floatValue": 0, "floatValue": 0}"# ) ]
132132 #[ test_case( r#"{"null": null, "doubleValue": 0}"# ) ]
133133 #[ test_case( r#"{"doubleValue": 0, "doubleValue": 0}"# ) ]
134- #[ test_case( r#"{"null": null, "int": 0}"# ) ]
135- #[ test_case( r#"{"int ": 0, "int": 0}"# ) ]
136- #[ test_case( r#"{"null": null, "long": 0}"# ) ]
137- #[ test_case( r#"{"long ": 0, "long": 0}"# ) ]
134+ #[ test_case( r#"{"null": null, "int32": 0}"# ) ]
135+ #[ test_case( r#"{"int32 ": 0, "int32": 0}"# ) ]
136+ #[ test_case( r#"{"null": null, "int64": 0}"# ) ]
137+ #[ test_case( r#"{"int64 ": 0, "int64": 0}"# ) ]
138138 #[ test_case( r#"{"null": null, "enum": "BLACK"}"# ) ]
139139 #[ test_case( r#"{"enum": "BLACK", "enum": "BLACK"}"# ) ]
140140 #[ test_case( r#"{"null": null, "inner": {}}"# ) ]
@@ -226,25 +226,25 @@ mod tests {
226226 Ok ( ( ) )
227227 }
228228
229- #[ test_case( json!( { "int " : 0 } ) , 0 ) ]
230- #[ test_case( json!( { "int " : "0" } ) , 0 ; "0 as str" ) ]
231- #[ test_case( json!( { "int " : 1 } ) , 1 ) ]
232- #[ test_case( json!( { "int " : "1" } ) , 1 ; "1 as str" ) ]
229+ #[ test_case( json!( { "int32 " : 0 } ) , 0 ) ]
230+ #[ test_case( json!( { "int32 " : "0" } ) , 0 ; "0 as str" ) ]
231+ #[ test_case( json!( { "int32 " : 1 } ) , 1 ) ]
232+ #[ test_case( json!( { "int32 " : "1" } ) , 1 ; "1 as str" ) ]
233233 fn test_int ( input : Value , want : i32 ) -> Result {
234234 let got = serde_json:: from_value :: < MessageWithComplexOneOf > ( input) ?;
235- assert_eq ! ( got. int ( ) , Some ( & want) , "{got:?}" ) ;
235+ assert_eq ! ( got. int32 ( ) , Some ( & want) , "{got:?}" ) ;
236236 let roundtrip = serde_json:: from_value ( serde_json:: to_value ( & got) ?) ?;
237237 assert_eq ! ( got, roundtrip) ;
238238 Ok ( ( ) )
239239 }
240240
241- #[ test_case( json!( { "long " : 0 } ) , 0 ) ]
242- #[ test_case( json!( { "long " : "0" } ) , 0 ; "0 as str" ) ]
243- #[ test_case( json!( { "long " : 1 } ) , 1 ) ]
244- #[ test_case( json!( { "long " : "1" } ) , 1 ; "1 as str" ) ]
241+ #[ test_case( json!( { "int64 " : 0 } ) , 0 ) ]
242+ #[ test_case( json!( { "int64 " : "0" } ) , 0 ; "0 as str" ) ]
243+ #[ test_case( json!( { "int64 " : 1 } ) , 1 ) ]
244+ #[ test_case( json!( { "int64 " : "1" } ) , 1 ; "1 as str" ) ]
245245 fn test_long ( input : Value , want : i64 ) -> Result {
246246 let got = serde_json:: from_value :: < MessageWithComplexOneOf > ( input) ?;
247- assert_eq ! ( got. long ( ) , Some ( & want) , "{got:?}" ) ;
247+ assert_eq ! ( got. int64 ( ) , Some ( & want) , "{got:?}" ) ;
248248 let roundtrip = serde_json:: from_value ( serde_json:: to_value ( & got) ?) ?;
249249 assert_eq ! ( got, roundtrip) ;
250250 Ok ( ( ) )
0 commit comments