Skip to content

Commit

Permalink
Various changes to prevent narrowing conversions: sql/
Browse files Browse the repository at this point in the history
Bug: 1216696
Change-Id: If96fa9eae1871df611fe3956809b117d9b921249
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2958311
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Commit-Queue: Victor Costan <pwnall@chromium.org>
Reviewed-by: Victor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#891916}
  • Loading branch information
pkasting authored and Chromium LUCI CQ committed Jun 12, 2021
1 parent d6df49e commit 94b5032
Showing 1 changed file with 19 additions and 75 deletions.
94 changes: 19 additions & 75 deletions sql/recover_module/module_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -897,91 +897,35 @@ TEST_F(RecoverModuleTest, IntegerEncodings) {
TEST_F(RecoverModuleTest, VarintEncodings) {
const std::vector<int64_t> values = {
// 1-byte varints.
0x00,
0x01,
0x02,
0x7e,
0x7f,
0x00, 0x01, 0x02, 0x7e, 0x7f,
// 2-byte varints
0x80,
0x81,
0xff,
0x0100,
0x0101,
0x1234,
0x1ffe,
0x1fff,
0x3ffe,
0x3fff,
0x80, 0x81, 0xff, 0x0100, 0x0101, 0x1234, 0x1ffe, 0x1fff, 0x3ffe, 0x3fff,
// 3-byte varints
0x4000,
0x4001,
0x0ffffe,
0x0fffff,
0x123456,
0x1fedcb,
0x1ffffe,
0x4000, 0x4001, 0x0ffffe, 0x0fffff, 0x123456, 0x1fedcb, 0x1ffffe,
0x1fffff,
// 4-byte varints
0x200000,
0x200001,
0x123456,
0xfedcba,
0xfffffe,
0xffffff,
0x01234567,
0x0fedcba9,
0x0ffffffe,
0x0fffffff,
0x200000, 0x200001, 0x123456, 0xfedcba, 0xfffffe, 0xffffff, 0x01234567,
0x0fedcba9, 0x0ffffffe, 0x0fffffff,
// 5-byte varints
0x10000000,
0x10000001,
0x12345678,
0xfedcba98,
0x0123456789,
0x07fffffffe,
0x07ffffffff,
0x10000000, 0x10000001, 0x12345678, 0xfedcba98, 0x01'23456789,
0x07'fffffffe, 0x07'ffffffff,
// 6-byte varints
0x0800000000,
0x0800000001,
0x123456789a,
0xfedcba9876,
0x0123456789ab,
0x03fffffffffe,
0x03ffffffffff,
0x08'00000000, 0x08'00000001, 0x12'3456789a, 0xfe'dcba9876,
0x0123'456789ab, 0x03ff'fffffffe, 0x03ff'ffffffff,
// 7-byte varints
0x040000000000,
0x40000000001,
0xfedcba987654,
0x0123456789abcd,
0x01fffffffffffe,
0x01ffffffffffff,
0x0400'00000000, 0x0400'00000001, 0xfedc'ba987654, 0x012345'6789abcd,
0x01ffff'fffffffe, 0x01ffff'ffffffff,
// 8-byte varints
0x02000000000000,
0x2000000000001,
0x0fedcba9876543,
0x123456789abcde,
0xfedcba98765432,
0xfffffffffffffe,
0xffffffffffffff,
0x020000'00000000, 0x020000'00000001, 0x0fedcb'a9876543,
0x123456'789abcde, 0xfedcba'98765432, 0xffffff'fffffffe,
0xffffff'ffffffff,
// 9-byte positive varints
0x0100000000000000,
0x0100000000000001,
0x123456789abcdef0,
0xfedcba9876543210,
0x7ffffffffffffffe,
0x7fffffffffffffff,
0x01000000'00000000, 0x01000000'00000001, 0x12345678'9abcdef0,
0x7fedcba9'87654321, 0x7fffffff'fffffffe, 0x7fffffff'ffffffff,
// 9-byte negative varints
-0x01,
-0x02,
-0x7e,
-0x7f,
-0x80,
-0x81,
-0x123456789abcdef0,
-0xfedcba9876543210,
-0x7fffffffffffffff,
-0x8000000000000000,
-0x01, -0x02, -0x7e, -0x7f, -0x80, -0x81, -0x12345678'9abcdef0,
-0x7fedcba9'87654321, -0x7fffffff'ffffffff,
-0x7fffffff'ffffffff - 1, // -0x80000000'00000000 is not a valid literal
};

ASSERT_TRUE(db_.Execute("CREATE TABLE varints(value INTEGER PRIMARY KEY)"));
Expand Down

0 comments on commit 94b5032

Please sign in to comment.