mirror of
https://github.com/tristanpenman/valijson.git
synced 2025-03-03 12:58:03 +01:00
Minor tweaks for consistency with coding style
This commit is contained in:
parent
3d3f76df10
commit
29721d5538
2
Authors
2
Authors
@ -20,4 +20,4 @@ Richard Clamp, richardc@unixbeard.net
|
|||||||
Boost-related fixes
|
Boost-related fixes
|
||||||
|
|
||||||
Lars Immisch, lars@ibp.de
|
Lars Immisch, lars@ibp.de
|
||||||
noboost branch
|
noboost branch
|
||||||
|
@ -210,7 +210,7 @@ int main(int argc, char *argv[])
|
|||||||
while (results.popError(error)) {
|
while (results.popError(error)) {
|
||||||
cerr << "Error #" << errorNum << std::endl;
|
cerr << "Error #" << errorNum << std::endl;
|
||||||
cerr << " ";
|
cerr << " ";
|
||||||
for( const std::string contextElement : error.context ) {
|
for (const std::string &contextElement : error.context) {
|
||||||
cerr << contextElement << " ";
|
cerr << contextElement << " ";
|
||||||
}
|
}
|
||||||
cerr << endl;
|
cerr << endl;
|
||||||
|
@ -25,15 +25,25 @@ namespace adapters {
|
|||||||
* See http://www.stlsoft.org/doc-1.9/group__group____pattern____dereference__proxy.html
|
* See http://www.stlsoft.org/doc-1.9/group__group____pattern____dereference__proxy.html
|
||||||
* for motivation
|
* for motivation
|
||||||
*
|
*
|
||||||
* @tparam Value Name of the value type
|
* @tparam Value Name of the value type
|
||||||
*/
|
*/
|
||||||
template<class Value>
|
template<class Value>
|
||||||
struct DerefProxy
|
struct DerefProxy
|
||||||
{
|
{
|
||||||
explicit DerefProxy(const Value& x) : m_ref(x) {}
|
explicit DerefProxy(const Value& x)
|
||||||
Value* operator->() { return std::addressof(m_ref); }
|
: m_ref(x) { }
|
||||||
operator Value*() { return std::addressof(m_ref); }
|
|
||||||
|
|
||||||
|
Value* operator->()
|
||||||
|
{
|
||||||
|
return std::addressof(m_ref);
|
||||||
|
}
|
||||||
|
|
||||||
|
operator Value*()
|
||||||
|
{
|
||||||
|
return std::addressof(m_ref);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
Value m_ref;
|
Value m_ref;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -239,7 +249,7 @@ public:
|
|||||||
// definitely an array.
|
// definitely an array.
|
||||||
if (value.isArray()) {
|
if (value.isArray()) {
|
||||||
const opt::optional<Array> array = value.getArrayOptional();
|
const opt::optional<Array> array = value.getArrayOptional();
|
||||||
for( const AdapterType element : *array ) {
|
for (const AdapterType element : *array) {
|
||||||
if (!fn(element)) {
|
if (!fn(element)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -257,7 +267,7 @@ public:
|
|||||||
|
|
||||||
if (value.isObject()) {
|
if (value.isObject()) {
|
||||||
const opt::optional<Object> object = value.getObjectOptional();
|
const opt::optional<Object> object = value.getObjectOptional();
|
||||||
for( const ObjectMemberType member : *object ) {
|
for (const ObjectMemberType member : *object) {
|
||||||
if (!fn(member.first, AdapterType(member.second))) {
|
if (!fn(member.first, AdapterType(member.second))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ public:
|
|||||||
void applyToSubschemas(const FunctorType &fn) const
|
void applyToSubschemas(const FunctorType &fn) const
|
||||||
{
|
{
|
||||||
unsigned int index = 0;
|
unsigned int index = 0;
|
||||||
for( const Subschema *subschema : subschemas ) {
|
for (const Subschema *subschema : subschemas) {
|
||||||
if (!fn(index, subschema)) {
|
if (!fn(index, subschema)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -100,7 +100,7 @@ public:
|
|||||||
void applyToSubschemas(const FunctorType &fn) const
|
void applyToSubschemas(const FunctorType &fn) const
|
||||||
{
|
{
|
||||||
unsigned int index = 0;
|
unsigned int index = 0;
|
||||||
for( const Subschema *subschema : subschemas ) {
|
for (const Subschema *subschema : subschemas) {
|
||||||
if (!fn(index, subschema)) {
|
if (!fn(index, subschema)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -167,7 +167,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
typedef typename ContainerType::value_type ValueType;
|
typedef typename ContainerType::value_type ValueType;
|
||||||
for( const ValueType &dependencyName : dependencyNames ) {
|
for (const ValueType &dependencyName : dependencyNames) {
|
||||||
itr->second.insert(String(dependencyName.c_str(), allocator));
|
itr->second.insert(String(dependencyName.c_str(), allocator));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,8 +193,7 @@ public:
|
|||||||
template<typename FunctorType>
|
template<typename FunctorType>
|
||||||
void applyToPropertyDependencies(const FunctorType &fn) const
|
void applyToPropertyDependencies(const FunctorType &fn) const
|
||||||
{
|
{
|
||||||
for( const PropertyDependencies::value_type &v :
|
for (const PropertyDependencies::value_type &v : propertyDependencies) {
|
||||||
propertyDependencies ) {
|
|
||||||
if (!fn(v.first, v.second)) {
|
if (!fn(v.first, v.second)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -204,8 +203,7 @@ public:
|
|||||||
template<typename FunctorType>
|
template<typename FunctorType>
|
||||||
void applyToSchemaDependencies(const FunctorType &fn) const
|
void applyToSchemaDependencies(const FunctorType &fn) const
|
||||||
{
|
{
|
||||||
for( const SchemaDependencies::value_type &v :
|
for (const SchemaDependencies::value_type &v : schemaDependencies) {
|
||||||
schemaDependencies ) {
|
|
||||||
if (!fn(v.first, v.second)) {
|
if (!fn(v.first, v.second)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -251,7 +249,7 @@ public:
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// Clone individual enum values
|
// Clone individual enum values
|
||||||
for( const EnumValue *otherValue : other.enumValues ) {
|
for (const EnumValue *otherValue : other.enumValues) {
|
||||||
const EnumValue *value = otherValue->clone();
|
const EnumValue *value = otherValue->clone();
|
||||||
try {
|
try {
|
||||||
enumValues.push_back(value);
|
enumValues.push_back(value);
|
||||||
@ -263,7 +261,7 @@ public:
|
|||||||
|
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
// Delete values already added to constraint
|
// Delete values already added to constraint
|
||||||
for( const EnumValue *value : enumValues ) {
|
for (const EnumValue *value : enumValues) {
|
||||||
delete value;
|
delete value;
|
||||||
}
|
}
|
||||||
throw;
|
throw;
|
||||||
@ -272,7 +270,7 @@ public:
|
|||||||
|
|
||||||
virtual ~EnumConstraint()
|
virtual ~EnumConstraint()
|
||||||
{
|
{
|
||||||
for( const EnumValue *value : enumValues ) {
|
for (const EnumValue *value : enumValues) {
|
||||||
delete value;
|
delete value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -292,7 +290,7 @@ public:
|
|||||||
template<typename FunctorType>
|
template<typename FunctorType>
|
||||||
void applyToValues(const FunctorType &fn) const
|
void applyToValues(const FunctorType &fn) const
|
||||||
{
|
{
|
||||||
for( const EnumValue *value : enumValues ) {
|
for (const EnumValue *value : enumValues) {
|
||||||
if (!fn(*value)) {
|
if (!fn(*value)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@ namespace json_pointer {
|
|||||||
* @param search string to search
|
* @param search string to search
|
||||||
* @param replace replacement string
|
* @param replace replacement string
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline void replace_all_inplace(std::string& subject, const char* search,
|
inline void replace_all_inplace(std::string& subject, const char* search,
|
||||||
const char* replace)
|
const char* replace)
|
||||||
{
|
{
|
||||||
|
@ -174,7 +174,7 @@ private:
|
|||||||
{
|
{
|
||||||
typedef typename DocumentCache<AdapterType>::Type DocCacheType;
|
typedef typename DocumentCache<AdapterType>::Type DocCacheType;
|
||||||
|
|
||||||
for( const typename DocCacheType::value_type &v : docCache ) {
|
for (const typename DocCacheType::value_type &v : docCache) {
|
||||||
freeDoc(v.second);
|
freeDoc(v.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -314,7 +314,7 @@ private:
|
|||||||
const std::vector<std::string> &keysToCreate,
|
const std::vector<std::string> &keysToCreate,
|
||||||
const Subschema *schema)
|
const Subschema *schema)
|
||||||
{
|
{
|
||||||
for( const std::string &keyToCreate : keysToCreate ) {
|
for (const std::string &keyToCreate : keysToCreate) {
|
||||||
const SchemaCache::value_type value(keyToCreate, schema);
|
const SchemaCache::value_type value(keyToCreate, schema);
|
||||||
if (!schemaCache.insert(value).second) {
|
if (!schemaCache.insert(value).second) {
|
||||||
throw std::logic_error(
|
throw std::logic_error(
|
||||||
@ -1180,7 +1180,7 @@ private:
|
|||||||
if (member.second.maybeArray()) {
|
if (member.second.maybeArray()) {
|
||||||
// Parse an array of dependency names
|
// Parse an array of dependency names
|
||||||
std::vector<std::string> dependentPropertyNames;
|
std::vector<std::string> dependentPropertyNames;
|
||||||
for( const AdapterType dependencyName : member.second.asArray() ) {
|
for (const AdapterType dependencyName : member.second.asArray()) {
|
||||||
if (dependencyName.maybeString()) {
|
if (dependencyName.maybeString()) {
|
||||||
dependentPropertyNames.push_back(dependencyName.getString());
|
dependentPropertyNames.push_back(dependencyName.getString());
|
||||||
} else {
|
} else {
|
||||||
@ -1237,7 +1237,7 @@ private:
|
|||||||
{
|
{
|
||||||
// Make a copy of each value in the enum array
|
// Make a copy of each value in the enum array
|
||||||
constraints::EnumConstraint constraint;
|
constraints::EnumConstraint constraint;
|
||||||
for( const AdapterType value : node.getArray() ) {
|
for (const AdapterType value : node.getArray()) {
|
||||||
constraint.addValue(value);
|
constraint.addValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1335,7 +1335,7 @@ private:
|
|||||||
// validate the values at the corresponding indexes in a target
|
// validate the values at the corresponding indexes in a target
|
||||||
// array.
|
// array.
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for( const AdapterType v : items->getArray() ) {
|
for (const AdapterType v : items->getArray()) {
|
||||||
const std::string childPath = itemsPath + "/" +
|
const std::string childPath = itemsPath + "/" +
|
||||||
std::to_string(index);
|
std::to_string(index);
|
||||||
const Subschema *subschema = makeOrReuseSchema<AdapterType>(
|
const Subschema *subschema = makeOrReuseSchema<AdapterType>(
|
||||||
@ -1861,7 +1861,7 @@ private:
|
|||||||
|
|
||||||
// Create subschemas for 'properties' constraint
|
// Create subschemas for 'properties' constraint
|
||||||
if (properties) {
|
if (properties) {
|
||||||
for( const Member m : properties->getObject() ) {
|
for (const Member m : properties->getObject()) {
|
||||||
const std::string &property = m.first;
|
const std::string &property = m.first;
|
||||||
const std::string childPath = propertiesPath + "/" + property;
|
const std::string childPath = propertiesPath + "/" + property;
|
||||||
const Subschema *subschema = makeOrReuseSchema<AdapterType>(
|
const Subschema *subschema = makeOrReuseSchema<AdapterType>(
|
||||||
@ -1874,7 +1874,7 @@ private:
|
|||||||
|
|
||||||
// Create subschemas for 'patternProperties' constraint
|
// Create subschemas for 'patternProperties' constraint
|
||||||
if (patternProperties) {
|
if (patternProperties) {
|
||||||
for( const Member m : patternProperties->getObject() ) {
|
for (const Member m : patternProperties->getObject()) {
|
||||||
const std::string &pattern = m.first;
|
const std::string &pattern = m.first;
|
||||||
const std::string childPath = patternPropertiesPath + "/" +
|
const std::string childPath = patternPropertiesPath + "/" +
|
||||||
pattern;
|
pattern;
|
||||||
@ -1973,7 +1973,7 @@ private:
|
|||||||
{
|
{
|
||||||
constraints::RequiredConstraint constraint;
|
constraints::RequiredConstraint constraint;
|
||||||
|
|
||||||
for( const AdapterType v : node.getArray() ) {
|
for (const AdapterType v : node.getArray()) {
|
||||||
if (!v.isString()) {
|
if (!v.isString()) {
|
||||||
throw std::runtime_error("Expected required property name to "
|
throw std::runtime_error("Expected required property name to "
|
||||||
"be a string value");
|
"be a string value");
|
||||||
@ -2030,7 +2030,7 @@ private:
|
|||||||
|
|
||||||
} else if (node.isArray()) {
|
} else if (node.isArray()) {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for( const AdapterType v : node.getArray() ) {
|
for (const AdapterType v : node.getArray()) {
|
||||||
if (v.isString()) {
|
if (v.isString()) {
|
||||||
const TypeConstraint::JsonType type =
|
const TypeConstraint::JsonType type =
|
||||||
TypeConstraint::jsonTypeFromString(v.getString());
|
TypeConstraint::jsonTypeFromString(v.getString());
|
||||||
|
@ -121,7 +121,7 @@ public:
|
|||||||
bool apply(ApplyFunction &applyFunction) const
|
bool apply(ApplyFunction &applyFunction) const
|
||||||
{
|
{
|
||||||
bool allTrue = true;
|
bool allTrue = true;
|
||||||
for( const Constraint *constraint : constraints ) {
|
for (const Constraint *constraint : constraints) {
|
||||||
allTrue = allTrue && applyFunction(*constraint);
|
allTrue = allTrue && applyFunction(*constraint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool applyStrict(ApplyFunction &applyFunction) const
|
bool applyStrict(ApplyFunction &applyFunction) const
|
||||||
{
|
{
|
||||||
for( const Constraint *constraint : constraints ) {
|
for (const Constraint *constraint : constraints) {
|
||||||
if (!applyFunction(*constraint)) {
|
if (!applyFunction(*constraint)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -875,7 +875,7 @@ public:
|
|||||||
return validated;
|
return validated;
|
||||||
}
|
}
|
||||||
|
|
||||||
for( const typename AdapterType::ObjectMember m : object ) {
|
for (const typename AdapterType::ObjectMember m : object) {
|
||||||
if (propertiesMatched.find(m.first) == propertiesMatched.end()) {
|
if (propertiesMatched.find(m.first) == propertiesMatched.end()) {
|
||||||
// Update context
|
// Update context
|
||||||
std::vector<std::string> newContext = context;
|
std::vector<std::string> newContext = context;
|
||||||
@ -956,7 +956,7 @@ public:
|
|||||||
bool validated = true;
|
bool validated = true;
|
||||||
|
|
||||||
unsigned int index = 0;
|
unsigned int index = 0;
|
||||||
for( const AdapterType &item : target.getArray() ) {
|
for (const AdapterType &item : target.getArray()) {
|
||||||
// Update context for current array item
|
// Update context for current array item
|
||||||
std::vector<std::string> newContext = context;
|
std::vector<std::string> newContext = context;
|
||||||
newContext.push_back("[" +
|
newContext.push_back("[" +
|
||||||
@ -1199,7 +1199,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
typedef typename ContainerType::value_type ValueType;
|
typedef typename ContainerType::value_type ValueType;
|
||||||
for( const ValueType &dependencyName : dependencyNames ) {
|
for (const ValueType &dependencyName : dependencyNames) {
|
||||||
const std::string dependencyNameKey(dependencyName.c_str());
|
const std::string dependencyNameKey(dependencyName.c_str());
|
||||||
if (object.find(dependencyNameKey) == object.end()) {
|
if (object.find(dependencyNameKey) == object.end()) {
|
||||||
if (validated) {
|
if (validated) {
|
||||||
@ -1411,7 +1411,7 @@ private:
|
|||||||
|
|
||||||
// Recursively validate all matching properties
|
// Recursively validate all matching properties
|
||||||
typedef const typename AdapterType::ObjectMember ObjectMember;
|
typedef const typename AdapterType::ObjectMember ObjectMember;
|
||||||
for( const ObjectMember m : object ) {
|
for (const ObjectMember m : object) {
|
||||||
if (std::regex_search(m.first, r)) {
|
if (std::regex_search(m.first, r)) {
|
||||||
matchFound = true;
|
matchFound = true;
|
||||||
if (propertiesMatched) {
|
if (propertiesMatched) {
|
||||||
|
@ -35,7 +35,7 @@ TEST_F(TestJson11Adapter, BasicArrayIteration)
|
|||||||
|
|
||||||
// Ensure that the elements are returned in the order they were inserted
|
// Ensure that the elements are returned in the order they were inserted
|
||||||
unsigned int expectedValue = 0;
|
unsigned int expectedValue = 0;
|
||||||
for( const valijson::adapters::Json11Adapter value : adapter.getArray() ) {
|
for (const valijson::adapters::Json11Adapter value : adapter.getArray()) {
|
||||||
ASSERT_TRUE( value.isNumber() );
|
ASSERT_TRUE( value.isNumber() );
|
||||||
EXPECT_EQ( double(expectedValue), value.getDouble() );
|
EXPECT_EQ( double(expectedValue), value.getDouble() );
|
||||||
expectedValue++;
|
expectedValue++;
|
||||||
@ -72,7 +72,7 @@ TEST_F(TestJson11Adapter, BasicObjectIteration)
|
|||||||
|
|
||||||
// Ensure that the members are returned in the order they were inserted
|
// Ensure that the members are returned in the order they were inserted
|
||||||
unsigned int expectedValue = 0;
|
unsigned int expectedValue = 0;
|
||||||
for( const valijson::adapters::Json11Adapter::ObjectMember member : adapter.getObject() ) {
|
for (const valijson::adapters::Json11Adapter::ObjectMember member : adapter.getObject()) {
|
||||||
ASSERT_TRUE( member.second.isNumber() );
|
ASSERT_TRUE( member.second.isNumber() );
|
||||||
EXPECT_EQ( std::to_string(expectedValue), member.first );
|
EXPECT_EQ( std::to_string(expectedValue), member.first );
|
||||||
EXPECT_EQ( double(expectedValue), member.second.getDouble() );
|
EXPECT_EQ( double(expectedValue), member.second.getDouble() );
|
||||||
|
@ -32,7 +32,7 @@ TEST_F(TestJsonCppAdapter, BasicArrayIteration)
|
|||||||
|
|
||||||
// Ensure that the elements are returned in the order they were inserted
|
// Ensure that the elements are returned in the order they were inserted
|
||||||
unsigned int expectedValue = 0;
|
unsigned int expectedValue = 0;
|
||||||
for( const valijson::adapters::JsonCppAdapter value : adapter.getArray() ) {
|
for (const valijson::adapters::JsonCppAdapter value : adapter.getArray()) {
|
||||||
ASSERT_TRUE( value.isNumber() );
|
ASSERT_TRUE( value.isNumber() );
|
||||||
EXPECT_EQ( double(expectedValue), value.getNumber() );
|
EXPECT_EQ( double(expectedValue), value.getNumber() );
|
||||||
expectedValue++;
|
expectedValue++;
|
||||||
@ -68,7 +68,7 @@ TEST_F(TestJsonCppAdapter, BasicObjectIteration)
|
|||||||
|
|
||||||
// Ensure that the members are returned in the order they were inserted
|
// Ensure that the members are returned in the order they were inserted
|
||||||
unsigned int expectedValue = 0;
|
unsigned int expectedValue = 0;
|
||||||
for( const valijson::adapters::JsonCppAdapter::ObjectMember member : adapter.getObject() ) {
|
for (const valijson::adapters::JsonCppAdapter::ObjectMember member : adapter.getObject()) {
|
||||||
ASSERT_TRUE( member.second.isNumber() );
|
ASSERT_TRUE( member.second.isNumber() );
|
||||||
EXPECT_EQ( std::to_string(expectedValue), member.first );
|
EXPECT_EQ( std::to_string(expectedValue), member.first );
|
||||||
EXPECT_EQ( double(expectedValue), member.second.getDouble() );
|
EXPECT_EQ( double(expectedValue), member.second.getDouble() );
|
||||||
|
@ -34,7 +34,7 @@ TEST_F(TestNlohmannJsonAdapter, BasicArrayIteration)
|
|||||||
|
|
||||||
// Ensure that the elements are returned in the order they were inserted
|
// Ensure that the elements are returned in the order they were inserted
|
||||||
unsigned int expectedValue = 0;
|
unsigned int expectedValue = 0;
|
||||||
for( const valijson::adapters::NlohmannJsonAdapter value : adapter.getArray() ) {
|
for (const valijson::adapters::NlohmannJsonAdapter value : adapter.getArray()) {
|
||||||
ASSERT_TRUE( value.isNumber() );
|
ASSERT_TRUE( value.isNumber() );
|
||||||
EXPECT_EQ( double(expectedValue), value.getDouble() );
|
EXPECT_EQ( double(expectedValue), value.getDouble() );
|
||||||
expectedValue++;
|
expectedValue++;
|
||||||
@ -69,7 +69,7 @@ TEST_F(TestNlohmannJsonAdapter, BasicObjectIteration)
|
|||||||
|
|
||||||
// Ensure that the members are returned in the order they were inserted
|
// Ensure that the members are returned in the order they were inserted
|
||||||
unsigned int expectedValue = 0;
|
unsigned int expectedValue = 0;
|
||||||
for( const valijson::adapters::NlohmannJsonAdapter::ObjectMember member : adapter.getObject() ) {
|
for (const valijson::adapters::NlohmannJsonAdapter::ObjectMember member : adapter.getObject()) {
|
||||||
ASSERT_TRUE( member.second.isNumber() );
|
ASSERT_TRUE( member.second.isNumber() );
|
||||||
EXPECT_EQ( std::to_string(expectedValue), member.first );
|
EXPECT_EQ( std::to_string(expectedValue), member.first );
|
||||||
EXPECT_EQ( double(expectedValue), member.second.getDouble() );
|
EXPECT_EQ( double(expectedValue), member.second.getDouble() );
|
||||||
|
@ -35,7 +35,7 @@ TEST_F(TestPicoJsonAdapter, BasicArrayIteration)
|
|||||||
|
|
||||||
// Ensure that the elements are returned in the order they were inserted
|
// Ensure that the elements are returned in the order they were inserted
|
||||||
unsigned int expectedValue = 0;
|
unsigned int expectedValue = 0;
|
||||||
for( const valijson::adapters::PicoJsonAdapter value : adapter.getArray() ) {
|
for (const valijson::adapters::PicoJsonAdapter value : adapter.getArray()) {
|
||||||
ASSERT_TRUE( value.isNumber() );
|
ASSERT_TRUE( value.isNumber() );
|
||||||
EXPECT_EQ( double(expectedValue), value.getDouble() );
|
EXPECT_EQ( double(expectedValue), value.getDouble() );
|
||||||
expectedValue++;
|
expectedValue++;
|
||||||
@ -72,7 +72,7 @@ TEST_F(TestPicoJsonAdapter, BasicObjectIteration)
|
|||||||
|
|
||||||
// Ensure that the members are returned in the order they were inserted
|
// Ensure that the members are returned in the order they were inserted
|
||||||
unsigned int expectedValue = 0;
|
unsigned int expectedValue = 0;
|
||||||
for( const valijson::adapters::PicoJsonAdapter::ObjectMember member : adapter.getObject() ) {
|
for (const valijson::adapters::PicoJsonAdapter::ObjectMember member : adapter.getObject()) {
|
||||||
ASSERT_TRUE( member.second.isNumber() );
|
ASSERT_TRUE( member.second.isNumber() );
|
||||||
EXPECT_EQ( std::to_string(expectedValue), member.first );
|
EXPECT_EQ( std::to_string(expectedValue), member.first );
|
||||||
EXPECT_EQ( double(expectedValue), member.second.getDouble() );
|
EXPECT_EQ( double(expectedValue), member.second.getDouble() );
|
||||||
|
@ -34,7 +34,7 @@ TEST_F(TestPropertyTreeAdapter, BasicArrayIteration)
|
|||||||
|
|
||||||
// Ensure that the elements are returned in the order they were inserted
|
// Ensure that the elements are returned in the order they were inserted
|
||||||
unsigned int expectedValue = 0;
|
unsigned int expectedValue = 0;
|
||||||
for( const valijson::adapters::PropertyTreeAdapter value : adapter.getArray() ) {
|
for (const valijson::adapters::PropertyTreeAdapter value : adapter.getArray()) {
|
||||||
ASSERT_TRUE( value.isString() );
|
ASSERT_TRUE( value.isString() );
|
||||||
ASSERT_FALSE( value.isNumber() );
|
ASSERT_FALSE( value.isNumber() );
|
||||||
ASSERT_TRUE( value.maybeDouble() );
|
ASSERT_TRUE( value.maybeDouble() );
|
||||||
@ -73,7 +73,7 @@ TEST_F(TestPropertyTreeAdapter, BasicObjectIteration)
|
|||||||
|
|
||||||
// Ensure that the members are returned in the order they were inserted
|
// Ensure that the members are returned in the order they were inserted
|
||||||
unsigned int expectedValue = 0;
|
unsigned int expectedValue = 0;
|
||||||
for( const valijson::adapters::PropertyTreeAdapter::ObjectMember member : adapter.getObject() ) {
|
for (const valijson::adapters::PropertyTreeAdapter::ObjectMember member : adapter.getObject()) {
|
||||||
ASSERT_TRUE( member.second.isString() );
|
ASSERT_TRUE( member.second.isString() );
|
||||||
ASSERT_FALSE( member.second.isNumber() );
|
ASSERT_FALSE( member.second.isNumber() );
|
||||||
ASSERT_TRUE( member.second.maybeDouble() );
|
ASSERT_TRUE( member.second.maybeDouble() );
|
||||||
|
@ -37,7 +37,7 @@ void testBasicArrayIteration()
|
|||||||
|
|
||||||
// Ensure that the elements are returned in the order they were inserted
|
// Ensure that the elements are returned in the order they were inserted
|
||||||
unsigned int expectedValue = 0;
|
unsigned int expectedValue = 0;
|
||||||
for( const valijson::adapters::RapidJsonAdapter value : adapter.getArray() ) {
|
for (const valijson::adapters::RapidJsonAdapter value : adapter.getArray()) {
|
||||||
ASSERT_TRUE( value.isNumber() );
|
ASSERT_TRUE( value.isNumber() );
|
||||||
EXPECT_EQ( double(expectedValue), value.getDouble() );
|
EXPECT_EQ( double(expectedValue), value.getDouble() );
|
||||||
expectedValue++;
|
expectedValue++;
|
||||||
@ -77,7 +77,7 @@ void testBasicObjectIteration()
|
|||||||
|
|
||||||
// Ensure that the members are returned in the order they were inserted
|
// Ensure that the members are returned in the order they were inserted
|
||||||
unsigned int expectedValue = 0;
|
unsigned int expectedValue = 0;
|
||||||
for( const valijson::adapters::RapidJsonAdapter::ObjectMember member : adapter.getObject() ) {
|
for (const valijson::adapters::RapidJsonAdapter::ObjectMember member : adapter.getObject()) {
|
||||||
ASSERT_TRUE( member.second.isNumber() );
|
ASSERT_TRUE( member.second.isNumber() );
|
||||||
EXPECT_EQ( std::to_string(expectedValue), member.first );
|
EXPECT_EQ( std::to_string(expectedValue), member.first );
|
||||||
EXPECT_EQ( double(expectedValue), member.second.getDouble() );
|
EXPECT_EQ( double(expectedValue), member.second.getDouble() );
|
||||||
|
@ -96,7 +96,7 @@ protected:
|
|||||||
ASSERT_TRUE( testCases.isArray() );
|
ASSERT_TRUE( testCases.isArray() );
|
||||||
|
|
||||||
// Process each test case in the file
|
// Process each test case in the file
|
||||||
for( const AdapterType testCase : testCases.getArray() ) {
|
for (const AdapterType testCase : testCases.getArray()) {
|
||||||
|
|
||||||
currentTestCase.clear();
|
currentTestCase.clear();
|
||||||
currentTest.clear();
|
currentTest.clear();
|
||||||
@ -124,7 +124,7 @@ protected:
|
|||||||
itr = object.find("tests");
|
itr = object.find("tests");
|
||||||
ASSERT_NE( object.end(), itr );
|
ASSERT_NE( object.end(), itr );
|
||||||
ASSERT_TRUE( itr->second.isArray() );
|
ASSERT_TRUE( itr->second.isArray() );
|
||||||
for( const AdapterType test : itr->second.getArray() ) {
|
for (const AdapterType test : itr->second.getArray()) {
|
||||||
|
|
||||||
const bool strict = itr->second.hasStrictTypes();
|
const bool strict = itr->second.hasStrictTypes();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user