]> git.ipfire.org Git - thirdparty/json-c.git/commitdiff
some simple tests
authorStoian Ivanov <sdr@mail.bg>
Thu, 6 Oct 2016 20:16:29 +0000 (23:16 +0300)
committerStoian Ivanov <sdr@mail.bg>
Thu, 6 Oct 2016 20:16:29 +0000 (23:16 +0300)
tests/Makefile.am
tests/test_set_value.c [new file with mode: 0644]
tests/test_set_value.expected [new file with mode: 0644]
tests/test_set_value.test [new file with mode: 0755]

index d33e22c06512bdf4028347d414c6521ea6fc891d..f6e4b2d37cf6b0aad44c3f8122b58d6faee3eb62 100644 (file)
@@ -21,6 +21,7 @@ TESTS+= test_charcase.test
 TESTS+= test_printbuf.test
 TESTS+= test_set_serializer.test
 TESTS+= test_compare.test
+TESTS+= test_set_value.test
 
 check_PROGRAMS=
 check_PROGRAMS += $(TESTS:.test=)
diff --git a/tests/test_set_value.c b/tests/test_set_value.c
new file mode 100644 (file)
index 0000000..a321260
--- /dev/null
@@ -0,0 +1,30 @@
+#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "json.h"
+
+int main(int argc, char **argv)
+{
+       json_object *tmp=json_object_new_int(123);
+       assert (json_object_get_int(tmp)==123);
+       json_object_set_int(tmp,321);
+       assert (json_object_get_int(tmp)==321); 
+       printf("INT PASSED\n");
+       json_object_set_int64(tmp,(int64_t)321321321);
+       assert (json_object_get_int64(tmp)==321321321); 
+       json_object_put(tmp);
+       printf("INT64 PASSED\n");
+       tmp=json_object_new_boolean(TRUE);
+       assert (json_object_get_boolean(tmp)==TRUE); 
+       json_object_set_boolean(tmp,FALSE);
+       assert (json_object_get_boolean(tmp)==FALSE); 
+       json_object_set_boolean(tmp,TRUE);
+       assert (json_object_get_boolean(tmp)==TRUE); 
+       json_object_put(tmp);
+       printf("BOOL PASSED\n");
+       
+       
+       printf("PASSED\n");
+       return 0;
+}
diff --git a/tests/test_set_value.expected b/tests/test_set_value.expected
new file mode 100644 (file)
index 0000000..0ac57fe
--- /dev/null
@@ -0,0 +1,4 @@
+INT PASSED
+INT64 PASSED
+BOOL PASSED
+PASSED
diff --git a/tests/test_set_value.test b/tests/test_set_value.test
new file mode 100755 (executable)
index 0000000..4e8fdac
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+# Common definitions
+if test -z "$srcdir"; then
+    srcdir="${0%/*}"
+    test "$srcdir" = "$0" && srcdir=.
+    test -z "$srcdir" && srcdir=.
+fi
+. "$srcdir/test-defs.sh"
+
+run_output_test test_set_value
+exit $?