8
test_bson_cursor_get_javascript_w_scope (void)
10
bson *b, *scope = NULL, *valid;
12
const gchar *s = "deadbeef";
14
ok (bson_cursor_get_javascript_w_scope (NULL, &s, &scope) == FALSE,
15
"bson_cursor_get_javascript_w_scope() with a NULL cursor fails");
17
b = test_bson_generate_full ();
18
c = bson_cursor_new (b);
20
ok (bson_cursor_get_javascript_w_scope (c, NULL, &scope) == FALSE,
21
"bson_cursor_get_javascript_w_scope() with a NULL js destination fails");
22
ok (bson_cursor_get_javascript_w_scope (c, &s, NULL) == FALSE,
23
"bson_cursor_get_javascript_w_scope() with a NULL scope destinatin fails");
24
ok (bson_cursor_get_javascript_w_scope (c, &s, &scope) == FALSE,
25
"bson_cursor_get_javascript_w_scope() at the initial position fails");
27
"destination remains unchanged after failed cursor operations");
30
c = bson_find (b, "print");
31
ok (bson_cursor_get_javascript_w_scope (c, &s, &scope),
32
"bson_cursor_get_javascript_w_scope() works");
34
"bson_cursor_get_javascript_w_scope() returns the correct result");
37
bson_append_string (valid, "v", "hello world", -1);
40
cmp_ok (bson_size (scope), "==", bson_size (valid),
41
"The returned scope's length is correct");
42
ok (memcmp (bson_data (scope), bson_data (valid),
43
bson_size (scope)) == 0,
44
"The returned scope is correct");
48
ok (bson_cursor_get_javascript_w_scope (c, &s, &scope) == FALSE,
49
"bson_cursor_get_javascript_w_scope() should fail when the cursor "
50
"points to non-javascript data");
57
RUN_TEST (10, bson_cursor_get_javascript_w_scope);