summaryrefslogtreecommitdiff
path: root/tests/perf/bson/p_bson_find.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2014-12-02 10:06:21 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2014-12-02 10:06:21 +0100
commitfd841e416881cc0392e61ec312c1870f3a0004bd (patch)
tree8357ba56e79d614ba57f722e7878b853591dc339 /tests/perf/bson/p_bson_find.c
Initial import of libmongo-client version 0.1.8-2
Diffstat (limited to 'tests/perf/bson/p_bson_find.c')
-rw-r--r--tests/perf/bson/p_bson_find.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/perf/bson/p_bson_find.c b/tests/perf/bson/p_bson_find.c
new file mode 100644
index 0000000..4e62132
--- /dev/null
+++ b/tests/perf/bson/p_bson_find.c
@@ -0,0 +1,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);