mirror of
https://github.com/google/leveldb.git
synced 2024-12-26 03:50:10 +08:00
8f464e7f68
This gives some flexibility to embedders. Currently, embedders have to build a binary for each test file. After this CL, embedders can still choose to have a binary for each test file, by linking each test file with a googletest target that includes main() (usually "gtest_main"). Embedders can also choose to build a single binary for almost all test files, and link with a googletest target that includes main(). The latter is more convenient for projects that have very few test binaries, like Chromium. PiperOrigin-RevId: 419470798
42 lines
1.4 KiB
C++
42 lines
1.4 KiB
C++
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
|
|
|
#include "util/hash.h"
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
namespace leveldb {
|
|
|
|
TEST(HASH, SignedUnsignedIssue) {
|
|
const uint8_t data1[1] = {0x62};
|
|
const uint8_t data2[2] = {0xc3, 0x97};
|
|
const uint8_t data3[3] = {0xe2, 0x99, 0xa5};
|
|
const uint8_t data4[4] = {0xe1, 0x80, 0xb9, 0x32};
|
|
const uint8_t data5[48] = {
|
|
0x01, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
|
|
0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x18, 0x28, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
};
|
|
|
|
ASSERT_EQ(Hash(0, 0, 0xbc9f1d34), 0xbc9f1d34);
|
|
ASSERT_EQ(
|
|
Hash(reinterpret_cast<const char*>(data1), sizeof(data1), 0xbc9f1d34),
|
|
0xef1345c4);
|
|
ASSERT_EQ(
|
|
Hash(reinterpret_cast<const char*>(data2), sizeof(data2), 0xbc9f1d34),
|
|
0x5b663814);
|
|
ASSERT_EQ(
|
|
Hash(reinterpret_cast<const char*>(data3), sizeof(data3), 0xbc9f1d34),
|
|
0x323c078f);
|
|
ASSERT_EQ(
|
|
Hash(reinterpret_cast<const char*>(data4), sizeof(data4), 0xbc9f1d34),
|
|
0xed21633a);
|
|
ASSERT_EQ(
|
|
Hash(reinterpret_cast<const char*>(data5), sizeof(data5), 0x12345678),
|
|
0xf333dabb);
|
|
}
|
|
|
|
} // namespace leveldb
|