leveldb/util/status_test.cc
Victor Costan 8f464e7f68 Remove main() from most tests.
This gives some flexibility to embedders.

Currently, embedders have to build a binary for each test file.

After this CL, embedders can still choose to have a binary for each test
file, by linking each test file with a googletest target that includes
main() (usually "gtest_main"). Embedders can also choose to build a
single binary for almost all test files, and link with a googletest
target that includes main(). The latter is more convenient for projects
that have very few test binaries, like Chromium.

PiperOrigin-RevId: 419470798
2022-01-03 21:05:04 +00:00

40 lines
991 B
C++

// 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.
#include "leveldb/status.h"
#include <utility>
#include "gtest/gtest.h"
#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