File: p_bson_find.c

package info (click to toggle)
syslog-ng 3.3.5-4
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 14,120 kB
  • sloc: ansic: 60,880; sh: 12,423; yacc: 7,308; xml: 1,554; makefile: 1,242; python: 801; lex: 262; perl: 216; awk: 184
file content (43 lines) | stat: -rw-r--r-- 697 bytes parent folder | download | duplicates (2)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "tap.h"
#include "test.h"

#include <mongo.h>

#define MAX_KEYS 10000

void
test_p_bson_find (void)
{
  bson *b;
  bson_cursor *c;
  gint i;
  gchar **keys;
  gboolean ret = TRUE;

  keys = g_new(gchar *, MAX_KEYS);

  b = bson_new ();
  for (i = 0; i < MAX_KEYS; i++)
    {
      keys[i] = g_strdup_printf ("tmp_key_%d", i);
      bson_append_int32 (b, keys[i], i);
    }
  bson_finish (b);

  for (i = 1; i <= MAX_KEYS; i++)
    {
      c = bson_find (b, keys[i - 1]);
      if (!c)
	ret = FALSE;
      bson_cursor_free (c);
      g_free (keys[i - 1]);
    }

  bson_free (b);
  g_free (keys);

  ok (ret == TRUE,
      "bson_find() performance test ok");
}

RUN_TEST (1, p_bson_find);