mirror of
https://github.com/tristanpenman/valijson.git
synced 2024-12-12 18:20:27 +01:00
Automated test support for Poco JSON adapter
This commit is contained in:
parent
93ade00e00
commit
2de198ea2e
@ -9,7 +9,7 @@ matrix:
|
|||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources: ['ubuntu-toolchain-r-test']
|
sources: ['ubuntu-toolchain-r-test']
|
||||||
packages: ['g++-5', 'qtbase5-dev']
|
packages: ['g++-5', 'qtbase5-dev', 'libpoco-dev']
|
||||||
env:
|
env:
|
||||||
- CXX_COMPILER=g++-5
|
- CXX_COMPILER=g++-5
|
||||||
- C_COMPILER=gcc-5
|
- C_COMPILER=gcc-5
|
||||||
@ -19,7 +19,7 @@ matrix:
|
|||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6']
|
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6']
|
||||||
packages: ['clang-3.6', 'qtbase5-dev']
|
packages: ['clang-3.6', 'qtbase5-dev', 'libpoco-dev']
|
||||||
env:
|
env:
|
||||||
- CXX_COMPILER=clang++-3.6
|
- CXX_COMPILER=clang++-3.6
|
||||||
- C_COMPILER=clang-3.6
|
- C_COMPILER=clang-3.6
|
||||||
@ -30,7 +30,7 @@ matrix:
|
|||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.7']
|
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.7']
|
||||||
packages: ['clang-3.7', 'qtbase5-dev']
|
packages: ['clang-3.7', 'qtbase5-dev', 'libpoco-dev']
|
||||||
env:
|
env:
|
||||||
- CXX_COMPILER=clang++-3.7
|
- CXX_COMPILER=clang++-3.7
|
||||||
- C_COMPILER=clang-3.7
|
- C_COMPILER=clang-3.7
|
||||||
@ -41,7 +41,7 @@ matrix:
|
|||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.8']
|
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.8']
|
||||||
packages: ['clang-3.8', 'libc++-dev', 'libc++abi-dev', 'qtbase5-dev']
|
packages: ['clang-3.8', 'libc++-dev', 'libc++abi-dev', 'qtbase5-dev', 'libpoco-dev']
|
||||||
env:
|
env:
|
||||||
- CXX_COMPILER=clang++-3.8
|
- CXX_COMPILER=clang++-3.8
|
||||||
- C_COMPILER=clang-3.8
|
- C_COMPILER=clang-3.8
|
||||||
|
@ -22,9 +22,9 @@ set(Boost_USE_MULTITHREADED ON)
|
|||||||
set(Boost_USE_STATIC_RUNTIME OFF)
|
set(Boost_USE_STATIC_RUNTIME OFF)
|
||||||
|
|
||||||
find_package(Boost 1.54.0 REQUIRED)
|
find_package(Boost 1.54.0 REQUIRED)
|
||||||
|
find_package(Poco OPTIONAL_COMPONENTS JSON)
|
||||||
find_package(Qt5Core)
|
find_package(Qt5Core)
|
||||||
|
|
||||||
|
|
||||||
# jsoncpp library
|
# jsoncpp library
|
||||||
add_library(jsoncpp
|
add_library(jsoncpp
|
||||||
thirdparty/jsoncpp-0.9.4/src/lib_json/json_reader.cpp
|
thirdparty/jsoncpp-0.9.4/src/lib_json/json_reader.cpp
|
||||||
@ -90,6 +90,7 @@ set(TEST_SOURCES
|
|||||||
tests/test_property_tree_adapter.cpp
|
tests/test_property_tree_adapter.cpp
|
||||||
tests/test_rapidjson_adapter.cpp
|
tests/test_rapidjson_adapter.cpp
|
||||||
tests/test_picojson_adapter.cpp
|
tests/test_picojson_adapter.cpp
|
||||||
|
tests/test_poco_json_adapter.cpp
|
||||||
tests/test_validation_errors.cpp
|
tests/test_validation_errors.cpp
|
||||||
tests/test_validator.cpp
|
tests/test_validator.cpp
|
||||||
tests/test_poly_constraint.cpp
|
tests/test_poly_constraint.cpp
|
||||||
@ -110,11 +111,16 @@ set_target_properties(test_suite
|
|||||||
)
|
)
|
||||||
|
|
||||||
set(TEST_LIBS gtest gtest_main jsoncpp json11)
|
set(TEST_LIBS gtest gtest_main jsoncpp json11)
|
||||||
|
|
||||||
if (Qt5Core_FOUND)
|
if (Qt5Core_FOUND)
|
||||||
list(APPEND TEST_LIBS Qt5::Core)
|
list(APPEND TEST_LIBS Qt5::Core)
|
||||||
target_compile_definitions(test_suite PRIVATE "VALIJSON_BUILD_QT_ADAPTERS")
|
target_compile_definitions(test_suite PRIVATE "VALIJSON_BUILD_QT_ADAPTERS")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(Poco_FOUND)
|
||||||
|
list(APPEND TEST_LIBS ${Poco_LIBRARIES})
|
||||||
|
target_compile_definitions(test_suite PRIVATE "VALIJSON_BUILD_POCO_ADAPTERS")
|
||||||
|
endif()
|
||||||
|
|
||||||
target_link_libraries(test_suite ${TEST_LIBS} ${Boost_LIBRARIES})
|
target_link_libraries(test_suite ${TEST_LIBS} ${Boost_LIBRARIES})
|
||||||
target_link_libraries(custom_schema ${Boost_LIBRARIES})
|
target_link_libraries(custom_schema ${Boost_LIBRARIES})
|
||||||
|
@ -26,6 +26,12 @@
|
|||||||
|
|
||||||
#endif // VALIJSON_BUILD_QT_ADAPTERS
|
#endif // VALIJSON_BUILD_QT_ADAPTERS
|
||||||
|
|
||||||
|
#ifdef VALIJSON_BUILD_POCO_ADAPTERS
|
||||||
|
#include <valijson/adapters/poco_json_adapter.hpp>
|
||||||
|
#include <valijson/utils/poco_json_utils.hpp>
|
||||||
|
|
||||||
|
#endif // VALIJSON_BUILD_POCO_ADAPTERS
|
||||||
|
|
||||||
#define TEST_DATA_DIR "../tests/data/documents/"
|
#define TEST_DATA_DIR "../tests/data/documents/"
|
||||||
|
|
||||||
using valijson::adapters::AdapterTraits;
|
using valijson::adapters::AdapterTraits;
|
||||||
@ -355,13 +361,6 @@ TEST_F(TestAdapterComparison, QtJsonVsQtJson) {
|
|||||||
valijson::adapters::QtJsonAdapter>();
|
valijson::adapters::QtJsonAdapter>();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TestAdapterComparison, QtJsonVsJson11)
|
|
||||||
{
|
|
||||||
testComparison<
|
|
||||||
valijson::adapters::QtJsonAdapter,
|
|
||||||
valijson::adapters::Json11Adapter>();
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(TestAdapterComparison, QtJsonVsJsonCpp)
|
TEST_F(TestAdapterComparison, QtJsonVsJsonCpp)
|
||||||
{
|
{
|
||||||
testComparison<
|
testComparison<
|
||||||
@ -369,7 +368,6 @@ TEST_F(TestAdapterComparison, QtJsonVsJsonCpp)
|
|||||||
valijson::adapters::JsonCppAdapter>();
|
valijson::adapters::JsonCppAdapter>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST_F(TestAdapterComparison, QtJsonVsRapidJson)
|
TEST_F(TestAdapterComparison, QtJsonVsRapidJson)
|
||||||
{
|
{
|
||||||
testComparison<
|
testComparison<
|
||||||
@ -401,3 +399,98 @@ TEST_F(TestAdapterComparison, QtJsonVsPropertyTree)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif // VALIJSON_BUILD_QT_ADAPTERS
|
#endif // VALIJSON_BUILD_QT_ADAPTERS
|
||||||
|
|
||||||
|
#if defined(VALIJSON_BUILD_QT_ADAPTERS) && defined(VALIJSON_BUILD_CXX11_ADAPTERS)
|
||||||
|
|
||||||
|
TEST_F(TestAdapterComparison, QtJsonVsJson11)
|
||||||
|
{
|
||||||
|
testComparison<
|
||||||
|
valijson::adapters::QtJsonAdapter,
|
||||||
|
valijson::adapters::Json11Adapter>();
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(TestAdapterComparison, QtJsonVsNlohmannJson)
|
||||||
|
{
|
||||||
|
testComparison<
|
||||||
|
valijson::adapters::QtJsonAdapter,
|
||||||
|
valijson::adapters::NlohmannJsonAdapter>();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef VALIJSON_BUILD_POCO_ADAPTERS
|
||||||
|
|
||||||
|
TEST_F(TestAdapterComparison, PocoJsonVsPocoJson)
|
||||||
|
{
|
||||||
|
testComparison<
|
||||||
|
valijson::adapters::PocoJsonAdapter,
|
||||||
|
valijson::adapters::PocoJsonAdapter>();
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(TestAdapterComparison, PocoJsonVsJsonCpp)
|
||||||
|
{
|
||||||
|
testComparison<
|
||||||
|
valijson::adapters::PocoJsonAdapter,
|
||||||
|
valijson::adapters::JsonCppAdapter>();
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(TestAdapterComparison, PocoJsonVsRapidJson)
|
||||||
|
{
|
||||||
|
testComparison<
|
||||||
|
valijson::adapters::PocoJsonAdapter,
|
||||||
|
valijson::adapters::RapidJsonAdapter>();
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(TestAdapterComparison, PocoJsonVsRapidJsonCrtAlloc)
|
||||||
|
{
|
||||||
|
testComparison<
|
||||||
|
valijson::adapters::PocoJsonAdapter,
|
||||||
|
valijson::adapters::GenericRapidJsonAdapter<
|
||||||
|
rapidjson::GenericValue<rapidjson::UTF8<>,
|
||||||
|
rapidjson::CrtAllocator> > >();
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(TestAdapterComparison, PocoJsonVsPicoJson)
|
||||||
|
{
|
||||||
|
testComparison<
|
||||||
|
valijson::adapters::PocoJsonAdapter,
|
||||||
|
valijson::adapters::PicoJsonAdapter>();
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(TestAdapterComparison, PocoJsonVsPropertyTree)
|
||||||
|
{
|
||||||
|
testComparison<
|
||||||
|
valijson::adapters::PocoJsonAdapter,
|
||||||
|
valijson::adapters::PropertyTreeAdapter>();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(VALIJSON_BUILD_POCO_ADAPTERS) && defined(VALIJSON_BUILD_CXX11_ADAPTERS)
|
||||||
|
|
||||||
|
TEST_F(TestAdapterComparison, PocoJsonVsJson11)
|
||||||
|
{
|
||||||
|
testComparison<
|
||||||
|
valijson::adapters::PocoJsonAdapter,
|
||||||
|
valijson::adapters::Json11Adapter>();
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(TestAdapterComparison, PocoJsonVsNlohmannJsonAdapter)
|
||||||
|
{
|
||||||
|
testComparison<
|
||||||
|
valijson::adapters::PocoJsonAdapter,
|
||||||
|
valijson::adapters::NlohmannJsonAdapter>();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(VALIJSON_BUILD_POCO_ADAPTERS) && defined(VALIJSON_BUILD_QT_ADAPTERS)
|
||||||
|
|
||||||
|
TEST_F(TestAdapterComparison, PocoJsonVsQtJson)
|
||||||
|
{
|
||||||
|
testComparison<
|
||||||
|
valijson::adapters::PocoJsonAdapter,
|
||||||
|
valijson::adapters::QtJsonAdapter>();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user