~ubuntu-branches/ubuntu/saucy/syslog-ng/saucy

« back to all changes in this revision

Viewing changes to modules/afmongodb/libmongo-client/tests/unit/bson/bson_cursor_get_array.c

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2011-11-15 08:48:02 UTC
  • mfrom: (26.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20111115084802-n0jegdnjlxk0m26s
Tags: 3.3.1.dfsg-1ubuntu1
* debian/control: remove libsystemd-daemon-dev build-depends
* debian/rules: remove --with-systemdsystemunitdir from
  override_dh_auto_configure.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "tap.h"
 
2
#include "test.h"
 
3
#include "bson.h"
 
4
 
 
5
#include <string.h>
 
6
 
 
7
void
 
8
test_bson_cursor_get_array (void)
 
9
{
 
10
  bson *b, *a = NULL;
 
11
  bson_cursor *c;
 
12
 
 
13
  ok (bson_cursor_get_array (NULL, &a) == FALSE,
 
14
      "bson_cursor_get_array() with a NULL cursor fails");
 
15
 
 
16
  b = test_bson_generate_full ();
 
17
  c = bson_cursor_new (b);
 
18
 
 
19
  ok (bson_cursor_get_array (c, NULL) == FALSE,
 
20
      "bson_cursor_get_array() with a NULL destination fails");
 
21
  ok (bson_cursor_get_array (c, &a) == FALSE,
 
22
      "bson_cursor_get_array() at the initial position fails");
 
23
  ok (a == NULL,
 
24
      "destination remains unchanged after failed cursor operations");
 
25
  bson_cursor_free (c);
 
26
 
 
27
  c = bson_find (b, "array");
 
28
  ok (bson_cursor_get_array (c, &a),
 
29
      "bson_cursor_get_array() works");
 
30
  cmp_ok (bson_size (a), ">", 0,
 
31
          "the returned document is finished");
 
32
  bson_free (a);
 
33
 
 
34
  bson_cursor_next (c);
 
35
 
 
36
  ok (bson_cursor_get_array (c, &a) == FALSE,
 
37
      "bson_cursor_get_array() fails if the cursor points to "
 
38
      "non-array data");
 
39
 
 
40
  bson_cursor_free (c);
 
41
  bson_free (b);
 
42
}
 
43
 
 
44
RUN_TEST (7, bson_cursor_get_array);