mirror of
https://github.com/tristanpenman/valijson.git
synced 2025-03-03 12:58:03 +01:00
Merge remote-tracking branch 'origin/master' into v6-and-v7-support
This commit is contained in:
commit
c8dfd94035
@ -61,7 +61,7 @@ include_directories(include SYSTEM
|
|||||||
|
|
||||||
if(valijson_BUILD_TESTS)
|
if(valijson_BUILD_TESTS)
|
||||||
if(NOT valijson_EXCLUDE_BOOST)
|
if(NOT valijson_EXCLUDE_BOOST)
|
||||||
find_package(Boost 1.54.0)
|
find_package(Boost)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Build local gtest
|
# Build local gtest
|
||||||
@ -77,22 +77,11 @@ if(valijson_BUILD_TESTS)
|
|||||||
tests/test_nlohmann_json_adapter.cpp
|
tests/test_nlohmann_json_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_poly_constraint.cpp
|
tests/test_poly_constraint.cpp
|
||||||
tests/test_validation_errors.cpp
|
tests/test_validation_errors.cpp
|
||||||
tests/test_validator.cpp
|
tests/test_validator.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if(Qt5Core_FOUND)
|
|
||||||
include_directories(${Qt5Core_INCLUDE_DIRS})
|
|
||||||
list(APPEND TEST_SOURCES tests/test_qtjson_adapter.cpp)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(Boost_FOUND)
|
|
||||||
include_directories(${Boost_INCLUDE_DIRS})
|
|
||||||
list(APPEND TEST_SOURCES tests/test_property_tree_adapter.cpp)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Unit tests executable
|
# Unit tests executable
|
||||||
add_executable(test_suite ${TEST_SOURCES})
|
add_executable(test_suite ${TEST_SOURCES})
|
||||||
|
|
||||||
@ -102,20 +91,27 @@ if(valijson_BUILD_TESTS)
|
|||||||
set(TEST_LIBS gtest gtest_main jsoncpp json11)
|
set(TEST_LIBS gtest gtest_main jsoncpp json11)
|
||||||
|
|
||||||
if(Boost_FOUND)
|
if(Boost_FOUND)
|
||||||
|
include_directories(${Boost_INCLUDE_DIRS})
|
||||||
|
list(APPEND TEST_SOURCES tests/test_property_tree_adapter.cpp)
|
||||||
add_definitions(-DBOOST_ALL_DYN_LINK)
|
add_definitions(-DBOOST_ALL_DYN_LINK)
|
||||||
set(Boost_USE_STATIC_LIBS OFF)
|
set(Boost_USE_STATIC_LIBS OFF)
|
||||||
set(Boost_USE_MULTITHREADED ON)
|
set(Boost_USE_MULTITHREADED ON)
|
||||||
set(Boost_USE_STATIC_RUNTIME OFF)
|
set(Boost_USE_STATIC_RUNTIME OFF)
|
||||||
endif()
|
target_compile_definitions(test_suite PRIVATE "VALIJSON_BUILD_PROPERTY_TREE_ADAPTER")
|
||||||
|
|
||||||
if(Qt5Core_FOUND)
|
|
||||||
list(APPEND TEST_LIBS Qt5::Core)
|
|
||||||
target_compile_definitions(test_suite PRIVATE "VALIJSON_BUILD_QT_ADAPTERS")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(Poco_FOUND)
|
if(Poco_FOUND)
|
||||||
|
include_directories(${Poco_INCLUDE_DIRS})
|
||||||
|
list(APPEND TEST_SOURCES tests/test_poco_json_adapter.cpp)
|
||||||
list(APPEND TEST_LIBS ${Poco_Foundation_LIBRARIES} ${Poco_JSON_LIBRARIES})
|
list(APPEND TEST_LIBS ${Poco_Foundation_LIBRARIES} ${Poco_JSON_LIBRARIES})
|
||||||
target_compile_definitions(test_suite PRIVATE "VALIJSON_BUILD_POCO_ADAPTERS")
|
target_compile_definitions(test_suite PRIVATE "VALIJSON_BUILD_POCO_ADAPTER")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(Qt5Core_FOUND)
|
||||||
|
include_directories(${Qt5Core_INCLUDE_DIRS})
|
||||||
|
list(APPEND TEST_SOURCES tests/test_qtjson_adapter.cpp)
|
||||||
|
list(APPEND TEST_LIBS Qt5::Core)
|
||||||
|
target_compile_definitions(test_suite PRIVATE "VALIJSON_BUILD_QT_ADAPTER")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(test_suite ${TEST_LIBS} ${Boost_LIBRARIES})
|
target_link_libraries(test_suite ${TEST_LIBS} ${Boost_LIBRARIES})
|
||||||
|
@ -993,21 +993,21 @@ namespace std{
|
|||||||
{
|
{
|
||||||
x.swap(y);
|
x.swap(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
constexpr optional<typename decay<T>::type> make_optional(T&& v)
|
constexpr optional<typename decay<T>::type> make_optional(T&& v)
|
||||||
{
|
{
|
||||||
return optional<typename decay<T>::type>(constexpr_forward<T>(v));
|
return optional<typename decay<T>::type>(constexpr_forward<T>(v));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class X>
|
template <class X>
|
||||||
constexpr optional<X&> make_optional(reference_wrapper<X> v)
|
constexpr optional<X&> make_optional(reference_wrapper<X> v)
|
||||||
{
|
{
|
||||||
return optional<X&>(v.get());
|
return optional<X&>(v.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace experimental
|
} // namespace experimental
|
||||||
} // namespace std
|
} // namespace std
|
||||||
|
|
||||||
@ -1018,18 +1018,18 @@ namespace std
|
|||||||
{
|
{
|
||||||
typedef typename hash<T>::result_type result_type;
|
typedef typename hash<T>::result_type result_type;
|
||||||
typedef std::experimental::optional<T> argument_type;
|
typedef std::experimental::optional<T> argument_type;
|
||||||
|
|
||||||
constexpr result_type operator()(argument_type const& arg) const {
|
constexpr result_type operator()(argument_type const& arg) const {
|
||||||
return arg ? std::hash<T>{}(*arg) : result_type{};
|
return arg ? std::hash<T>{}(*arg) : result_type{};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct hash<std::experimental::optional<T&>>
|
struct hash<std::experimental::optional<T&>>
|
||||||
{
|
{
|
||||||
typedef typename hash<T>::result_type result_type;
|
typedef typename hash<T>::result_type result_type;
|
||||||
typedef std::experimental::optional<T&> argument_type;
|
typedef std::experimental::optional<T&> argument_type;
|
||||||
|
|
||||||
constexpr result_type operator()(argument_type const& arg) const {
|
constexpr result_type operator()(argument_type const& arg) const {
|
||||||
return arg ? std::hash<T>{}(*arg) : result_type{};
|
return arg ? std::hash<T>{}(*arg) : result_type{};
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -24,8 +24,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#ifndef __VALIJSON_ADAPTERS_QTJSON_ADAPTER_HPP
|
|
||||||
#define __VALIJSON_ADAPTERS_QTJSON_ADAPTER_HPP
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@ -33,7 +31,6 @@
|
|||||||
#include <QJsonValue>
|
#include <QJsonValue>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
|
|
||||||
|
|
||||||
#include <valijson/adapters/adapter.hpp>
|
#include <valijson/adapters/adapter.hpp>
|
||||||
#include <valijson/adapters/basic_adapter.hpp>
|
#include <valijson/adapters/basic_adapter.hpp>
|
||||||
#include <valijson/adapters/frozen_value.hpp>
|
#include <valijson/adapters/frozen_value.hpp>
|
||||||
@ -721,5 +718,3 @@ inline QtJsonObjectMemberIterator QtJsonObject::find(
|
|||||||
|
|
||||||
} // namespace adapters
|
} // namespace adapters
|
||||||
} // namespace valijson
|
} // namespace valijson
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@ -48,4 +48,3 @@ struct Constraint
|
|||||||
|
|
||||||
} // namespace constraints
|
} // namespace constraints
|
||||||
} // namespace valijson
|
} // namespace valijson
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ class ConstraintVisitor
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
virtual ~ConstraintVisitor() {}
|
virtual ~ConstraintVisitor() {}
|
||||||
|
|
||||||
// Shorten type names for derived classes outside of this namespace
|
// Shorten type names for derived classes outside of this namespace
|
||||||
typedef constraints::AllOfConstraint AllOfConstraint;
|
typedef constraints::AllOfConstraint AllOfConstraint;
|
||||||
typedef constraints::AnyOfConstraint AnyOfConstraint;
|
typedef constraints::AnyOfConstraint AnyOfConstraint;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#ifndef __VALIJSON_DEBUG_HPP
|
#pragma once
|
||||||
#define __VALIJSON_DEBUG_HPP
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@ -29,5 +28,3 @@ std::string nodeTypeAsString(const AdapterType &node) {
|
|||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
} // end namespace valijson
|
} // end namespace valijson
|
||||||
|
|
||||||
#endif
|
|
@ -9,52 +9,51 @@ namespace valijson {
|
|||||||
namespace internal {
|
namespace internal {
|
||||||
namespace json_reference {
|
namespace json_reference {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Extract URI from JSON Reference relative to the current schema
|
* @brief Extract URI from JSON Reference relative to the current schema
|
||||||
*
|
*
|
||||||
* @param jsonRef JSON Reference to extract from
|
* @param jsonRef JSON Reference to extract from
|
||||||
* @param schema Schema that JSON Reference URI is relative to
|
* @param schema Schema that JSON Reference URI is relative to
|
||||||
*
|
*
|
||||||
* @return Optional string containing URI
|
* @return Optional string containing URI
|
||||||
*/
|
*/
|
||||||
inline opt::optional<std::string> getJsonReferenceUri(
|
inline opt::optional<std::string> getJsonReferenceUri(
|
||||||
const std::string &jsonRef)
|
const std::string &jsonRef)
|
||||||
{
|
{
|
||||||
const size_t ptrPos = jsonRef.find("#");
|
const size_t ptrPos = jsonRef.find("#");
|
||||||
if (ptrPos == 0) {
|
if (ptrPos == 0) {
|
||||||
// The JSON Reference does not contain a URI, but might contain a
|
// The JSON Reference does not contain a URI, but might contain a
|
||||||
// JSON Pointer that refers to the current document
|
// JSON Pointer that refers to the current document
|
||||||
return opt::optional<std::string>();
|
|
||||||
} else if (ptrPos != std::string::npos) {
|
|
||||||
// The JSON Reference contains a URI and possibly a JSON Pointer
|
|
||||||
return jsonRef.substr(0, ptrPos);
|
|
||||||
}
|
|
||||||
|
|
||||||
// The entire JSON Reference should be treated as a URI
|
|
||||||
return jsonRef;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Extract JSON Pointer portion of a JSON Reference
|
|
||||||
*
|
|
||||||
* @param jsonRef JSON Reference to extract from
|
|
||||||
*
|
|
||||||
* @return Optional string containing JSON Pointer
|
|
||||||
*/
|
|
||||||
inline opt::optional<std::string> getJsonReferencePointer(
|
|
||||||
const std::string &jsonRef)
|
|
||||||
{
|
|
||||||
// Attempt to extract JSON Pointer if '#' character is present. Note
|
|
||||||
// that a valid pointer would contain at least a leading forward
|
|
||||||
// slash character.
|
|
||||||
const size_t ptrPos = jsonRef.find("#");
|
|
||||||
if (ptrPos != std::string::npos) {
|
|
||||||
return jsonRef.substr(ptrPos + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return opt::optional<std::string>();
|
return opt::optional<std::string>();
|
||||||
|
} else if (ptrPos != std::string::npos) {
|
||||||
|
// The JSON Reference contains a URI and possibly a JSON Pointer
|
||||||
|
return jsonRef.substr(0, ptrPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The entire JSON Reference should be treated as a URI
|
||||||
|
return jsonRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Extract JSON Pointer portion of a JSON Reference
|
||||||
|
*
|
||||||
|
* @param jsonRef JSON Reference to extract from
|
||||||
|
*
|
||||||
|
* @return Optional string containing JSON Pointer
|
||||||
|
*/
|
||||||
|
inline opt::optional<std::string> getJsonReferencePointer(
|
||||||
|
const std::string &jsonRef)
|
||||||
|
{
|
||||||
|
// Attempt to extract JSON Pointer if '#' character is present. Note
|
||||||
|
// that a valid pointer would contain at least a leading forward
|
||||||
|
// slash character.
|
||||||
|
const size_t ptrPos = jsonRef.find("#");
|
||||||
|
if (ptrPos != std::string::npos) {
|
||||||
|
return jsonRef.substr(ptrPos + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return opt::optional<std::string>();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace json_reference
|
} // namespace json_reference
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#ifndef __VALIJSON_OPTIONAL_HPP
|
|
||||||
#define __VALIJSON_OPTIONAL_HPP
|
|
||||||
|
|
||||||
#if __cplusplus >= 201703
|
#if __cplusplus >= 201703
|
||||||
// Visual C++ only supports __has_include in versions 14.12 and greater
|
// Visual C++ only supports __has_include in versions 14.12 and greater
|
||||||
@ -14,5 +12,3 @@ namespace opt = std;
|
|||||||
# include <compat/optional.hpp>
|
# include <compat/optional.hpp>
|
||||||
namespace opt = std::experimental;
|
namespace opt = std::experimental;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@ -6,27 +6,27 @@ namespace valijson {
|
|||||||
namespace internal {
|
namespace internal {
|
||||||
namespace uri {
|
namespace uri {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Placeholder function to check whether a URI is absolute
|
* @brief Placeholder function to check whether a URI is absolute
|
||||||
*
|
*
|
||||||
* This function just checks for '://'
|
* This function just checks for '://'
|
||||||
*/
|
*/
|
||||||
inline bool isUriAbsolute(const std::string &documentUri)
|
inline bool isUriAbsolute(const std::string &documentUri)
|
||||||
{
|
{
|
||||||
static const char * placeholderMarker = "://";
|
static const char * placeholderMarker = "://";
|
||||||
|
|
||||||
return documentUri.find(placeholderMarker) != std::string::npos;
|
return documentUri.find(placeholderMarker) != std::string::npos;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Placeholder function to resolve a relative URI within a given scope
|
* Placeholder function to resolve a relative URI within a given scope
|
||||||
*/
|
*/
|
||||||
inline std::string resolveRelativeUri(
|
inline std::string resolveRelativeUri(
|
||||||
const std::string &resolutionScope,
|
const std::string &resolutionScope,
|
||||||
const std::string &relativeUri)
|
const std::string &relativeUri)
|
||||||
{
|
{
|
||||||
return resolutionScope + relativeUri;
|
return resolutionScope + relativeUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace uri
|
} // namespace uri
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
@ -15,7 +15,7 @@ namespace valijson {
|
|||||||
* While all JSON Schemas have at least one sub-schema, the root, some will
|
* While all JSON Schemas have at least one sub-schema, the root, some will
|
||||||
* have additional sub-schemas that are defined as part of constraints that are
|
* have additional sub-schemas that are defined as part of constraints that are
|
||||||
* included in the schema. For example, a 'oneOf' constraint maintains a set of
|
* included in the schema. For example, a 'oneOf' constraint maintains a set of
|
||||||
* references to one or more nested sub-schemas. As per the definition of a
|
* references to one or more nested sub-schemas. As per the definition of a
|
||||||
* oneOf constraint, a document is valid within that constraint if it validates
|
* oneOf constraint, a document is valid within that constraint if it validates
|
||||||
* against one of the nested sub-schemas.
|
* against one of the nested sub-schemas.
|
||||||
*/
|
*/
|
||||||
@ -242,7 +242,7 @@ public:
|
|||||||
*
|
*
|
||||||
* The title will not be used for validation, but may be used as part
|
* The title will not be used for validation, but may be used as part
|
||||||
* of the user interface for interacting with schemas and sub-schema. As an
|
* of the user interface for interacting with schemas and sub-schema. As an
|
||||||
* example, it may be used as part of the validation error descriptions
|
* example, it may be used as part of the validation error descriptions
|
||||||
* that are produced by the Validator and ValidationVisitor classes.
|
* that are produced by the Validator and ValidationVisitor classes.
|
||||||
*
|
*
|
||||||
* @param title new title
|
* @param title new title
|
||||||
|
@ -8,7 +8,8 @@
|
|||||||
namespace valijson {
|
namespace valijson {
|
||||||
namespace utils {
|
namespace utils {
|
||||||
|
|
||||||
inline bool loadDocument(const std::string &path, nlohmann::json &document) {
|
inline bool loadDocument(const std::string &path, nlohmann::json &document)
|
||||||
|
{
|
||||||
// Load schema JSON from file
|
// Load schema JSON from file
|
||||||
std::string file;
|
std::string file;
|
||||||
if (!loadFile(path, file)) {
|
if (!loadFile(path, file)) {
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#ifndef VALIJSON_POCO_JSON_UTILS_HPP
|
|
||||||
#define VALIJSON_POCO_JSON_UTILS_HPP
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@ -13,7 +11,8 @@
|
|||||||
namespace valijson {
|
namespace valijson {
|
||||||
namespace utils {
|
namespace utils {
|
||||||
|
|
||||||
inline bool loadDocument(const std::string &path, Poco::Dynamic::Var &document) {
|
inline bool loadDocument(const std::string &path, Poco::Dynamic::Var &document)
|
||||||
|
{
|
||||||
// Load schema JSON from file
|
// Load schema JSON from file
|
||||||
std::string file;
|
std::string file;
|
||||||
if (!loadFile(path, file)) {
|
if (!loadFile(path, file)) {
|
||||||
@ -36,5 +35,3 @@ inline bool loadDocument(const std::string &path, Poco::Dynamic::Var &document)
|
|||||||
|
|
||||||
} // namespace utils
|
} // namespace utils
|
||||||
} // namespace valijson
|
} // namespace valijson
|
||||||
|
|
||||||
#endif //VALIJSON_POCO_JSON_UTILS_HPP
|
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#ifndef __VALIJSON_UTILS_QTJSON_UTILS_HPP
|
|
||||||
#define __VALIJSON_UTILS_QTJSON_UTILS_HPP
|
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
|
||||||
@ -44,5 +42,3 @@ inline bool loadDocument(const std::string &path, QJsonValue &root)
|
|||||||
|
|
||||||
} // namespace utils
|
} // namespace utils
|
||||||
} // namespace valijson
|
} // namespace valijson
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@ -244,7 +244,7 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Validate a value against a LinearItemsConstraint
|
* @brief Validate a value against a LinearItemsConstraint
|
||||||
|
*
|
||||||
* A LinearItemsConstraint represents an 'items' constraint that specifies,
|
* A LinearItemsConstraint represents an 'items' constraint that specifies,
|
||||||
* for each item in array, an individual sub-schema that the item must
|
* for each item in array, an individual sub-schema that the item must
|
||||||
* validate against. The LinearItemsConstraint class also captures the
|
* validate against. The LinearItemsConstraint class also captures the
|
||||||
|
@ -5,25 +5,29 @@
|
|||||||
#include <valijson/adapters/json11_adapter.hpp>
|
#include <valijson/adapters/json11_adapter.hpp>
|
||||||
#include <valijson/adapters/jsoncpp_adapter.hpp>
|
#include <valijson/adapters/jsoncpp_adapter.hpp>
|
||||||
#include <valijson/adapters/nlohmann_json_adapter.hpp>
|
#include <valijson/adapters/nlohmann_json_adapter.hpp>
|
||||||
#include <valijson/adapters/property_tree_adapter.hpp>
|
|
||||||
#include <valijson/adapters/rapidjson_adapter.hpp>
|
|
||||||
#include <valijson/adapters/picojson_adapter.hpp>
|
#include <valijson/adapters/picojson_adapter.hpp>
|
||||||
|
#include <valijson/adapters/rapidjson_adapter.hpp>
|
||||||
|
|
||||||
#include <valijson/utils/json11_utils.hpp>
|
#include <valijson/utils/json11_utils.hpp>
|
||||||
#include <valijson/utils/jsoncpp_utils.hpp>
|
#include <valijson/utils/jsoncpp_utils.hpp>
|
||||||
#include <valijson/utils/nlohmann_json_utils.hpp>
|
#include <valijson/utils/nlohmann_json_utils.hpp>
|
||||||
#include <valijson/utils/property_tree_utils.hpp>
|
|
||||||
#include <valijson/utils/rapidjson_utils.hpp>
|
|
||||||
#include <valijson/utils/picojson_utils.hpp>
|
#include <valijson/utils/picojson_utils.hpp>
|
||||||
|
#include <valijson/utils/rapidjson_utils.hpp>
|
||||||
|
|
||||||
#ifdef VALIJSON_BUILD_QT_ADAPTERS
|
#ifdef VALIJSON_BUILD_PROPERTY_TREE_ADAPTER
|
||||||
|
#include <valijson/adapters/property_tree_adapter.hpp>
|
||||||
|
#include <valijson/utils/property_tree_utils.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef VALIJSON_BUILD_QT_ADAPTER
|
||||||
#include <valijson/adapters/qtjson_adapter.hpp>
|
#include <valijson/adapters/qtjson_adapter.hpp>
|
||||||
#include <valijson/utils/qtjson_utils.hpp>
|
#include <valijson/utils/qtjson_utils.hpp>
|
||||||
#endif // VALIJSON_BUILD_QT_ADAPTERS
|
#endif
|
||||||
|
|
||||||
#ifdef VALIJSON_BUILD_POCO_ADAPTERS
|
#ifdef VALIJSON_BUILD_POCO_ADAPTER
|
||||||
#include <valijson/adapters/poco_json_adapter.hpp>
|
#include <valijson/adapters/poco_json_adapter.hpp>
|
||||||
#include <valijson/utils/poco_json_utils.hpp>
|
#include <valijson/utils/poco_json_utils.hpp>
|
||||||
#endif // VALIJSON_BUILD_POCO_ADAPTERS
|
#endif
|
||||||
|
|
||||||
#define TEST_DATA_DIR "../tests/data/documents/"
|
#define TEST_DATA_DIR "../tests/data/documents/"
|
||||||
|
|
||||||
@ -129,6 +133,10 @@ protected:
|
|||||||
|
|
||||||
std::vector<TestAdapterComparison::JsonFile> TestAdapterComparison::jsonFiles;
|
std::vector<TestAdapterComparison::JsonFile> TestAdapterComparison::jsonFiles;
|
||||||
|
|
||||||
|
//
|
||||||
|
// JsonCppAdapter vs X
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
TEST_F(TestAdapterComparison, JsonCppVsJsonCpp)
|
TEST_F(TestAdapterComparison, JsonCppVsJsonCpp)
|
||||||
{
|
{
|
||||||
testComparison<
|
testComparison<
|
||||||
@ -143,6 +151,8 @@ TEST_F(TestAdapterComparison, JsonCppVsPicoJson)
|
|||||||
valijson::adapters::PicoJsonAdapter>();
|
valijson::adapters::PicoJsonAdapter>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef VALIJSON_BUILD_PROPERTY_TREE_ADAPTER
|
||||||
|
|
||||||
TEST_F(TestAdapterComparison, JsonCppVsPropertyTree)
|
TEST_F(TestAdapterComparison, JsonCppVsPropertyTree)
|
||||||
{
|
{
|
||||||
testComparison<
|
testComparison<
|
||||||
@ -150,6 +160,8 @@ TEST_F(TestAdapterComparison, JsonCppVsPropertyTree)
|
|||||||
valijson::adapters::PropertyTreeAdapter>();
|
valijson::adapters::PropertyTreeAdapter>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
TEST_F(TestAdapterComparison, JsonCppVsRapidJson)
|
TEST_F(TestAdapterComparison, JsonCppVsRapidJson)
|
||||||
{
|
{
|
||||||
testComparison<
|
testComparison<
|
||||||
@ -166,6 +178,12 @@ TEST_F(TestAdapterComparison, JsonCppVsRapidJsonCrtAlloc)
|
|||||||
rapidjson::CrtAllocator> > >();
|
rapidjson::CrtAllocator> > >();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// PropertyTreeAdapter vs X
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifdef VALIJSON_BUILD_PROPERTY_TREE_ADAPTER
|
||||||
|
|
||||||
TEST_F(TestAdapterComparison, PropertyTreeVsPicoJson)
|
TEST_F(TestAdapterComparison, PropertyTreeVsPicoJson)
|
||||||
{
|
{
|
||||||
testComparison<
|
testComparison<
|
||||||
@ -196,6 +214,12 @@ TEST_F(TestAdapterComparison, PropertyTreeVsRapidJsonCrtAlloc)
|
|||||||
rapidjson::CrtAllocator> > >();
|
rapidjson::CrtAllocator> > >();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//
|
||||||
|
// RapidJson vs X
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
TEST_F(TestAdapterComparison, RapidJsonVsRapidJson)
|
TEST_F(TestAdapterComparison, RapidJsonVsRapidJson)
|
||||||
{
|
{
|
||||||
testComparison<
|
testComparison<
|
||||||
@ -219,6 +243,10 @@ TEST_F(TestAdapterComparison, RapidJsonVsPicoJson)
|
|||||||
valijson::adapters::PicoJsonAdapter>();
|
valijson::adapters::PicoJsonAdapter>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// PicoJsonAdapter vs X
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
TEST_F(TestAdapterComparison, PicoJsonVsPicoJson)
|
TEST_F(TestAdapterComparison, PicoJsonVsPicoJson)
|
||||||
{
|
{
|
||||||
testComparison<
|
testComparison<
|
||||||
@ -246,6 +274,10 @@ TEST_F(TestAdapterComparison, RapidJsonCrtAllocVsRapidJsonCrtAlloc)
|
|||||||
rapidjson::CrtAllocator> > >();
|
rapidjson::CrtAllocator> > >();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Json11Adapter vs X
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
TEST_F(TestAdapterComparison, Json11VsJson11)
|
TEST_F(TestAdapterComparison, Json11VsJson11)
|
||||||
{
|
{
|
||||||
testComparison<
|
testComparison<
|
||||||
@ -284,6 +316,8 @@ TEST_F(TestAdapterComparison, Json11VsPicoJson)
|
|||||||
valijson::adapters::PicoJsonAdapter>();
|
valijson::adapters::PicoJsonAdapter>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef VALIJSON_BUILD_PROPERTY_TREE_ADAPTER
|
||||||
|
|
||||||
TEST_F(TestAdapterComparison, Json11VsPropertyTree)
|
TEST_F(TestAdapterComparison, Json11VsPropertyTree)
|
||||||
{
|
{
|
||||||
testComparison<
|
testComparison<
|
||||||
@ -291,6 +325,12 @@ TEST_F(TestAdapterComparison, Json11VsPropertyTree)
|
|||||||
valijson::adapters::PropertyTreeAdapter>();
|
valijson::adapters::PropertyTreeAdapter>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // VALIJSON_BUILD_PROPERTY_TREE_ADAPTER
|
||||||
|
|
||||||
|
//
|
||||||
|
// NlohmannJsonAdapter vs X
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
TEST_F(TestAdapterComparison, NlohmannJsonVsNlohmannJson) {
|
TEST_F(TestAdapterComparison, NlohmannJsonVsNlohmannJson) {
|
||||||
testComparison<
|
testComparison<
|
||||||
valijson::adapters::NlohmannJsonAdapter,
|
valijson::adapters::NlohmannJsonAdapter,
|
||||||
@ -335,6 +375,8 @@ TEST_F(TestAdapterComparison, NlohmannJsonVsPicoJson)
|
|||||||
valijson::adapters::PicoJsonAdapter>();
|
valijson::adapters::PicoJsonAdapter>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef VALIJSON_BUILD_PROPERTY_TREE_ADAPTER
|
||||||
|
|
||||||
TEST_F(TestAdapterComparison, NlohmannJsonVsPropertyTree)
|
TEST_F(TestAdapterComparison, NlohmannJsonVsPropertyTree)
|
||||||
{
|
{
|
||||||
testComparison<
|
testComparison<
|
||||||
@ -342,7 +384,13 @@ TEST_F(TestAdapterComparison, NlohmannJsonVsPropertyTree)
|
|||||||
valijson::adapters::PropertyTreeAdapter>();
|
valijson::adapters::PropertyTreeAdapter>();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VALIJSON_BUILD_QT_ADAPTERS
|
#endif // VALIJSON_BUILD_PROPERTY_TREE_ADAPTER
|
||||||
|
|
||||||
|
//
|
||||||
|
// QtJsonAdapter vs X
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifdef VALIJSON_BUILD_QT_ADAPTER
|
||||||
|
|
||||||
TEST_F(TestAdapterComparison, QtJsonVsQtJson) {
|
TEST_F(TestAdapterComparison, QtJsonVsQtJson) {
|
||||||
testComparison<
|
testComparison<
|
||||||
@ -380,6 +428,8 @@ TEST_F(TestAdapterComparison, QtJsonVsPicoJson)
|
|||||||
valijson::adapters::PicoJsonAdapter>();
|
valijson::adapters::PicoJsonAdapter>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef VALIJSON_BUILD_PROPERTY_TREE_ADAPTER
|
||||||
|
|
||||||
TEST_F(TestAdapterComparison, QtJsonVsPropertyTree)
|
TEST_F(TestAdapterComparison, QtJsonVsPropertyTree)
|
||||||
{
|
{
|
||||||
testComparison<
|
testComparison<
|
||||||
@ -387,9 +437,7 @@ TEST_F(TestAdapterComparison, QtJsonVsPropertyTree)
|
|||||||
valijson::adapters::PropertyTreeAdapter>();
|
valijson::adapters::PropertyTreeAdapter>();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // VALIJSON_BUILD_QT_ADAPTERS
|
#endif // VALIJSON_BUILD_PROPERTY_TREE_ADAPTER
|
||||||
|
|
||||||
#if defined(VALIJSON_BUILD_QT_ADAPTERS)
|
|
||||||
|
|
||||||
TEST_F(TestAdapterComparison, QtJsonVsJson11)
|
TEST_F(TestAdapterComparison, QtJsonVsJson11)
|
||||||
{
|
{
|
||||||
@ -405,9 +453,13 @@ TEST_F(TestAdapterComparison, QtJsonVsNlohmannJson)
|
|||||||
valijson::adapters::NlohmannJsonAdapter>();
|
valijson::adapters::NlohmannJsonAdapter>();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif // VALIJSON_BUILD_QT_ADAPTER
|
||||||
|
|
||||||
#ifdef VALIJSON_BUILD_POCO_ADAPTERS
|
//
|
||||||
|
// PocoJsonAdapter vs X
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifdef VALIJSON_BUILD_POCO_ADAPTER
|
||||||
|
|
||||||
TEST_F(TestAdapterComparison, PocoJsonVsPocoJson)
|
TEST_F(TestAdapterComparison, PocoJsonVsPocoJson)
|
||||||
{
|
{
|
||||||
@ -446,6 +498,8 @@ TEST_F(TestAdapterComparison, PocoJsonVsPicoJson)
|
|||||||
valijson::adapters::PicoJsonAdapter>();
|
valijson::adapters::PicoJsonAdapter>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef VALIJSON_BUILD_PROPERTY_TREE_ADAPTER
|
||||||
|
|
||||||
TEST_F(TestAdapterComparison, PocoJsonVsPropertyTree)
|
TEST_F(TestAdapterComparison, PocoJsonVsPropertyTree)
|
||||||
{
|
{
|
||||||
testComparison<
|
testComparison<
|
||||||
@ -453,9 +507,7 @@ TEST_F(TestAdapterComparison, PocoJsonVsPropertyTree)
|
|||||||
valijson::adapters::PropertyTreeAdapter>();
|
valijson::adapters::PropertyTreeAdapter>();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif // VALIJSON_BUILD_PROPERTY_TREE_ADAPTER
|
||||||
|
|
||||||
#if defined(VALIJSON_BUILD_POCO_ADAPTERS)
|
|
||||||
|
|
||||||
TEST_F(TestAdapterComparison, PocoJsonVsJson11)
|
TEST_F(TestAdapterComparison, PocoJsonVsJson11)
|
||||||
{
|
{
|
||||||
@ -471,9 +523,7 @@ TEST_F(TestAdapterComparison, PocoJsonVsNlohmannJsonAdapter)
|
|||||||
valijson::adapters::NlohmannJsonAdapter>();
|
valijson::adapters::NlohmannJsonAdapter>();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#ifdef VALIJSON_BUILD_QT_ADAPTER
|
||||||
|
|
||||||
#if defined(VALIJSON_BUILD_POCO_ADAPTERS) && defined(VALIJSON_BUILD_QT_ADAPTERS)
|
|
||||||
|
|
||||||
TEST_F(TestAdapterComparison, PocoJsonVsQtJson)
|
TEST_F(TestAdapterComparison, PocoJsonVsQtJson)
|
||||||
{
|
{
|
||||||
@ -482,4 +532,6 @@ TEST_F(TestAdapterComparison, PocoJsonVsQtJson)
|
|||||||
valijson::adapters::QtJsonAdapter>();
|
valijson::adapters::QtJsonAdapter>();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif // VALIJSON_BUILD_QT_ADAPTER
|
||||||
|
|
||||||
|
#endif // VALIJSON_BUILD_POCO_ADAPTER
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
#ifdef VALIJSON_BUILD_POCO_ADAPTERS
|
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include <valijson/adapters/poco_json_adapter.hpp>
|
#include <valijson/adapters/poco_json_adapter.hpp>
|
||||||
@ -15,7 +13,7 @@ TEST_F(TestPocoJsonAdapter, BasicArrayIteration)
|
|||||||
|
|
||||||
// Create a Json document that consists of an array of numbers
|
// Create a Json document that consists of an array of numbers
|
||||||
Poco::JSON::Array::Ptr documentImpl = new Poco::JSON::Array();
|
Poco::JSON::Array::Ptr documentImpl = new Poco::JSON::Array();
|
||||||
|
|
||||||
for (unsigned int i = 0; i < numElements; i++) {
|
for (unsigned int i = 0; i < numElements; i++) {
|
||||||
documentImpl->set(i, static_cast<double>(i));
|
documentImpl->set(i, static_cast<double>(i));
|
||||||
}
|
}
|
||||||
@ -84,6 +82,3 @@ TEST_F(TestPocoJsonAdapter, BasicObjectIteration)
|
|||||||
// Ensure that the correct number of elements were iterated over
|
// Ensure that the correct number of elements were iterated over
|
||||||
EXPECT_EQ( numElements, expectedValue );
|
EXPECT_EQ( numElements, expectedValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // VALIJSON_BUILD_POCO_ADAPTERS
|
|
||||||
|
|
||||||
|
@ -10,17 +10,17 @@
|
|||||||
#include <valijson/adapters/picojson_adapter.hpp>
|
#include <valijson/adapters/picojson_adapter.hpp>
|
||||||
#include <valijson/utils/json11_utils.hpp>
|
#include <valijson/utils/json11_utils.hpp>
|
||||||
#include <valijson/utils/jsoncpp_utils.hpp>
|
#include <valijson/utils/jsoncpp_utils.hpp>
|
||||||
#include <valijson/utils/rapidjson_utils.hpp>
|
|
||||||
#include <valijson/utils/picojson_utils.hpp>
|
#include <valijson/utils/picojson_utils.hpp>
|
||||||
|
#include <valijson/utils/rapidjson_utils.hpp>
|
||||||
#include <valijson/schema.hpp>
|
#include <valijson/schema.hpp>
|
||||||
#include <valijson/schema_parser.hpp>
|
#include <valijson/schema_parser.hpp>
|
||||||
#include <valijson/validation_results.hpp>
|
#include <valijson/validation_results.hpp>
|
||||||
#include <valijson/validator.hpp>
|
#include <valijson/validator.hpp>
|
||||||
|
|
||||||
#ifdef VALIJSON_BUILD_POCO_ADAPTERS
|
#ifdef VALIJSON_BUILD_POCO_ADAPTER
|
||||||
#include <valijson/adapters/poco_json_adapter.hpp>
|
#include <valijson/adapters/poco_json_adapter.hpp>
|
||||||
#include <valijson/utils/poco_json_utils.hpp>
|
#include <valijson/utils/poco_json_utils.hpp>
|
||||||
#endif // VALIJSON_BUILD_POCO_ADAPTERS
|
#endif
|
||||||
|
|
||||||
#define REMOTES_DIR "../thirdparty/JSON-Schema-Test-Suite/remotes/"
|
#define REMOTES_DIR "../thirdparty/JSON-Schema-Test-Suite/remotes/"
|
||||||
|
|
||||||
@ -169,9 +169,9 @@ protected:
|
|||||||
processTestFile<valijson::adapters::RapidJsonAdapter>(testFile, version);
|
processTestFile<valijson::adapters::RapidJsonAdapter>(testFile, version);
|
||||||
processTestFile<valijson::adapters::PicoJsonAdapter>(testFile, version);
|
processTestFile<valijson::adapters::PicoJsonAdapter>(testFile, version);
|
||||||
|
|
||||||
#ifdef VALIJSON_BUILD_POCO_ADAPTERS
|
#ifdef VALIJSON_BUILD_POCO_ADAPTER
|
||||||
processTestFile<valijson::adapters::PocoJsonAdapter>(testFile, version);
|
processTestFile<valijson::adapters::PocoJsonAdapter>(testFile, version);
|
||||||
#endif // VALIJSON_BUILD_POCO_ADAPTERS
|
#endif // VALIJSON_BUILD_POCO_ADAPTER
|
||||||
}
|
}
|
||||||
|
|
||||||
void processDraft3TestFile(const std::string &testFile)
|
void processDraft3TestFile(const std::string &testFile)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user