2018-04-24 07:15:21 +08:00
|
|
|
// Copyright (c) 2018 The LevelDB Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
|
|
|
|
2019-11-22 05:09:53 +08:00
|
|
|
#include "leveldb/status.h"
|
|
|
|
|
2018-04-24 07:15:21 +08:00
|
|
|
#include <utility>
|
|
|
|
|
2019-11-26 01:29:06 +08:00
|
|
|
#include "gtest/gtest.h"
|
2018-04-24 07:15:21 +08:00
|
|
|
#include "leveldb/slice.h"
|
|
|
|
|
|
|
|
namespace leveldb {
|
|
|
|
|
|
|
|
TEST(Status, MoveConstructor) {
|
|
|
|
{
|
|
|
|
Status ok = Status::OK();
|
|
|
|
Status ok2 = std::move(ok);
|
|
|
|
|
|
|
|
ASSERT_TRUE(ok2.ok());
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
Status status = Status::NotFound("custom NotFound status message");
|
|
|
|
Status status2 = std::move(status);
|
|
|
|
|
|
|
|
ASSERT_TRUE(status2.IsNotFound());
|
|
|
|
ASSERT_EQ("NotFound: custom NotFound status message", status2.ToString());
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
Status self_moved = Status::IOError("custom IOError status message");
|
|
|
|
|
|
|
|
// Needed to bypass compiler warning about explicit move-assignment.
|
|
|
|
Status& self_moved_reference = self_moved;
|
|
|
|
self_moved_reference = std::move(self_moved);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace leveldb
|
|
|
|
|
2019-11-22 05:09:53 +08:00
|
|
|
int main(int argc, char** argv) {
|
|
|
|
testing::InitGoogleTest(&argc, argv);
|
|
|
|
return RUN_ALL_TESTS();
|
|
|
|
}
|