mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-10-15 15:16:47 +02:00
json_value.cpp bug in the edges of uint/int (#1519)
* json_value.cpp bug in the edges of uint/int Fixing bug of sending a number that is a bit bigger than max<uint64_t> it returns 0: https://stackoverflow.com/questions/77261400/jsoncpp-do-not-protect-from-uint64-overflow-and-have-weird-behavior/77261716#77261716 * Update json_value.cpp Fixing bug of sending a number that is a bit bigger than max<uint64_t> it returns 0: https://stackoverflow.com/questions/77261400/jsoncpp-do-not-protect-from-uint64-overflow-and-have-weird-behavior/77261716#77261716 * Update test cases * json_value.cpp bug in the edges of uint/int Fixing bug of sending a number that is a bit bigger than max<uint64_t> it returns 0: https://stackoverflow.com/questions/77261400/jsoncpp-do-not-protect-from-uint64-overflow-and-have-weird-behavior/77261716#77261716 * Run clang tidy --------- Co-authored-by: Jordan Bayles <bayles.jordan@gmail.com>
This commit is contained in:
@@ -1191,15 +1191,13 @@ JSONTEST_FIXTURE_LOCAL(ValueTest, integers) {
|
||||
JSONTEST_ASSERT_EQUAL(true, val.asBool());
|
||||
JSONTEST_ASSERT_STRING_EQUAL("-9223372036854775808", val.asString());
|
||||
|
||||
// int64 min (floating point constructor). Note that kint64min *is* exactly
|
||||
// representable as a double.
|
||||
// int64 min (floating point constructor). Since double values in proximity of
|
||||
// kint64min are rounded to kint64min, we don't check for conversion to int64.
|
||||
val = Json::Value(double(kint64min));
|
||||
|
||||
JSONTEST_ASSERT_EQUAL(Json::realValue, val.type());
|
||||
|
||||
checks = IsCheck();
|
||||
checks.isInt64_ = true;
|
||||
checks.isIntegral_ = true;
|
||||
checks.isDouble_ = true;
|
||||
checks.isNumeric_ = true;
|
||||
JSONTEST_ASSERT_PRED(checkIs(val, checks));
|
||||
@@ -1208,8 +1206,6 @@ JSONTEST_FIXTURE_LOCAL(ValueTest, integers) {
|
||||
JSONTEST_ASSERT(!val.isConvertibleTo(Json::intValue));
|
||||
JSONTEST_ASSERT(!val.isConvertibleTo(Json::uintValue));
|
||||
|
||||
JSONTEST_ASSERT_EQUAL(kint64min, val.asInt64());
|
||||
JSONTEST_ASSERT_EQUAL(kint64min, val.asLargestInt());
|
||||
JSONTEST_ASSERT_EQUAL(-9223372036854775808.0, val.asDouble());
|
||||
JSONTEST_ASSERT_EQUAL(-9223372036854775808.0, val.asFloat());
|
||||
JSONTEST_ASSERT_EQUAL(true, val.asBool());
|
||||
|
Reference in New Issue
Block a user