blob: 4e621323e25d4ae093d3848e2e117897aff8ad29 (
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
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);
|