status_test.cc
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 5 #include <utility> 6 7 #include "leveldb/slice.h" 8 #include "leveldb/status.h" 9 #include "util/testharness.h" 10 11 namespace leveldb { 12 13 TEST(Status, MoveConstructor) { 14 { 15 Status ok = Status::OK(); 16 Status ok2 = std::move(ok); 17 18 ASSERT_TRUE(ok2.ok()); 19 } 20 21 { 22 Status status = Status::NotFound("custom NotFound status message"); 23 Status status2 = std::move(status); 24 25 ASSERT_TRUE(status2.IsNotFound()); 26 ASSERT_EQ("NotFound: custom NotFound status message", status2.ToString()); 27 } 28 29 { 30 Status self_moved = Status::IOError("custom IOError status message"); 31 32 // Needed to bypass compiler warning about explicit move-assignment. 33 Status& self_moved_reference = self_moved; 34 self_moved_reference = std::move(self_moved); 35 } 36 } 37 38 } // namespace leveldb 39 40 int main(int argc, char** argv) { return leveldb::test::RunAllTests(); }