summaryrefslogtreecommitdiff
path: root/tests/unit/bson/bson_new.c
blob: 31490275a58fc59351f987f8b74b4d034ead6004 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "bson.h"
#include "test.h"
#include "tap.h"

#include <string.h>

void
test_bson_new (void)
{
  bson *b;

  ok ((b = bson_new ()) != NULL, "bson_new() works");
  ok (bson_data (b) == NULL,
      "bson_data() with an unfished object should fail");
  ok (bson_size (b) == -1,
      "bson_size() with an unfinished object should fail");
  ok (bson_finish (b), "bson_finish() works");
  ok (bson_finish (b),
      "bson_finish() works on an already finished object too");
  bson_free (b);

  ok (bson_size (NULL) == -1, "bson_size(NULL) works correctly");
  ok (bson_data (NULL) == NULL, "bson_data(NULL) works correctly");
  ok (bson_finish (NULL) == FALSE, "bson_finish(NULL) works correctly");
  bson_free (NULL);
}

RUN_TEST (8, bson_new);