diff --git a/.travis.yml b/.travis.yml index 84773e8..917bcbf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ matrix: addons: apt: sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-5', 'qtbase5-dev'] + packages: ['g++-5', 'qtbase5-dev', 'libpoco-dev'] env: - CXX_COMPILER=g++-5 - C_COMPILER=gcc-5 @@ -19,7 +19,7 @@ matrix: addons: apt: 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: - CXX_COMPILER=clang++-3.6 - C_COMPILER=clang-3.6 @@ -30,7 +30,7 @@ matrix: addons: apt: 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: - CXX_COMPILER=clang++-3.7 - C_COMPILER=clang-3.7 @@ -41,7 +41,7 @@ matrix: addons: apt: 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: - CXX_COMPILER=clang++-3.8 - C_COMPILER=clang-3.8 diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f39093..ea22309 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,9 +22,9 @@ set(Boost_USE_MULTITHREADED ON) set(Boost_USE_STATIC_RUNTIME OFF) find_package(Boost 1.54.0 REQUIRED) +find_package(Poco OPTIONAL_COMPONENTS JSON) find_package(Qt5Core) - # jsoncpp library add_library(jsoncpp 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_rapidjson_adapter.cpp tests/test_picojson_adapter.cpp + tests/test_poco_json_adapter.cpp tests/test_validation_errors.cpp tests/test_validator.cpp tests/test_poly_constraint.cpp @@ -110,11 +111,16 @@ set_target_properties(test_suite ) set(TEST_LIBS gtest gtest_main jsoncpp json11) + if (Qt5Core_FOUND) list(APPEND TEST_LIBS Qt5::Core) target_compile_definitions(test_suite PRIVATE "VALIJSON_BUILD_QT_ADAPTERS") 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(custom_schema ${Boost_LIBRARIES}) diff --git a/tests/test_adapter_comparison.cpp b/tests/test_adapter_comparison.cpp index 5e73bfe..7e0b251 100644 --- a/tests/test_adapter_comparison.cpp +++ b/tests/test_adapter_comparison.cpp @@ -26,6 +26,12 @@ #endif // VALIJSON_BUILD_QT_ADAPTERS +#ifdef VALIJSON_BUILD_POCO_ADAPTERS +#include +#include + +#endif // VALIJSON_BUILD_POCO_ADAPTERS + #define TEST_DATA_DIR "../tests/data/documents/" using valijson::adapters::AdapterTraits; @@ -355,13 +361,6 @@ TEST_F(TestAdapterComparison, QtJsonVsQtJson) { valijson::adapters::QtJsonAdapter>(); } -TEST_F(TestAdapterComparison, QtJsonVsJson11) -{ - testComparison< - valijson::adapters::QtJsonAdapter, - valijson::adapters::Json11Adapter>(); -} - TEST_F(TestAdapterComparison, QtJsonVsJsonCpp) { testComparison< @@ -369,7 +368,6 @@ TEST_F(TestAdapterComparison, QtJsonVsJsonCpp) valijson::adapters::JsonCppAdapter>(); } - TEST_F(TestAdapterComparison, QtJsonVsRapidJson) { testComparison< @@ -401,3 +399,98 @@ TEST_F(TestAdapterComparison, QtJsonVsPropertyTree) } #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::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