static void test_decimal128 (void) { bson_decimal128_t val; bson_decimal128_t dec; bson_t *bcon; bson_decimal128_from_string("12", &dec); bcon = BCON_NEW ("foo", BCON_DECIMAL128 (&dec)); assert (BCON_EXTRACT (bcon, "foo", BCONE_DECIMAL128 (val))); assert (val.low == 0xCULL); assert (val.high == 0x3040000000000000ULL); bson_destroy (bcon); }
static void test_decimal128 (void) { bson_t bcon, expected; bson_decimal128_t dec; bson_decimal128_from_string("120E20", &dec); bson_init (&bcon); bson_init (&expected); bson_append_decimal128 (&expected, "foo", -1, &dec); BCON_APPEND(&bcon, "foo", BCON_DECIMAL128(&dec)); bson_eq_bson (&bcon, &expected); bson_destroy (&bcon); bson_destroy (&expected); }
static void test_value_decimal128 (void) { const bson_value_t *value; bson_value_t copy; bson_iter_t iter; bson_decimal128_t dec; bson_t other = BSON_INITIALIZER; bson_t *doc; assert (bson_decimal128_from_string ("123.5", &dec)); doc = BCON_NEW ("decimal128", BCON_DECIMAL128 (&dec)); assert (bson_iter_init (&iter, doc) && bson_iter_next (&iter)); assert (value = bson_iter_value (&iter)); bson_value_copy (value, ©); assert (bson_append_value (&other, bson_iter_key (&iter), -1, ©)); bson_value_destroy (©); bson_destroy (doc); bson_destroy (&other); }