8
test_bson_binary (void)
13
ok (bson_append_binary (b, "binary0", BSON_BINARY_SUBTYPE_GENERIC,
14
(guint8 *)"foo\0bar", 7),
15
"bson_append_binary(), type 0 works");
16
ok (bson_append_binary (b, "binary2", BSON_BINARY_SUBTYPE_BINARY,
17
(guint8 *)"\0\0\0\7foo\0bar", 11),
18
"bson_append_binary(), type 2 works");
21
cmp_ok (bson_size (b), "==", 51, "BSON binary element size check");
22
ok (memcmp (bson_data (b),
23
"\063\000\000\000\005\142\151\156\141\162\171\060\000\007\000"
24
"\000\000\000\146\157\157\000\142\141\162\005\142\151\156\141"
25
"\162\171\062\000\013\000\000\000\002\000\000\000\007\146\157"
26
"\157\000\142\141\162\000",
28
"BSON binary element contents check");
33
ok (bson_append_binary (b, NULL, BSON_BINARY_SUBTYPE_GENERIC,
34
(guint8 *)"foo\0bar", 7) == FALSE,
35
"bson_append_binary() without a key name should fail");
36
ok (bson_append_binary (b, "binary1", BSON_BINARY_SUBTYPE_GENERIC,
38
"bson_append_binary () without binary data should fail");
39
ok (bson_append_binary (b, "binary3", BSON_BINARY_SUBTYPE_GENERIC,
40
(guint8 *)"foo\0bar", -1) == FALSE,
41
"bson_append_binary () with an invalid length should fail");
42
ok (bson_append_binary (NULL, "binary1", BSON_BINARY_SUBTYPE_GENERIC,
43
(guint8 *)"foo\0bar", 7) == FALSE,
44
"bson_append_binary () without a BSON object should fail");
46
cmp_ok (bson_size (b), "==", 5,
47
"BSON object should be empty");
49
ok (bson_append_binary (b, "binary", BSON_BINARY_SUBTYPE_GENERIC,
50
(guint8 *)"foo\0bar", 7) == FALSE,
51
"Appending to a finished element should fail");
56
RUN_TEST (10, bson_binary);