status_test.cc 991 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright (c) 2018 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 "leveldb/status.h"
  5. #include <utility>
  6. #include "gtest/gtest.h"
  7. #include "leveldb/slice.h"
  8. namespace leveldb {
  9. TEST(Status, MoveConstructor) {
  10. {
  11. Status ok = Status::OK();
  12. Status ok2 = std::move(ok);
  13. ASSERT_TRUE(ok2.ok());
  14. }
  15. {
  16. Status status = Status::NotFound("custom NotFound status message");
  17. Status status2 = std::move(status);
  18. ASSERT_TRUE(status2.IsNotFound());
  19. ASSERT_EQ("NotFound: custom NotFound status message", status2.ToString());
  20. }
  21. {
  22. Status self_moved = Status::IOError("custom IOError status message");
  23. // Needed to bypass compiler warning about explicit move-assignment.
  24. Status& self_moved_reference = self_moved;
  25. self_moved_reference = std::move(self_moved);
  26. }
  27. }
  28. } // namespace leveldb