diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-08-12 09:27:39 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-08-12 09:27:39 +0200 |
commit | 3749d61e1f7a59f5ec5067e560af1eb610c82015 (patch) | |
tree | 73dc228333948738bbe02976cacca8cd382bc978 /Source/WebKit/chromium/tests/IDBLevelDBCodingTest.cpp | |
parent | b32b4dcd9a51ab8de6afc53d9e17f8707e1f7a5e (diff) | |
download | qtwebkit-3749d61e1f7a59f5ec5067e560af1eb610c82015.tar.gz |
Imported WebKit commit a77350243e054f3460d1137301d8b3faee3d2052 (http://svn.webkit.org/repository/webkit/trunk@125365)
New snapshot with build fixes for latest API changes in Qt and all WK1 Win MSVC fixes upstream
Diffstat (limited to 'Source/WebKit/chromium/tests/IDBLevelDBCodingTest.cpp')
-rw-r--r-- | Source/WebKit/chromium/tests/IDBLevelDBCodingTest.cpp | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/Source/WebKit/chromium/tests/IDBLevelDBCodingTest.cpp b/Source/WebKit/chromium/tests/IDBLevelDBCodingTest.cpp index 137699c30..1b2ff6fe1 100644 --- a/Source/WebKit/chromium/tests/IDBLevelDBCodingTest.cpp +++ b/Source/WebKit/chromium/tests/IDBLevelDBCodingTest.cpp @@ -84,6 +84,24 @@ TEST(IDBLevelDBCodingTest, EncodeByte) EXPECT_EQ(expected, encodeByte(c)); } +TEST(IDBLevelDBCodingTest, DecodeByte) +{ + Vector<unsigned char> testCases; + testCases.append(0); + testCases.append(1); + testCases.append(255); + + for (size_t i = 0; i < testCases.size(); ++i) { + unsigned char n = testCases[i]; + Vector<char> v = encodeByte(n); + + unsigned char res; + const char* p = decodeByte(v.data(), v.data() + v.size(), res); + EXPECT_EQ(n, res); + EXPECT_EQ(v.data() + v.size(), p); + } +} + TEST(IDBLevelDBCodingTest, EncodeBool) { { @@ -187,8 +205,10 @@ TEST(IDBLevelDBCodingTest, EncodeVarInt) EXPECT_EQ(static_cast<size_t>(2), encodeVarInt(255).size()); EXPECT_EQ(static_cast<size_t>(2), encodeVarInt(256).size()); EXPECT_EQ(static_cast<size_t>(5), encodeVarInt(0xffffffff).size()); + EXPECT_EQ(static_cast<size_t>(8), encodeVarInt(0xfffffffffffffLL).size()); + EXPECT_EQ(static_cast<size_t>(9), encodeVarInt(0x7fffffffffffffffLL).size()); #ifdef NDEBUG - EXPECT_EQ(static_cast<size_t>(8), encodeInt(-100).size()); + EXPECT_EQ(static_cast<size_t>(10), encodeVarInt(-100).size()); #endif } @@ -682,6 +702,24 @@ TEST(IDBLevelDBCodingTest, ComparisonTest) } } +TEST(IDBLevelDBCodingTest, EncodeVarIntVSEncodeByteTest) +{ + Vector<unsigned char> testCases; + testCases.append(0); + testCases.append(1); + testCases.append(127); + + for (size_t i = 0; i < testCases.size(); ++i) { + unsigned char n = testCases[i]; + + Vector<char> vA = encodeByte(n); + Vector<char> vB = encodeVarInt(static_cast<int64_t>(n)); + + EXPECT_EQ(vA.size(), vB.size()); + EXPECT_EQ(*(vA.data()), *(vB.data())); + } +} + } // namespace #endif // USE(LEVELDB) |