wide_columns_helper_test.cc 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright (c) Meta Platforms, Inc. and affiliates.
  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. #include "db/wide/wide_columns_helper.h"
  6. #include "db/wide/wide_column_serialization.h"
  7. #include "test_util/testharness.h"
  8. #include "util/coding.h"
  9. namespace ROCKSDB_NAMESPACE {
  10. TEST(WideColumnsHelperTest, DumpWideColumns) {
  11. WideColumns columns{{"foo", "bar"}, {"hello", "world"}};
  12. std::ostringstream oss;
  13. WideColumnsHelper::DumpWideColumns(columns, oss, false /* hex */);
  14. EXPECT_EQ("foo:bar hello:world", oss.str());
  15. }
  16. TEST(WideColumnsHelperTest, DumpSliceAsWideColumns) {
  17. WideColumns columns{{"foo", "bar"}, {"hello", "world"}};
  18. std::string output;
  19. ASSERT_OK(WideColumnSerialization::Serialize(columns, output));
  20. Slice input(output);
  21. std::ostringstream oss;
  22. ASSERT_OK(
  23. WideColumnsHelper::DumpSliceAsWideColumns(input, oss, false /* hex */));
  24. EXPECT_EQ("foo:bar hello:world", oss.str());
  25. }
  26. } // namespace ROCKSDB_NAMESPACE
  27. int main(int argc, char** argv) {
  28. ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
  29. ::testing::InitGoogleTest(&argc, argv);
  30. return RUN_ALL_TESTS();
  31. }