summaryrefslogtreecommitdiff
path: root/tests/unit/bson/bson_type_as_string.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/unit/bson/bson_type_as_string.c
Initial import of libmongo-client version 0.1.8-2
Diffstat (limited to 'tests/unit/bson/bson_type_as_string.c')
-rw-r--r--tests/unit/bson/bson_type_as_string.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/unit/bson/bson_type_as_string.c b/tests/unit/bson/bson_type_as_string.c
new file mode 100644
index 0000000..35e8210
--- /dev/null
+++ b/tests/unit/bson/bson_type_as_string.c
@@ -0,0 +1,40 @@
+#include "bson.h"
+#include "test.h"
+#include "tap.h"
+
+#include <string.h>
+
+#define CHECK_TYPE(t) \
+ is (bson_type_as_string (t), #t, \
+ "bson_type_as_string(%s) works", #t)
+
+void
+test_bson_type_as_string (void)
+{
+ CHECK_TYPE (BSON_TYPE_NONE);
+ CHECK_TYPE (BSON_TYPE_DOUBLE);
+ CHECK_TYPE (BSON_TYPE_STRING);
+ CHECK_TYPE (BSON_TYPE_DOCUMENT);
+ CHECK_TYPE (BSON_TYPE_ARRAY);
+ CHECK_TYPE (BSON_TYPE_BINARY);
+ CHECK_TYPE (BSON_TYPE_UNDEFINED);
+ CHECK_TYPE (BSON_TYPE_OID);
+ CHECK_TYPE (BSON_TYPE_BOOLEAN);
+ CHECK_TYPE (BSON_TYPE_UTC_DATETIME);
+ CHECK_TYPE (BSON_TYPE_NULL);
+ CHECK_TYPE (BSON_TYPE_REGEXP);
+ CHECK_TYPE (BSON_TYPE_DBPOINTER);
+ CHECK_TYPE (BSON_TYPE_JS_CODE);
+ CHECK_TYPE (BSON_TYPE_SYMBOL);
+ CHECK_TYPE (BSON_TYPE_JS_CODE_W_SCOPE);
+ CHECK_TYPE (BSON_TYPE_INT32);
+ CHECK_TYPE (BSON_TYPE_TIMESTAMP);
+ CHECK_TYPE (BSON_TYPE_INT64);
+ CHECK_TYPE (BSON_TYPE_MIN);
+ CHECK_TYPE (BSON_TYPE_MAX);
+
+ ok (bson_type_as_string (42) == NULL,
+ "bson_type_as_string() returns NULL on invalid type.");
+}
+
+RUN_TEST (22, bson_type_as_string);