diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-12-02 10:06:21 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-12-02 10:06:21 +0100 |
commit | fd841e416881cc0392e61ec312c1870f3a0004bd (patch) | |
tree | 8357ba56e79d614ba57f722e7878b853591dc339 /tests/unit/mongo/wire/cmd_get_more.c |
Initial import of libmongo-client version 0.1.8-2
Diffstat (limited to 'tests/unit/mongo/wire/cmd_get_more.c')
-rw-r--r-- | tests/unit/mongo/wire/cmd_get_more.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/unit/mongo/wire/cmd_get_more.c b/tests/unit/mongo/wire/cmd_get_more.c new file mode 100644 index 0000000..5f56821 --- /dev/null +++ b/tests/unit/mongo/wire/cmd_get_more.c @@ -0,0 +1,50 @@ +#include "test.h" +#include "tap.h" +#include "mongo-wire.h" + +#include <string.h> + +void +test_mongo_wire_cmd_get_more (void) +{ + mongo_packet *p; + + mongo_packet_header hdr; + const guint8 *data; + gint32 data_size; + + gint32 pos; + gint64 cid = 9876543210; + + ok (mongo_wire_cmd_get_more (1, NULL, 1, cid) == NULL, + "mongo_wire_cmd_get_more() fails with a NULL namespace"); + ok ((p = mongo_wire_cmd_get_more (1, "test.ns", 1, cid)) != NULL, + "mongo_wire_cmd_get_more() works"); + + /* Test basic header data */ + mongo_wire_packet_get_header (p, &hdr); + cmp_ok ((data_size = mongo_wire_packet_get_data (p, &data)), "!=", -1, + "Packet data size appears fine"); + + cmp_ok (hdr.length, "==", sizeof (mongo_packet_header) + data_size, + "Packet header length is correct"); + cmp_ok (hdr.id, "==", 1, "Header ID is ok"); + cmp_ok (hdr.resp_to, "==", 0, "Response ID is ok"); + + /* + * Test the request itself. + */ + + /* pos = zero + ns + NULL + ret */ + pos = sizeof (gint32) + strlen ("test.ns") + 1 + sizeof (gint32); + cid = 0; + memcpy (&cid, data + pos, sizeof (cid)); + cid = GINT64_FROM_LE (cid); + + ok (cid == 9876543210, + "Included CID is correct"); + + mongo_wire_packet_free (p); +} + +RUN_TEST (7, mongo_wire_cmd_get_more); |