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