From 3749d61e1f7a59f5ec5067e560af1eb610c82015 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Sun, 12 Aug 2012 09:27:39 +0200 Subject: 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 --- .../WebKit/chromium/tests/IDBLevelDBCodingTest.cpp | 40 +++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'Source/WebKit/chromium/tests/IDBLevelDBCodingTest.cpp') 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 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 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(2), encodeVarInt(255).size()); EXPECT_EQ(static_cast(2), encodeVarInt(256).size()); EXPECT_EQ(static_cast(5), encodeVarInt(0xffffffff).size()); + EXPECT_EQ(static_cast(8), encodeVarInt(0xfffffffffffffLL).size()); + EXPECT_EQ(static_cast(9), encodeVarInt(0x7fffffffffffffffLL).size()); #ifdef NDEBUG - EXPECT_EQ(static_cast(8), encodeInt(-100).size()); + EXPECT_EQ(static_cast(10), encodeVarInt(-100).size()); #endif } @@ -682,6 +702,24 @@ TEST(IDBLevelDBCodingTest, ComparisonTest) } } +TEST(IDBLevelDBCodingTest, EncodeVarIntVSEncodeByteTest) +{ + Vector 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 vA = encodeByte(n); + Vector vB = encodeVarInt(static_cast(n)); + + EXPECT_EQ(vA.size(), vB.size()); + EXPECT_EQ(*(vA.data()), *(vB.data())); + } +} + } // namespace #endif // USE(LEVELDB) -- cgit v1.2.1