diff --git a/src/json.hpp b/src/json.hpp index 3f0b6e3e..ef55e2ea 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -3034,11 +3034,19 @@ class parser { case token_type::begin_object: { - if (keep and (not callback or ((keep = callback(depth++, parse_event_t::object_start, result))))) + if (keep) { - // explicitly set result to object to cope with {} - result.m_type = value_t::object; - result.m_value = value_t::object; + if (callback) + { + keep = callback(depth++, parse_event_t::object_start, result); + } + + if (not callback or keep) + { + // explicitly set result to object to cope with {} + result.m_type = value_t::object; + result.m_value = value_t::object; + } } // read next token @@ -3130,11 +3138,19 @@ class parser case token_type::begin_array: { - if (keep and (not callback or ((keep = callback(depth++, parse_event_t::array_start, result))))) + if (keep) { - // explicitly set result to object to cope with [] - result.m_type = value_t::array; - result.m_value = value_t::array; + if (callback) + { + keep = callback(depth++, parse_event_t::array_start, result); + } + + if (not callback or keep) + { + // explicitly set result to array to cope with [] + result.m_type = value_t::array; + result.m_value = value_t::array; + } } // read next token diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4ccbaf06..b51aff76 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -66,6 +66,19 @@ set_target_properties(catch_main PROPERTIES ) target_include_directories(catch_main PRIVATE "thirdparty/catch") +# https://stackoverflow.com/questions/2368811/how-to-set-warning-level-in-cmake +if(MSVC) + # Force to always compile with W4 + if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") + string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") + endif() + + # Disable warning C4389: '==': signed/unsigned mismatch + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4389") +endif() + ############################################################################# # one executable for each unit test file ############################################################################# diff --git a/test/src/unit-udt.cpp b/test/src/unit-udt.cpp index 6aa469fe..409cac83 100644 --- a/test/src/unit-udt.cpp +++ b/test/src/unit-udt.cpp @@ -201,7 +201,7 @@ void from_json(const BasicJsonType& j, country& c) { {u8"中华人民共和国", country::china}, {"France", country::france}, - {"Российская Федерация", country::russia} + {u8"Российская Федерация", country::russia} }; const auto it = m.find(str);