Fix Json Int/UInt comparison limit check

This commit is contained in:
Edward Hennis
2017-04-05 12:08:20 -04:00
committed by Scott Schurr
parent 2e5ab4e0e3
commit 7e9ac16c22
2 changed files with 5 additions and 4 deletions

View File

@@ -402,10 +402,6 @@ int integerCmp (Int i, UInt ui)
if (i < 0)
return -1;
// All unsigned numbers with bit 0 set are too big for signed integers.
if (ui & 0x8000)
return 1;
// Now we can safely compare.
return (i < ui) ? -1 : (i == ui) ? 0 : 1;
}

View File

@@ -91,8 +91,13 @@ struct json_value_test : beast::unit_test::suite
BEAST_EXPECT(j1["max_int"].asInt() == max_int);
BEAST_EXPECT(j1["min_int"].asInt() == min_int);
BEAST_EXPECT(j1["a_uint"].asUInt() == a_uint);
BEAST_EXPECT(j1["a_uint"] > a_large_int);
BEAST_EXPECT(j1["a_uint"] > a_small_int);
BEAST_EXPECT(j1["a_large_int"].asInt() == a_large_int);
BEAST_EXPECT(j1["a_large_int"].asUInt() == a_large_int);
BEAST_EXPECT(j1["a_large_int"] < a_uint);
BEAST_EXPECT(j1["a_small_int"].asInt() == a_small_int);
BEAST_EXPECT(j1["a_small_int"] < a_uint);
json = "{\"overflow\":";
json += std::to_string(std::uint64_t(max_uint) + 1);