60 int test_int_smaller = 5;
61 int test_int_bigger = 15;
62 std::string test_string_smaller =
"apple";
63 std::string test_string_bigger =
"cat";
65 std::unique_ptr<TypedAtomicOpFunctor<int>> amo_op_int =
66 std::make_unique<AtomicOpMin<int>>(10);
67 std::unique_ptr<TypedAtomicOpFunctor<std::string>> amo_op_string =
68 std::make_unique<AtomicOpMin<std::string>>(
"base");
69 amo_op_int->execute(&test_int_smaller);
70 amo_op_int->execute(&test_int_bigger);
71 amo_op_string->execute(&test_string_smaller);
72 amo_op_string->execute(&test_string_bigger);
74 EXPECT_EQ(test_int_smaller, 5);
75 EXPECT_EQ(test_int_bigger, 10);
76 EXPECT_EQ(test_string_smaller,
"apple");
77 EXPECT_EQ(test_string_bigger,
"base");
82 int test_int_smaller = 5;
83 int test_int_bigger = 15;
84 std::string test_string_smaller =
"apple";
85 std::string test_string_bigger =
"cat";
87 std::unique_ptr<TypedAtomicOpFunctor<int>> amo_op_int =
88 std::make_unique<AtomicOpMax<int>>(10);
89 std::unique_ptr<TypedAtomicOpFunctor<std::string>> amo_op_string =
90 std::make_unique<AtomicOpMax<std::string>>(
"base");
91 amo_op_int->execute(&test_int_smaller);
92 amo_op_int->execute(&test_int_bigger);
93 amo_op_string->execute(&test_string_smaller);
94 amo_op_string->execute(&test_string_bigger);
96 EXPECT_EQ(test_int_smaller, 10);
97 EXPECT_EQ(test_int_bigger, 15);
98 EXPECT_EQ(test_string_smaller,
"base");
99 EXPECT_EQ(test_string_bigger,
"cat");
105 char test_char =
'c';
107 std::unique_ptr<TypedAtomicOpFunctor<int>> amo_op_int =
108 std::make_unique<AtomicOpDec<int>>();
109 std::unique_ptr<TypedAtomicOpFunctor<char>> amo_op_char =
110 std::make_unique<AtomicOpDec<char>>();
111 amo_op_int->execute(&test_int);
112 amo_op_char->execute(&test_char);
114 EXPECT_EQ(test_int, 9);
115 EXPECT_EQ(test_char,
'b');
121 char test_char =
'c';
123 std::unique_ptr<TypedAtomicOpFunctor<int>> amo_op_int =
124 std::make_unique<AtomicOpInc<int>>();
125 std::unique_ptr<TypedAtomicOpFunctor<char>> amo_op_char =
126 std::make_unique<AtomicOpInc<char>>();
127 amo_op_int->execute(&test_int);
128 amo_op_char->execute(&test_char);
130 EXPECT_EQ(test_int, 11);
131 EXPECT_EQ(test_char,
'd');
137 char test_char =
'c';
139 std::unique_ptr<TypedAtomicOpFunctor<int>> amo_op_int =
140 std::make_unique<AtomicOpSub<int>>(2);
141 std::unique_ptr<TypedAtomicOpFunctor<char>> amo_op_char =
142 std::make_unique<AtomicOpSub<char>>(
'a');
143 amo_op_int->execute(&test_int);
144 amo_op_char->execute(&test_char);
146 EXPECT_EQ(test_int, 8);
147 EXPECT_EQ(test_char, 2);
153 char test_char =
'c';
155 std::unique_ptr<TypedAtomicOpFunctor<int>> amo_op_int =
156 std::make_unique<AtomicOpAdd<int>>(2);
157 std::unique_ptr<TypedAtomicOpFunctor<char>> amo_op_char =
158 std::make_unique<AtomicOpAdd<char>>(2);
159 amo_op_int->execute(&test_int);
160 amo_op_char->execute(&test_char);
162 EXPECT_EQ(test_int, 12);
163 EXPECT_EQ(test_char,
'e');
169 char test_char =
'c';
171 std::unique_ptr<TypedAtomicOpFunctor<int>> amo_op_int =
172 std::make_unique<AtomicOpExch<int>>(2);
173 std::unique_ptr<TypedAtomicOpFunctor<char>> amo_op_char =
174 std::make_unique<AtomicOpExch<char>>(
'a');
175 amo_op_int->execute(&test_int);
176 amo_op_char->execute(&test_char);
178 EXPECT_EQ(test_int, 2);
179 EXPECT_EQ(test_char,
'a');
185 char test_char =
'c';
187 std::unique_ptr<TypedAtomicOpFunctor<int>> amo_op_int =
188 std::make_unique<AtomicOpXor<int>>(2);
189 std::unique_ptr<TypedAtomicOpFunctor<char>> amo_op_char =
190 std::make_unique<AtomicOpXor<char>>(
'a');
191 amo_op_int->execute(&test_int);
192 amo_op_char->execute(&test_char);
194 EXPECT_EQ(test_int, 8);
195 EXPECT_EQ(test_char, 2);
201 bool test_bool =
true;
203 std::unique_ptr<TypedAtomicOpFunctor<int>> amo_op_int =
204 std::make_unique<AtomicOpOr<int>>(2);
205 std::unique_ptr<TypedAtomicOpFunctor<bool>> amo_op_bool =
206 std::make_unique<AtomicOpOr<bool>>(
false);
207 amo_op_int->execute(&test_int);
208 amo_op_bool->execute(&test_bool);
210 EXPECT_EQ(test_int, 10);
211 EXPECT_EQ(test_bool,
true);
217 char test_char =
'c';
219 std::unique_ptr<TypedAtomicOpFunctor<int>> amo_op_int =
220 std::make_unique<AtomicOpAnd<int>>(6);
221 std::unique_ptr<TypedAtomicOpFunctor<char>> amo_op_char =
222 std::make_unique<AtomicOpAnd<char>>(
'a');
223 amo_op_int->execute(&test_int);
224 amo_op_char->execute(&test_char);
226 EXPECT_EQ(test_int, 2);
227 EXPECT_EQ(test_char,
'a');