static void
test_extract_ctx (void)
{
   int32_t a, b, c;

   bson_t *bson =
      BCON_NEW ("a", BCON_INT32 (1), "b", BCON_INT32 (2), "c", BCON_INT32 (3));

   test_extract_ctx_helper (bson,
                            3,
                            "a",
                            BCONE_INT32 (a),
                            NULL,
                            "b",
                            BCONE_INT32 (b),
                            NULL,
                            "c",
                            BCONE_INT32 (c),
                            NULL);

   assert (a == 1);
   assert (b == 2);
   assert (c == 3);

   bson_destroy (bson);
}
static void
test_inline_array (void)
{
   int32_t a, b;

   bson_t *bcon = BCON_NEW ("foo", "[", BCON_INT32 (1), BCON_INT32 (2), "]");

   assert (
      BCON_EXTRACT (bcon, "foo", "[", BCONE_INT32 (a), BCONE_INT32 (b), "]"));

   assert (a == 1);
   assert (b == 2);

   bson_destroy (bcon);
}
Beispiel #3
0
static void
test_nested (void)
{
   const char *utf8;
   int i32;

   bson_t *bcon = BCON_NEW (
      "hello", "world",
      "foo", "{",
      "bar", BCON_INT32 (10),
      "}"
      );

   assert (BCON_EXTRACT (bcon,
                         "hello", BCONE_UTF8 (utf8),
                         "foo", "{",
                         "bar", BCONE_INT32 (i32),
                         "}"
                         ));

   assert (strcmp ("world", utf8) == 0);
   assert (i32 == 10);

   bson_destroy (bcon);
}
static void
test_inline_doc (void)
{
   int32_t a, b;

   bson_t *bcon =
      BCON_NEW ("foo", "{", "b", BCON_INT32 (2), "a", BCON_INT32 (1), "}");

   BSON_ASSERT (BCON_EXTRACT (
      bcon, "foo", "{", "a", BCONE_INT32 (a), "b", BCONE_INT32 (b), "}"));

   BSON_ASSERT (a == 1);
   BSON_ASSERT (b == 2);

   bson_destroy (bcon);
}
Beispiel #5
0
static void
test_int32 (void)
{
   int32_t i32;

   bson_t *bcon = BCON_NEW ("foo", BCON_INT32 (10));

   assert (BCON_EXTRACT (bcon, "foo", BCONE_INT32 (i32)));

   assert (i32 == 10);

   bson_destroy (bcon);
}