string_util_test.cc 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
  2. // This source code is licensed under both the GPLv2 (found in the
  3. // COPYING file in the root directory) and Apache 2.0 License
  4. // (found in the LICENSE.Apache file in the root directory).
  5. //
  6. #include "string_util.h"
  7. #include <gtest/gtest.h>
  8. #include <port/stack_trace.h>
  9. #include "test_util/testutil.h"
  10. namespace ROCKSDB_NAMESPACE {
  11. TEST(StringUtilTest, NumberToHumanString) {
  12. ASSERT_EQ("-9223372036G", NumberToHumanString(INT64_MIN));
  13. ASSERT_EQ("9223372036G", NumberToHumanString(INT64_MAX));
  14. ASSERT_EQ("0", NumberToHumanString(0));
  15. ASSERT_EQ("9999", NumberToHumanString(9999));
  16. ASSERT_EQ("10K", NumberToHumanString(10000));
  17. ASSERT_EQ("10M", NumberToHumanString(10000000));
  18. ASSERT_EQ("10G", NumberToHumanString(10000000000));
  19. ASSERT_EQ("-9999", NumberToHumanString(-9999));
  20. ASSERT_EQ("-10K", NumberToHumanString(-10000));
  21. ASSERT_EQ("-10M", NumberToHumanString(-10000000));
  22. ASSERT_EQ("-10G", NumberToHumanString(-10000000000));
  23. }
  24. } // namespace ROCKSDB_NAMESPACE
  25. int main(int argc, char** argv) {
  26. ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
  27. ::testing::InitGoogleTest(&argc, argv);
  28. return RUN_ALL_TESTS();
  29. }