@@ -58,6 +58,12 @@ typedef struct vector_json_test_case_t {
58
58
bool * test_valid ;
59
59
} vector_json_test_case_t ;
60
60
61
+ static BSON_INLINE double
62
+ double_inf (void )
63
+ {
64
+ return 1.0 / 0.0 ;
65
+ }
66
+
61
67
static void
62
68
translate_json_test_vector (bson_t * array_in , bson_t * array_out )
63
69
{
@@ -70,9 +76,9 @@ translate_json_test_vector (bson_t *array_in, bson_t *array_out)
70
76
bson_array_builder_t * builder = bson_array_builder_new ();
71
77
while (bson_iter_next (& iter_in )) {
72
78
if (BSON_ITER_HOLDS_UTF8 (& iter_in ) && 0 == strcmp ("inf" , bson_iter_utf8 (& iter_in , NULL ))) {
73
- BSON_ASSERT (bson_array_builder_append_double (builder , INFINITY ));
79
+ BSON_ASSERT (bson_array_builder_append_double (builder , double_inf () ));
74
80
} else if (BSON_ITER_HOLDS_UTF8 (& iter_in ) && 0 == strcmp ("-inf" , bson_iter_utf8 (& iter_in , NULL ))) {
75
- BSON_ASSERT (bson_array_builder_append_double (builder , - INFINITY ));
81
+ BSON_ASSERT (bson_array_builder_append_double (builder , - double_inf () ));
76
82
} else {
77
83
BSON_ASSERT (bson_array_builder_append_iter (builder , & iter_in ));
78
84
}
@@ -315,10 +321,10 @@ test_bson_vector_json_case (vector_json_test_case_t *test_case)
315
321
316
322
double expected_double ;
317
323
if (BSON_ITER_HOLDS_UTF8 (& expected_iter ) && 0 == strcmp ("inf" , bson_iter_utf8 (& expected_iter , NULL ))) {
318
- expected_double = INFINITY ;
324
+ expected_double = double_inf () ;
319
325
} else if (BSON_ITER_HOLDS_UTF8 (& expected_iter ) &&
320
326
0 == strcmp ("-inf" , bson_iter_utf8 (& expected_iter , NULL ))) {
321
- expected_double = - INFINITY ;
327
+ expected_double = - double_inf () ;
322
328
} else if (BSON_ITER_HOLDS_DOUBLE (& expected_iter )) {
323
329
expected_double = bson_iter_double (& expected_iter );
324
330
} else {
@@ -1235,7 +1241,7 @@ test_bson_vector_example_float32_const_view (void)
1235
1241
// setup: construct a sample document
1236
1242
bson_t doc = BSON_INITIALIZER ;
1237
1243
{
1238
- static const float values [] = {5.0f , -1e10f , ( float ) INFINITY , ( float ) NAN , -1.0f };
1244
+ static const float values [] = {5.0f , -1e10f , INFINITY , NAN , -1.0f };
1239
1245
bson_vector_float32_view_t view ;
1240
1246
BSON_ASSERT (BSON_APPEND_VECTOR_FLOAT32_UNINIT (& doc , "vector" , sizeof values / sizeof values [0 ], & view ));
1241
1247
BSON_ASSERT (bson_vector_float32_view_write (view , values , sizeof values / sizeof values [0 ], 0 ));
0 commit comments