예제 #1
0
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);
}
예제 #2
0
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);
}
예제 #3
0
파일: test-value.c 프로젝트: rpm5/libbson
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, &copy);
   assert (bson_append_value (&other, bson_iter_key (&iter), -1, &copy));

   bson_value_destroy (&copy);
   bson_destroy (doc);
   bson_destroy (&other);
}