MCPcopy Create free account
hub / github.com/alibaba/async_simple / Dummy

Class Dummy

async_simple/test/FutureTest.cpp:48–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46};
47
48struct Dummy {
49 Dummy() : state(nullptr), value(0) {}
50 Dummy(int x) : state(nullptr), value(x) {}
51 Dummy(int* state_) : state(state_), value(0) {
52 if (state) {
53 (*state) |= CONSTRUCTED;
54 }
55 }
56 Dummy(Dummy&& other) : state(other.state), value(other.value) {
57 other.state = nullptr;
58 }
59 Dummy& operator=(Dummy&& other) {
60 if (this != &other) {
61 std::swap(other.state, state);
62 std::swap(other.value, value);
63 }
64 return *this;
65 }
66
67 ~Dummy() {
68 if (state) {
69 (*state) |= DESTRUCTED;
70 state = nullptr;
71 }
72 }
73
74 Dummy(const Dummy&) = delete;
75 Dummy& operator=(const Dummy&) = delete;
76
77 int* state = nullptr;
78 int value = 0;
79
80 Dummy& operator+(const int& rhs) & {
81 value += rhs;
82 return *this;
83 }
84 Dummy&& operator+(const int& rhs) && {
85 value += rhs;
86 return std::move(*this);
87 }
88 Dummy& operator+(const Dummy& rhs) & {
89 value += rhs.value;
90 return *this;
91 }
92 Dummy&& operator+(const Dummy& rhs) && {
93 value += rhs.value;
94 return std::move(*this);
95 }
96
97 bool operator==(const Dummy& other) const { return value == other.value; }
98};
99} // namespace
100
101TEST_F(FutureTest, testSimpleProcess) {

Callers 1

TEST_FFunction · 0.70

Calls 1

swapFunction · 0.50

Tested by 1

TEST_FFunction · 0.56