From 6a0667567d2daef620ce84ac5e282714adea3fa2 Mon Sep 17 00:00:00 2001 From: Stoian Ivanov Date: Thu, 6 Oct 2016 23:16:29 +0300 Subject: [PATCH] some simple tests --- tests/Makefile.am | 1 + tests/test_set_value.c | 30 ++++++++++++++++++++++++++++++ tests/test_set_value.expected | 4 ++++ tests/test_set_value.test | 12 ++++++++++++ 4 files changed, 47 insertions(+) create mode 100644 tests/test_set_value.c create mode 100644 tests/test_set_value.expected create mode 100755 tests/test_set_value.test diff --git a/tests/Makefile.am b/tests/Makefile.am index d33e22c065..f6e4b2d37c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 index 0000000000..a321260761 --- /dev/null +++ b/tests/test_set_value.c @@ -0,0 +1,30 @@ +#include +#include +#include + +#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 index 0000000000..0ac57fe6bb --- /dev/null +++ b/tests/test_set_value.expected @@ -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 index 0000000000..4e8fdac174 --- /dev/null +++ b/tests/test_set_value.test @@ -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 $?