Fixed issue #199

This commit is contained in:
Trevor Welsby 2016-01-30 12:41:12 +10:00
parent ff6f723195
commit 561accb068
3 changed files with 383 additions and 786 deletions

File diff suppressed because it is too large Load diff

View file

@ -7478,7 +7478,7 @@ class basic_json
// Negative, parse with strtoll and attempt cast to
// number_integer_t
if (attempt_cast(std::strtoll(reinterpret_cast<typename string_t::const_pointer>(m_start), &endptr,
10), result.m_value.number_unsigned))
10), result.m_value.number_integer))
{
result.m_type = value_t::number_integer;
}

View file

@ -12097,17 +12097,17 @@ TEST_CASE("regression tests")
// unsigned integer parsing - expected to overflow and be stored as a float
j = custom_json::parse("4294967296"); // 2^32
CHECK(static_cast<int>(j.type()) == static_cast<int>(custom_json::value_t::number_float));
CHECK(j.get<float>() == 4294967296.0);
CHECK(j.get<float>() == 4294967296.0f);
// integer object creation - expected to wrap and still be stored as an integer
j = -2147483649LL; // -2^31-1
CHECK(static_cast<int>(j.type()) == static_cast<int>(custom_json::value_t::number_integer));
CHECK(j.get<int32_t>() == 2147483647.0); // Wrap
CHECK(j.get<int32_t>() == 2147483647); // Wrap
// integer parsing - expected to overflow and be stored as a float
j = custom_json::parse("-2147483648"); // -2^31
// integer parsing - expected to overflow and be stored as a float with rounding
j = custom_json::parse("-2147483649"); // -2^31
CHECK(static_cast<int>(j.type()) == static_cast<int>(custom_json::value_t::number_float));
CHECK(j.get<float>() == -2147483648.0);
CHECK(j.get<float>() == -2147483650.0f);
}
SECTION("issue #93 reverse_iterator operator inheritance problem")