Browse Source

some simple tests

tags/json-c-0.13-20171207
Stoian Ivanov 9 years ago
parent
commit
6a0667567d
4 changed files with 47 additions and 0 deletions
  1. +1
    -0
      tests/Makefile.am
  2. +30
    -0
      tests/test_set_value.c
  3. +4
    -0
      tests/test_set_value.expected
  4. +12
    -0
      tests/test_set_value.test

+ 1
- 0
tests/Makefile.am View File

@@ -21,6 +21,7 @@ TESTS+= test_charcase.test
TESTS+= test_printbuf.test TESTS+= test_printbuf.test
TESTS+= test_set_serializer.test TESTS+= test_set_serializer.test
TESTS+= test_compare.test TESTS+= test_compare.test
TESTS+= test_set_value.test


check_PROGRAMS= check_PROGRAMS=
check_PROGRAMS += $(TESTS:.test=) check_PROGRAMS += $(TESTS:.test=)


+ 30
- 0
tests/test_set_value.c View File

@@ -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;
}

+ 4
- 0
tests/test_set_value.expected View File

@@ -0,0 +1,4 @@
INT PASSED
INT64 PASSED
BOOL PASSED
PASSED

+ 12
- 0
tests/test_set_value.test View File

@@ -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 $?

Loading…
Cancel
Save