Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7303 from cbodley/wip-tx-move
os/ObjectStore: add custom move operations for ObjectStore::Transaction Reviewed-by: Kefu Chai <kchai@redhat.com>
- Loading branch information
Showing
4 changed files
with
176 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- | ||
// vim: ts=8 sw=2 smarttab | ||
/* | ||
* Ceph - scalable distributed file system | ||
* | ||
* Copyright (C) 2016 Casey Bodley <cbodley@redhat.com> | ||
* | ||
* This is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License version 2.1, as published by the Free Software | ||
* Foundation. See file COPYING. | ||
* | ||
*/ | ||
|
||
#include "os/ObjectStore.h" | ||
#include <gtest/gtest.h> | ||
|
||
TEST(Transaction, MoveConstruct) | ||
{ | ||
auto a = ObjectStore::Transaction{}; | ||
a.nop(); | ||
ASSERT_FALSE(a.empty()); | ||
|
||
// move-construct in b | ||
auto b = std::move(a); | ||
ASSERT_TRUE(a.empty()); | ||
ASSERT_FALSE(b.empty()); | ||
} | ||
|
||
TEST(Transaction, MoveAssign) | ||
{ | ||
auto a = ObjectStore::Transaction{}; | ||
a.nop(); | ||
ASSERT_FALSE(a.empty()); | ||
|
||
auto b = ObjectStore::Transaction{}; | ||
b = std::move(a); // move-assign to b | ||
ASSERT_TRUE(a.empty()); | ||
ASSERT_FALSE(b.empty()); | ||
} | ||
|
||
TEST(Transaction, CopyConstruct) | ||
{ | ||
auto a = ObjectStore::Transaction{}; | ||
a.nop(); | ||
ASSERT_FALSE(a.empty()); | ||
|
||
auto b = a; // copy-construct in b | ||
ASSERT_FALSE(a.empty()); | ||
ASSERT_FALSE(b.empty()); | ||
} | ||
|
||
TEST(Transaction, CopyAssign) | ||
{ | ||
auto a = ObjectStore::Transaction{}; | ||
a.nop(); | ||
ASSERT_FALSE(a.empty()); | ||
|
||
auto b = ObjectStore::Transaction{}; | ||
b = a; // copy-assign to b | ||
ASSERT_FALSE(a.empty()); | ||
ASSERT_FALSE(b.empty()); | ||
} | ||
|
||
TEST(Transaction, Swap) | ||
{ | ||
auto a = ObjectStore::Transaction{}; | ||
a.nop(); | ||
ASSERT_FALSE(a.empty()); | ||
|
||
auto b = ObjectStore::Transaction{}; | ||
std::swap(a, b); // swap a and b | ||
ASSERT_TRUE(a.empty()); | ||
ASSERT_FALSE(b.empty()); | ||
} |