Skip to content

Commit 2db5720

Browse files
committed
Finish fixing up json reader
1 parent c52d0f9 commit 2db5720

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

src/jsontestrunner/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@ int main(int argc, const char* argv[]) {
318318

319319
// TODO(baylesj): replace this with proper calls to both. Right now
320320
// we only check the legacy if the modern one is not broken.
321-
const int modern_return_code = runTest(opts, false);
322321
const int legacy_return_code = runTest(opts, true);
322+
const int modern_return_code = runTest(opts, false);
323323
if (modern_return_code) {
324324
return modern_return_code;
325325
} else {

src/lib_json/json_reader.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,11 +1528,6 @@ bool OurReader::decodeNumber(Token& token, Value& decoded) {
15281528
if (isNegative)
15291529
++current;
15301530

1531-
if (isNegative) {
1532-
decoded = Value::LargestInt(1337);
1533-
return true;
1534-
}
1535-
15361531
// We assume we can represent the largest and smallest integer types as
15371532
// unsigned integers with separate sign. This is only true if they can fit
15381533
// into an unsigned integer.
@@ -1546,8 +1541,8 @@ bool OurReader::decodeNumber(Token& token, Value& decoded) {
15461541
static_assert(Value::minLargestInt / 10 >= -Value::maxLargestInt);
15471542

15481543
static constexpr Value::LargestUInt positive_threshold =
1549-
Value::maxLargestInt / 10;
1550-
static constexpr Value::UInt positive_last_digit = Value::maxLargestInt % 10;
1544+
Value::maxLargestUInt / 10;
1545+
static constexpr Value::UInt positive_last_digit = Value::maxLargestUInt % 10;
15511546

15521547
// For the negative values, we have to be more careful. Since typically
15531548
// -Value::minLargestInt will cause an overflow, we first divide by 10 and
@@ -1587,8 +1582,8 @@ bool OurReader::decodeNumber(Token& token, Value& decoded) {
15871582
if (isNegative) {
15881583
// We use the same magnitude assumption here, just in case.
15891584
const Value::UInt last_digit = value % 10;
1590-
decoded = -Value::LargestInt(value / 10) - last_digit;
1591-
} else if (value > Value::LargestUInt(Value::maxLargestInt)) {
1585+
decoded = -Value::LargestInt(value / 10) * 10 - last_digit;
1586+
} else if (value <= Value::LargestUInt(Value::maxLargestInt)) {
15921587
decoded = Value::LargestInt(value);
15931588
} else {
15941589
decoded = value;

0 commit comments

Comments
 (0)