1 // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. See the AUTHORS file for names of contributors.
6 #include "util/testharness.h"
12 TEST(HASH, SignedUnsignedIssue) {
13 const unsigned char data1[1] = {0x62};
14 const unsigned char data2[2] = {0xc3, 0x97};
15 const unsigned char data3[3] = {0xe2, 0x99, 0xa5};
16 const unsigned char data4[4] = {0xe1, 0x80, 0xb9, 0x32};
17 const unsigned char data5[48] = {
18 0x01, 0xc0, 0x00, 0x00,
19 0x00, 0x00, 0x00, 0x00,
20 0x00, 0x00, 0x00, 0x00,
21 0x00, 0x00, 0x00, 0x00,
22 0x14, 0x00, 0x00, 0x00,
23 0x00, 0x00, 0x04, 0x00,
24 0x00, 0x00, 0x00, 0x14,
25 0x00, 0x00, 0x00, 0x18,
26 0x28, 0x00, 0x00, 0x00,
27 0x00, 0x00, 0x00, 0x00,
28 0x02, 0x00, 0x00, 0x00,
29 0x00, 0x00, 0x00, 0x00,
32 ASSERT_EQ(Hash(0, 0, 0xbc9f1d34), 0xbc9f1d34);
34 Hash(reinterpret_cast<const char*>(data1), sizeof(data1), 0xbc9f1d34),
37 Hash(reinterpret_cast<const char*>(data2), sizeof(data2), 0xbc9f1d34),
40 Hash(reinterpret_cast<const char*>(data3), sizeof(data3), 0xbc9f1d34),
43 Hash(reinterpret_cast<const char*>(data4), sizeof(data4), 0xbc9f1d34),
46 Hash(reinterpret_cast<const char*>(data5), sizeof(data5), 0x12345678),
50 } // namespace leveldb
52 int main(int argc, char** argv) {
53 return leveldb::test::RunAllTests();