~ubuntu-branches/ubuntu/trusty/syslog-ng/trusty-proposed

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Laszlo Boszormenyi (GCS), Gergely Nagy
  • Date: 2011-10-11 14:30:48 UTC
  • mfrom: (1.3.7)
  • Revision ID: package-import@ubuntu.com-20111011143048-r1iljux9xbvj3lwh
Tags: 3.3.1.dfsg-1
* New upstream release with important fixes from upstream git tree with
  non-free manpages removed.
* Drop syslog-ng.conf(5) (closes: #496521).
* syslog-ng(8) is generated, and does not mention -Q anymore
  (closes: #616069).
* Supports CAP_SYSLOG on recent kernels (closes: #630172).
* Does not use g_timeout_add_seconds anymore (closes: #609154).

[ Gergely Nagy <algernon@madhouse-project.org> ]
* Update debian/copyright to DEP-5 format.
* Simplified the logrotate file by merging identical entries.
* Include local configuration files from /etc/syslog-ng/conf.d/ (Closes:
  #609050).
* Update syslog-ng.conf to be fully 3.3 compliant.
* Compress both source and binaries (except the syslog-ng meta
  package) with xz, instead of gzip.
* Use dpkg triggers to restart syslog-ng when appropriate.
* Include DFSG-free manual pages for all binaries.
* Build with Hardening enabled.
* Mention syslog(3) in /etc/default/syslog-ng, instead of
  <linux/kernel.h> (Closes: #608605)
* Support 'status' in the init script.
  Patch from Peter Eisentraut <petere@debian.org> (Closes: #644458)
* Build-Depend on libevtlog-dev (>= 0.2.12-5~) for correct shlibs.
* Use [linux-any] in Build-Depends instead of hardcoded links.
  (Closes: #634715)
* Use $SYSLOGNG_OPTS in the init script when reloading syslog-ng.
  (Closes: #589081)

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_binary (void)
 
9
{
 
10
  bson *b;
 
11
 
 
12
  b = bson_new ();
 
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");
 
19
  bson_finish (b);
 
20
 
 
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",
 
27
              bson_size (b)) == 0,
 
28
      "BSON binary element contents check");
 
29
 
 
30
  bson_free (b);
 
31
 
 
32
  b = bson_new ();
 
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,
 
37
                          NULL, 10) == FALSE,
 
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");
 
45
  bson_finish (b);
 
46
  cmp_ok (bson_size (b), "==", 5,
 
47
          "BSON object should be empty");
 
48
 
 
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");
 
52
 
 
53
  bson_free (b);
 
54
}
 
55
 
 
56
RUN_TEST (10, bson_binary);