Merge branches 'binary_type' and 'develop' of https://github.com/nlohmann/json into binary_type
This commit is contained in:
commit
ab6e76dd05
18 changed files with 96 additions and 38 deletions
|
@ -939,7 +939,7 @@ TEST_CASE("CBOR")
|
|||
}
|
||||
SECTION("-3.40282e+38(lowest float)")
|
||||
{
|
||||
double v = std::numeric_limits<float>::lowest();
|
||||
double v = static_cast<double>(std::numeric_limits<float>::lowest());
|
||||
json j = v;
|
||||
std::vector<uint8_t> expected =
|
||||
{
|
||||
|
@ -953,7 +953,7 @@ TEST_CASE("CBOR")
|
|||
}
|
||||
SECTION("1 + 3.40282e+38(more than max float)")
|
||||
{
|
||||
double v = std::numeric_limits<float>::max() + 0.1e+34;
|
||||
double v = static_cast<double>(std::numeric_limits<float>::max()) + 0.1e+34;
|
||||
json j = v;
|
||||
std::vector<uint8_t> expected =
|
||||
{
|
||||
|
@ -968,7 +968,7 @@ TEST_CASE("CBOR")
|
|||
}
|
||||
SECTION("-1 - 3.40282e+38(less than lowest float)")
|
||||
{
|
||||
double v = std::numeric_limits<float>::lowest() - 1;
|
||||
double v = static_cast<double>(std::numeric_limits<float>::lowest()) - 1.0;
|
||||
json j = v;
|
||||
std::vector<uint8_t> expected =
|
||||
{
|
||||
|
@ -1582,7 +1582,7 @@ TEST_CASE("CBOR")
|
|||
auto j = json::from_cbor(input);
|
||||
CHECK(j.is_binary());
|
||||
auto k = json::binary_array({0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x99});
|
||||
CAPTURE(j.dump(0, ' ', false, json::error_handler_t::strict, true));
|
||||
CAPTURE(j.dump(0, ' ', false, json::error_handler_t::strict, true))
|
||||
CHECK(j == k);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,12 @@ void to_json(json&, pod) noexcept;
|
|||
void to_json(json&, pod_bis);
|
||||
void from_json(const json&, pod) noexcept;
|
||||
void from_json(const json&, pod_bis);
|
||||
static json* j;
|
||||
void to_json(json&, pod) noexcept {}
|
||||
void to_json(json&, pod_bis) {}
|
||||
void from_json(const json&, pod) noexcept {}
|
||||
void from_json(const json&, pod_bis) {}
|
||||
|
||||
static json* j = nullptr;
|
||||
|
||||
static_assert(noexcept(json{}), "");
|
||||
static_assert(noexcept(nlohmann::to_json(*j, 2)), "");
|
||||
|
@ -79,4 +84,14 @@ TEST_CASE("runtime checks")
|
|||
CHECK(std::is_nothrow_copy_constructible<json::out_of_range>::value == std::is_nothrow_copy_constructible<std::runtime_error>::value);
|
||||
CHECK(std::is_nothrow_copy_constructible<json::other_error>::value == std::is_nothrow_copy_constructible<std::runtime_error>::value);
|
||||
}
|
||||
|
||||
SECTION("silence -Wunneeded-internal-declaration errors")
|
||||
{
|
||||
j = nullptr;
|
||||
json j2;
|
||||
to_json(j2, pod());
|
||||
to_json(j2, pod_bis());
|
||||
from_json(j2, pod());
|
||||
from_json(j2, pod_bis());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,6 +120,8 @@ static void to_json(BasicJsonType& j, country c)
|
|||
case country::russia:
|
||||
j = u8"Российская Федерация";
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -803,7 +805,9 @@ class Evil
|
|||
public:
|
||||
Evil() = default;
|
||||
template <typename T>
|
||||
Evil(T) {}
|
||||
Evil(T t) : m_i(sizeof(t)) {}
|
||||
|
||||
int m_i = 0;
|
||||
};
|
||||
|
||||
void from_json(const json&, Evil&) {}
|
||||
|
@ -816,6 +820,10 @@ TEST_CASE("Issue #924")
|
|||
|
||||
CHECK_NOTHROW(j.get<Evil>());
|
||||
CHECK_NOTHROW(j.get<std::vector<Evil>>());
|
||||
|
||||
// silence Wunused-template warnings
|
||||
Evil e(1);
|
||||
CHECK(e.m_i >= 0);
|
||||
}
|
||||
|
||||
TEST_CASE("Issue #1237")
|
||||
|
|
2
test/thirdparty/doctest/doctest.h
vendored
2
test/thirdparty/doctest/doctest.h
vendored
|
@ -2913,7 +2913,7 @@ typedef timer_large_integer::type ticks_t;
|
|||
//unsigned int getElapsedMilliseconds() const {
|
||||
// return static_cast<unsigned int>(getElapsedMicroseconds() / 1000);
|
||||
//}
|
||||
double getElapsedSeconds() const { return (getCurrentTicks() - m_ticks) / 1000000.0; }
|
||||
double getElapsedSeconds() const { return static_cast<double>((getCurrentTicks() - m_ticks)) / 1000000.0; }
|
||||
|
||||
private:
|
||||
ticks_t m_ticks = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue