作者: 韩晨旭 10225101440 李畅 10225102463

54 lines
1.6 KiB

Release 1.18 Changes are: * Update version number to 1.18 * Replace the basic fprintf call with a call to fwrite in order to work around the apparent compiler optimization/rewrite failure that we are seeing with the new toolchain/iOS SDKs provided with Xcode6 and iOS8. * Fix ALL the header guards. * Createed a README.md with the LevelDB project description. * A new CONTRIBUTING file. * Don't implicitly convert uint64_t to size_t or int. Either preserve it as uint64_t, or explicitly cast. This fixes MSVC warnings about possible value truncation when compiling this code in Chromium. * Added a DumpFile() library function that encapsulates the guts of the "leveldbutil dump" command. This will allow clients to dump data to their log files instead of stdout. It will also allow clients to supply their own environment. * leveldb: Remove unused function 'ConsumeChar'. * leveldbutil: Remove unused member variables from WriteBatchItemPrinter. * OpenBSD, NetBSD and DragonflyBSD have _LITTLE_ENDIAN, so define PLATFORM_IS_LITTLE_ENDIAN like on FreeBSD. This fixes: * issue #143 * issue #198 * issue #249 * Switch from <cstdatomic> to <atomic>. The former never made it into the standard and doesn't exist in modern gcc versions at all. The later contains everything that leveldb was using from the former. This problem was noticed when porting to Portable Native Client where no memory barrier is defined. The fact that <cstdatomic> is missing normally goes unnoticed since memory barriers are defined for most architectures. * Make Hash() treat its input as unsigned. Before this change LevelDB files from platforms with different signedness of char were not compatible. This change fixes: issue #243 * Verify checksums of index/meta/filter blocks when paranoid_checks set. * Invoke all tools for iOS with xcrun. (This was causing problems with the new XCode 5.1.1 image on pulse.) * include <sys/stat.h> only once, and fix the following linter warning: "Found C system header after C++ system header" * When encountering a corrupted table file, return Status::Corruption instead of Status::InvalidArgument. * Support cygwin as build platform, patch is from https://code.google.com/p/leveldb/issues/detail?id=188 * Fix typo, merge patch from https://code.google.com/p/leveldb/issues/detail?id=159 * Fix typos and comments, and address the following two issues: * issue #166 * issue #241 * Add missing db synchronize after "fillseq" in the benchmark. * Removed unused variable in SeekRandom: value (issue #201)
преди 10 години
  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.
  4. #include "util/hash.h"
  5. #include "util/testharness.h"
  6. namespace leveldb {
  7. class HASH { };
  8. TEST(HASH, SignedUnsignedIssue) {
  9. const unsigned char data1[1] = {0x62};
  10. const unsigned char data2[2] = {0xc3, 0x97};
  11. const unsigned char data3[3] = {0xe2, 0x99, 0xa5};
  12. const unsigned char data4[4] = {0xe1, 0x80, 0xb9, 0x32};
  13. const unsigned char data5[48] = {
  14. 0x01, 0xc0, 0x00, 0x00,
  15. 0x00, 0x00, 0x00, 0x00,
  16. 0x00, 0x00, 0x00, 0x00,
  17. 0x00, 0x00, 0x00, 0x00,
  18. 0x14, 0x00, 0x00, 0x00,
  19. 0x00, 0x00, 0x04, 0x00,
  20. 0x00, 0x00, 0x00, 0x14,
  21. 0x00, 0x00, 0x00, 0x18,
  22. 0x28, 0x00, 0x00, 0x00,
  23. 0x00, 0x00, 0x00, 0x00,
  24. 0x02, 0x00, 0x00, 0x00,
  25. 0x00, 0x00, 0x00, 0x00,
  26. };
  27. ASSERT_EQ(Hash(0, 0, 0xbc9f1d34), 0xbc9f1d34);
  28. ASSERT_EQ(
  29. Hash(reinterpret_cast<const char*>(data1), sizeof(data1), 0xbc9f1d34),
  30. 0xef1345c4);
  31. ASSERT_EQ(
  32. Hash(reinterpret_cast<const char*>(data2), sizeof(data2), 0xbc9f1d34),
  33. 0x5b663814);
  34. ASSERT_EQ(
  35. Hash(reinterpret_cast<const char*>(data3), sizeof(data3), 0xbc9f1d34),
  36. 0x323c078f);
  37. ASSERT_EQ(
  38. Hash(reinterpret_cast<const char*>(data4), sizeof(data4), 0xbc9f1d34),
  39. 0xed21633a);
  40. ASSERT_EQ(
  41. Hash(reinterpret_cast<const char*>(data5), sizeof(data5), 0x12345678),
  42. 0xf333dabb);
  43. }
  44. } // namespace leveldb
  45. int main(int argc, char** argv) {
  46. return leveldb::test::RunAllTests();
  47. }