mirror of https://github.com/nlohmann/json.git
⚗️ try to use GCC 10
parent
7b98df515f
commit
433da31334
|
@ -8,8 +8,16 @@ jobs:
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
|
- name: install_gcc
|
||||||
|
run: |
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install gcc-10 g++-10
|
||||||
|
shell: bash
|
||||||
- name: cmake
|
- name: cmake
|
||||||
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On
|
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On
|
||||||
|
env:
|
||||||
|
CC: gcc-10
|
||||||
|
CXX: g++-10
|
||||||
- name: build
|
- name: build
|
||||||
run: cmake --build build --parallel 10
|
run: cmake --build build --parallel 10
|
||||||
- name: test
|
- name: test
|
||||||
|
|
10
.travis.yml
10
.travis.yml
|
@ -300,16 +300,6 @@ matrix:
|
||||||
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-7']
|
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-7']
|
||||||
packages: ['g++-7', 'clang-7', 'ninja-build']
|
packages: ['g++-7', 'clang-7', 'ninja-build']
|
||||||
|
|
||||||
- os: linux
|
|
||||||
compiler: clang
|
|
||||||
env:
|
|
||||||
- COMPILER=clang++-7
|
|
||||||
- CXX_STANDARD=20
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-7']
|
|
||||||
packages: ['g++-7', 'clang-7', 'ninja-build']
|
|
||||||
|
|
||||||
################
|
################
|
||||||
# build script #
|
# build script #
|
||||||
################
|
################
|
||||||
|
|
|
@ -393,7 +393,30 @@ class iter_impl
|
||||||
@brief comparison: equal
|
@brief comparison: equal
|
||||||
@pre The iterator is initialized; i.e. `m_object != nullptr`.
|
@pre The iterator is initialized; i.e. `m_object != nullptr`.
|
||||||
*/
|
*/
|
||||||
bool operator==(const iter_impl& other) const
|
bool operator==(const iter_impl<const BasicJsonType>& other) const
|
||||||
|
{
|
||||||
|
// if objects are not the same, the comparison is undefined
|
||||||
|
if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object))
|
||||||
|
{
|
||||||
|
JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers"));
|
||||||
|
}
|
||||||
|
|
||||||
|
JSON_ASSERT(m_object != nullptr);
|
||||||
|
|
||||||
|
switch (m_object->m_type)
|
||||||
|
{
|
||||||
|
case value_t::object:
|
||||||
|
return (m_it.object_iterator == other.m_it.object_iterator);
|
||||||
|
|
||||||
|
case value_t::array:
|
||||||
|
return (m_it.array_iterator == other.m_it.array_iterator);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return (m_it.primitive_iterator == other.m_it.primitive_iterator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const iter_impl<typename std::remove_const<BasicJsonType>::type>& other) const
|
||||||
{
|
{
|
||||||
// if objects are not the same, the comparison is undefined
|
// if objects are not the same, the comparison is undefined
|
||||||
if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object))
|
if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object))
|
||||||
|
|
|
@ -11279,7 +11279,30 @@ class iter_impl
|
||||||
@brief comparison: equal
|
@brief comparison: equal
|
||||||
@pre The iterator is initialized; i.e. `m_object != nullptr`.
|
@pre The iterator is initialized; i.e. `m_object != nullptr`.
|
||||||
*/
|
*/
|
||||||
bool operator==(const iter_impl& other) const
|
bool operator==(const iter_impl<const BasicJsonType>& other) const
|
||||||
|
{
|
||||||
|
// if objects are not the same, the comparison is undefined
|
||||||
|
if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object))
|
||||||
|
{
|
||||||
|
JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers"));
|
||||||
|
}
|
||||||
|
|
||||||
|
JSON_ASSERT(m_object != nullptr);
|
||||||
|
|
||||||
|
switch (m_object->m_type)
|
||||||
|
{
|
||||||
|
case value_t::object:
|
||||||
|
return (m_it.object_iterator == other.m_it.object_iterator);
|
||||||
|
|
||||||
|
case value_t::array:
|
||||||
|
return (m_it.array_iterator == other.m_it.array_iterator);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return (m_it.primitive_iterator == other.m_it.primitive_iterator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const iter_impl<typename std::remove_const<BasicJsonType>::type>& other) const
|
||||||
{
|
{
|
||||||
// if objects are not the same, the comparison is undefined
|
// if objects are not the same, the comparison is undefined
|
||||||
if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object))
|
if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object))
|
||||||
|
|
|
@ -509,7 +509,7 @@ TEST_CASE("parser class")
|
||||||
CHECK(parser_helper("\"€\"").get<json::string_t>() == "€");
|
CHECK(parser_helper("\"€\"").get<json::string_t>() == "€");
|
||||||
CHECK(parser_helper("\"🎈\"").get<json::string_t>() == "🎈");
|
CHECK(parser_helper("\"🎈\"").get<json::string_t>() == "🎈");
|
||||||
|
|
||||||
CHECK(parser_helper("\"\\ud80c\\udc60\"").get<json::string_t>() == u8"\U00013060");
|
CHECK(parser_helper("\"\\ud80c\\udc60\"").get<json::string_t>() == "\U00013060");
|
||||||
CHECK(parser_helper("\"\\ud83c\\udf1e\"").get<json::string_t>() == "🌞");
|
CHECK(parser_helper("\"\\ud83c\\udf1e\"").get<json::string_t>() == "🌞");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1448,3 +1448,11 @@ TEST_CASE("items()")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef JSON_HAS_CPP_17
|
||||||
|
#undef JSON_HAS_CPP_17
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef JSON_HAS_CPP_14
|
||||||
|
#undef JSON_HAS_CPP_14
|
||||||
|
#endif
|
||||||
|
|
|
@ -400,7 +400,7 @@ TEST_CASE("regression tests 1")
|
||||||
|
|
||||||
SECTION("issue #146 - character following a surrogate pair is skipped")
|
SECTION("issue #146 - character following a surrogate pair is skipped")
|
||||||
{
|
{
|
||||||
CHECK(json::parse("\"\\ud80c\\udc60abc\"").get<json::string_t>() == u8"\U00013060abc");
|
CHECK(json::parse("\"\\ud80c\\udc60abc\"").get<json::string_t>() == "\U00013060abc");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("issue #171 - Cannot index by key of type static constexpr const char*")
|
SECTION("issue #171 - Cannot index by key of type static constexpr const char*")
|
||||||
|
|
|
@ -112,13 +112,13 @@ static void to_json(BasicJsonType& j, country c)
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case country::china:
|
case country::china:
|
||||||
j = u8"中华人民共和国";
|
j = "中华人民共和国";
|
||||||
return;
|
return;
|
||||||
case country::france:
|
case country::france:
|
||||||
j = "France";
|
j = "France";
|
||||||
return;
|
return;
|
||||||
case country::russia:
|
case country::russia:
|
||||||
j = u8"Российская Федерация";
|
j = "Российская Федерация";
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -201,9 +201,9 @@ static void from_json(const BasicJsonType& j, country& c)
|
||||||
const auto str = j.template get<std::string>();
|
const auto str = j.template get<std::string>();
|
||||||
static const std::map<std::string, country> m =
|
static const std::map<std::string, country> m =
|
||||||
{
|
{
|
||||||
{u8"中华人民共和国", country::china},
|
{"中华人民共和国", country::china},
|
||||||
{"France", country::france},
|
{"France", country::france},
|
||||||
{u8"Российская Федерация", country::russia}
|
{"Российская Федерация", country::russia}
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto it = m.find(str);
|
const auto it = m.find(str);
|
||||||
|
@ -248,7 +248,7 @@ TEST_CASE("basic usage" * doctest::test_suite("udt"))
|
||||||
const udt::name n{"theo"};
|
const udt::name n{"theo"};
|
||||||
const udt::country c{udt::country::france};
|
const udt::country c{udt::country::france};
|
||||||
const udt::person sfinae_addict{a, n, c};
|
const udt::person sfinae_addict{a, n, c};
|
||||||
const udt::person senior_programmer{{42}, {u8"王芳"}, udt::country::china};
|
const udt::person senior_programmer{{42}, {"王芳"}, udt::country::china};
|
||||||
const udt::address addr{"Paris"};
|
const udt::address addr{"Paris"};
|
||||||
const udt::contact cpp_programmer{sfinae_addict, addr};
|
const udt::contact cpp_programmer{sfinae_addict, addr};
|
||||||
const udt::contact_book book{{"C++"}, {cpp_programmer, {senior_programmer, addr}}};
|
const udt::contact_book book{{"C++"}, {cpp_programmer, {senior_programmer, addr}}};
|
||||||
|
@ -265,14 +265,14 @@ TEST_CASE("basic usage" * doctest::test_suite("udt"))
|
||||||
|
|
||||||
CHECK(
|
CHECK(
|
||||||
json(book) ==
|
json(book) ==
|
||||||
u8R"({"name":"C++", "contacts" : [{"person" : {"age":23, "name":"theo", "country":"France"}, "address":"Paris"}, {"person" : {"age":42, "country":"中华人民共和国", "name":"王芳"}, "address":"Paris"}]})"_json);
|
R"({"name":"C++", "contacts" : [{"person" : {"age":23, "name":"theo", "country":"France"}, "address":"Paris"}, {"person" : {"age":42, "country":"中华人民共和国", "name":"王芳"}, "address":"Paris"}]})"_json);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("conversion from json via free-functions")
|
SECTION("conversion from json via free-functions")
|
||||||
{
|
{
|
||||||
const auto big_json =
|
const auto big_json =
|
||||||
u8R"({"name":"C++", "contacts" : [{"person" : {"age":23, "name":"theo", "country":"France"}, "address":"Paris"}, {"person" : {"age":42, "country":"中华人民共和国", "name":"王芳"}, "address":"Paris"}]})"_json;
|
R"({"name":"C++", "contacts" : [{"person" : {"age":23, "name":"theo", "country":"France"}, "address":"Paris"}, {"person" : {"age":42, "country":"中华人民共和国", "name":"王芳"}, "address":"Paris"}]})"_json;
|
||||||
SECTION("via explicit calls to get")
|
SECTION("via explicit calls to get")
|
||||||
{
|
{
|
||||||
const auto parsed_book = big_json.get<udt::contact_book>();
|
const auto parsed_book = big_json.get<udt::contact_book>();
|
||||||
|
|
Loading…
Reference in New Issue