integrate jansson.hpp into build and test suite
This commit is contained in:
parent
2ad4634de5
commit
c9b33e3386
@ -8,6 +8,7 @@ AC_CONFIG_HEADERS([config.h])
|
|||||||
|
|
||||||
# Checks for programs.
|
# Checks for programs.
|
||||||
AC_PROG_CC
|
AC_PROG_CC
|
||||||
|
AC_PROG_CXX
|
||||||
AC_PROG_LIBTOOL
|
AC_PROG_LIBTOOL
|
||||||
|
|
||||||
# Checks for libraries.
|
# Checks for libraries.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
include_HEADERS = jansson.h
|
include_HEADERS = jansson.h jansson.hpp jansson-impl.hpp
|
||||||
|
|
||||||
lib_LTLIBRARIES = libjansson.la
|
lib_LTLIBRARIES = libjansson.la
|
||||||
libjansson_la_SOURCES = \
|
libjansson_la_SOURCES = \
|
||||||
|
1
test/.gitignore
vendored
1
test/.gitignore
vendored
@ -7,3 +7,4 @@ suites/api/test_load
|
|||||||
suites/api/test_number
|
suites/api/test_number
|
||||||
suites/api/test_object
|
suites/api/test_object
|
||||||
suites/api/test_simple
|
suites/api/test_simple
|
||||||
|
suites/api/test_cpp
|
||||||
|
@ -5,7 +5,8 @@ check_PROGRAMS = \
|
|||||||
test_load \
|
test_load \
|
||||||
test_simple \
|
test_simple \
|
||||||
test_number \
|
test_number \
|
||||||
test_object
|
test_object \
|
||||||
|
test_cpp
|
||||||
|
|
||||||
test_array_SOURCES = test_array.c util.h
|
test_array_SOURCES = test_array.c util.h
|
||||||
test_copy_SOURCES = test_copy.c util.h
|
test_copy_SOURCES = test_copy.c util.h
|
||||||
@ -13,6 +14,7 @@ test_load_SOURCES = test_load.c util.h
|
|||||||
test_simple_SOURCES = test_simple.c util.h
|
test_simple_SOURCES = test_simple.c util.h
|
||||||
test_number_SOURCES = test_number.c util.h
|
test_number_SOURCES = test_number.c util.h
|
||||||
test_object_SOURCES = test_object.c util.h
|
test_object_SOURCES = test_object.c util.h
|
||||||
|
test_cpp_SOURCES = test_cpp.cpp
|
||||||
|
|
||||||
AM_CPPFLAGS = -I$(top_srcdir)/src
|
AM_CPPFLAGS = -I$(top_srcdir)/src
|
||||||
AM_CFLAGS = -Wall -Werror
|
AM_CFLAGS = -Wall -Werror
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
#define ASSERT_TRUE(p, m) ASSERT_OP(p, true, ==, m)
|
#define ASSERT_TRUE(p, m) ASSERT_OP(p, true, ==, m)
|
||||||
#define ASSERT_FALSE(p, m) ASSERT_OP(p, true, !=, m)
|
#define ASSERT_FALSE(p, m) ASSERT_OP(p, true, !=, m)
|
||||||
|
|
||||||
int json_cpp_tests() {
|
int main() {
|
||||||
json::Value e1(json::load_file("test.json"));
|
json::Value e1(json::load_file("suites/api/test.json"));
|
||||||
json::Value e2(e1);
|
json::Value e2(e1);
|
||||||
json::Value e3;
|
json::Value e3;
|
||||||
json::Value e4(json::load_string("{\"foo\": true, \"bar\": \"test\"}"));
|
json::Value e4(json::load_string("{\"foo\": true, \"bar\": \"test\"}"));
|
||||||
@ -126,7 +126,7 @@ int json_cpp_tests() {
|
|||||||
char* out_cstr = e12.save_string(0);
|
char* out_cstr = e12.save_string(0);
|
||||||
std::string out(out_cstr);
|
std::string out(out_cstr);
|
||||||
free(out_cstr);
|
free(out_cstr);
|
||||||
ASSERT_EQ(out, "{\"bar\": 3,\"foo\": \"test\"}\n", "object did not serialize as expected");
|
ASSERT_EQ(out, "{\"bar\": 3, \"foo\": \"test\"}", "object did not serialize as expected");
|
||||||
|
|
||||||
std::istringstream instr(out);
|
std::istringstream instr(out);
|
||||||
instr >> e12;
|
instr >> e12;
|
||||||
@ -137,7 +137,7 @@ int json_cpp_tests() {
|
|||||||
|
|
||||||
std::ostringstream outstr;
|
std::ostringstream outstr;
|
||||||
outstr << e12;
|
outstr << e12;
|
||||||
ASSERT_EQ(instr.str(), "{\"bar\": 3,\"foo\": \"test\"}\n", "object did not serialize as expected");
|
ASSERT_EQ(instr.str(), "{\"bar\": 3, \"foo\": \"test\"}", "object did not serialize as expected");
|
||||||
|
|
||||||
const json::Value e13(e12);
|
const json::Value e13(e12);
|
||||||
ASSERT_EQ(e13["bar"].as_integer(), 3, "e13.bar has incorrect value after copy");
|
ASSERT_EQ(e13["bar"].as_integer(), 3, "e13.bar has incorrect value after copy");
|
||||||
|
Loading…
Reference in New Issue
Block a user