Files
json-c/tests/test_cast.expected
Simon Resch 8c13801f2c Explicitly handle NaN values when converting to int
Json objects of type double with the value NaN could cause undefined
behavior when casting double to int in `json_object_get_int`.
2024-11-27 07:17:20 +01:00

115 lines
5.0 KiB
Plaintext

Parsed input: {
"string_of_digits": "123",
"regular_number": 222,
"decimal_number": 99.55,
"boolean_true": true,
"boolean_false": false,
"int64_number": 2147483649,
"negative_number": -321321321,
"a_null": null,
"empty_array": [],
"nonempty_array": [ 123 ],
"array_with_zero": [ 0 ],
"empty_object": {},
"nonempty_object": { "a": 123 },
"nan": NaN,
}
Result is not NULL
new_obj.string_of_digits json_object_get_type()=string
new_obj.string_of_digits json_object_get_int()=123
new_obj.string_of_digits json_object_get_int64()=123
new_obj.string_of_digits json_object_get_uint64()=123
new_obj.string_of_digits json_object_get_boolean()=1
new_obj.string_of_digits json_object_get_double()=123.000000
new_obj.regular_number json_object_get_type()=int
new_obj.regular_number json_object_get_int()=222
new_obj.regular_number json_object_get_int64()=222
new_obj.regular_number json_object_get_uint64()=222
new_obj.regular_number json_object_get_boolean()=1
new_obj.regular_number json_object_get_double()=222.000000
new_obj.decimal_number json_object_get_type()=double
new_obj.decimal_number json_object_get_int()=99
new_obj.decimal_number json_object_get_int64()=99
new_obj.decimal_number json_object_get_uint64()=99
new_obj.decimal_number json_object_get_boolean()=1
new_obj.decimal_number json_object_get_double()=99.550000
new_obj.boolean_true json_object_get_type()=boolean
new_obj.boolean_true json_object_get_int()=1
new_obj.boolean_true json_object_get_int64()=1
new_obj.boolean_true json_object_get_uint64()=1
new_obj.boolean_true json_object_get_boolean()=1
new_obj.boolean_true json_object_get_double()=1.000000
new_obj.boolean_false json_object_get_type()=boolean
new_obj.boolean_false json_object_get_int()=0
new_obj.boolean_false json_object_get_int64()=0
new_obj.boolean_false json_object_get_uint64()=0
new_obj.boolean_false json_object_get_boolean()=0
new_obj.boolean_false json_object_get_double()=0.000000
new_obj.int64_number json_object_get_type()=int
new_obj.int64_number json_object_get_int()=2147483647
new_obj.int64_number json_object_get_int64()=2147483649
new_obj.int64_number json_object_get_uint64()=2147483649
new_obj.int64_number json_object_get_boolean()=1
new_obj.int64_number json_object_get_double()=2147483649.000000
new_obj.negative_number json_object_get_type()=int
new_obj.negative_number json_object_get_int()=-321321321
new_obj.negative_number json_object_get_int64()=-321321321
new_obj.negative_number json_object_get_uint64()=0
new_obj.negative_number json_object_get_boolean()=1
new_obj.negative_number json_object_get_double()=-321321321.000000
new_obj.a_null json_object_get_type()=null
new_obj.a_null json_object_get_int()=0
new_obj.a_null json_object_get_int64()=0
new_obj.a_null json_object_get_uint64()=0
new_obj.a_null json_object_get_boolean()=0
new_obj.a_null json_object_get_double()=0.000000
new_obj.empty_array json_object_get_type()=array
new_obj.empty_array json_object_get_int()=0
new_obj.empty_array json_object_get_int64()=0
new_obj.empty_array json_object_get_uint64()=0
new_obj.empty_array json_object_get_boolean()=0
new_obj.empty_array json_object_get_double()=0.000000
new_obj.nonempty_array json_object_get_type()=array
new_obj.nonempty_array json_object_get_int()=0
new_obj.nonempty_array json_object_get_int64()=0
new_obj.nonempty_array json_object_get_uint64()=0
new_obj.nonempty_array json_object_get_boolean()=0
new_obj.nonempty_array json_object_get_double()=0.000000
new_obj.array_with_zero json_object_get_type()=array
new_obj.array_with_zero json_object_get_int()=0
new_obj.array_with_zero json_object_get_int64()=0
new_obj.array_with_zero json_object_get_uint64()=0
new_obj.array_with_zero json_object_get_boolean()=0
new_obj.array_with_zero json_object_get_double()=0.000000
new_obj.empty_object json_object_get_type()=object
new_obj.empty_object json_object_get_int()=0
new_obj.empty_object json_object_get_int64()=0
new_obj.empty_object json_object_get_uint64()=0
new_obj.empty_object json_object_get_boolean()=0
new_obj.empty_object json_object_get_double()=0.000000
new_obj.nonempty_object json_object_get_type()=object
new_obj.nonempty_object json_object_get_int()=0
new_obj.nonempty_object json_object_get_int64()=0
new_obj.nonempty_object json_object_get_uint64()=0
new_obj.nonempty_object json_object_get_boolean()=0
new_obj.nonempty_object json_object_get_double()=0.000000
new_obj.nan json_object_get_type()=double
new_obj.nan json_object_get_int()=-2147483648
new_obj.nan json_object_get_int64()=-9223372036854775808
new_obj.nan json_object_get_uint64()=0
new_obj.nan json_object_get_boolean()=1
new_obj.nan json_object_get_double()=nan
================================
json_object_is_type: null,boolean,double,int,object,array,string
new_obj : 0,0,0,0,1,0,0
new_obj.string_of_digits : 0,0,0,0,0,0,1
new_obj.regular_number : 0,0,0,1,0,0,0
new_obj.decimal_number : 0,0,1,0,0,0,0
new_obj.boolean_true : 0,1,0,0,0,0,0
new_obj.boolean_false : 0,1,0,0,0,0,0
new_obj.int64_number : 0,0,0,1,0,0,0
new_obj.negative_number : 0,0,0,1,0,0,0
new_obj.a_null : 1,0,0,0,0,0,0
new_obj.nan : 0,0,1,0,0,0,0