62 int test_int_smaller = 5;
63 int test_int_bigger = 15;
64 std::string test_string_smaller =
"apple";
65 std::string test_string_bigger =
"cat";
67 std::unique_ptr<TypedAtomicOpFunctor<int>> amo_op_int =
68 std::make_unique<AtomicOpMin<int>>(10);
69 std::unique_ptr<TypedAtomicOpFunctor<std::string>> amo_op_string =
70 std::make_unique<AtomicOpMin<std::string>>(
"base");
71 amo_op_int->execute(&test_int_smaller);
72 amo_op_int->execute(&test_int_bigger);
73 amo_op_string->execute(&test_string_smaller);
74 amo_op_string->execute(&test_string_bigger);
76 EXPECT_EQ(test_int_smaller, 5);
77 EXPECT_EQ(test_int_bigger, 10);
78 EXPECT_EQ(test_string_smaller,
"apple");
79 EXPECT_EQ(test_string_bigger,
"base");
84 int test_int_smaller = 5;
85 int test_int_bigger = 15;
86 std::string test_string_smaller =
"apple";
87 std::string test_string_bigger =
"cat";
89 std::unique_ptr<TypedAtomicOpFunctor<int>> amo_op_int =
90 std::make_unique<AtomicOpMax<int>>(10);
91 std::unique_ptr<TypedAtomicOpFunctor<std::string>> amo_op_string =
92 std::make_unique<AtomicOpMax<std::string>>(
"base");
93 amo_op_int->execute(&test_int_smaller);
94 amo_op_int->execute(&test_int_bigger);
95 amo_op_string->execute(&test_string_smaller);
96 amo_op_string->execute(&test_string_bigger);
98 EXPECT_EQ(test_int_smaller, 10);
99 EXPECT_EQ(test_int_bigger, 15);
100 EXPECT_EQ(test_string_smaller,
"base");
101 EXPECT_EQ(test_string_bigger,
"cat");
107 char test_char =
'c';
109 std::unique_ptr<TypedAtomicOpFunctor<int>> amo_op_int =
110 std::make_unique<AtomicOpDec<int>>();
111 std::unique_ptr<TypedAtomicOpFunctor<char>> amo_op_char =
112 std::make_unique<AtomicOpDec<char>>();
113 amo_op_int->execute(&test_int);
114 amo_op_char->execute(&test_char);
116 EXPECT_EQ(test_int, 9);
117 EXPECT_EQ(test_char,
'b');
123 char test_char =
'c';
125 std::unique_ptr<TypedAtomicOpFunctor<int>> amo_op_int =
126 std::make_unique<AtomicOpInc<int>>();
127 std::unique_ptr<TypedAtomicOpFunctor<char>> amo_op_char =
128 std::make_unique<AtomicOpInc<char>>();
129 amo_op_int->execute(&test_int);
130 amo_op_char->execute(&test_char);
132 EXPECT_EQ(test_int, 11);
133 EXPECT_EQ(test_char,
'd');
139 char test_char =
'c';
141 std::unique_ptr<TypedAtomicOpFunctor<int>> amo_op_int =
142 std::make_unique<AtomicOpSub<int>>(2);
143 std::unique_ptr<TypedAtomicOpFunctor<char>> amo_op_char =
144 std::make_unique<AtomicOpSub<char>>(
'a');
145 amo_op_int->execute(&test_int);
146 amo_op_char->execute(&test_char);
148 EXPECT_EQ(test_int, 8);
149 EXPECT_EQ(test_char, 2);
155 char test_char =
'c';
157 std::unique_ptr<TypedAtomicOpFunctor<int>> amo_op_int =
158 std::make_unique<AtomicOpAdd<int>>(2);
159 std::unique_ptr<TypedAtomicOpFunctor<char>> amo_op_char =
160 std::make_unique<AtomicOpAdd<char>>(2);
161 amo_op_int->execute(&test_int);
162 amo_op_char->execute(&test_char);
164 EXPECT_EQ(test_int, 12);
165 EXPECT_EQ(test_char,
'e');
171 char test_char =
'c';
173 std::unique_ptr<TypedAtomicOpFunctor<int>> amo_op_int =
174 std::make_unique<AtomicOpExch<int>>(2);
175 std::unique_ptr<TypedAtomicOpFunctor<char>> amo_op_char =
176 std::make_unique<AtomicOpExch<char>>(
'a');
177 amo_op_int->execute(&test_int);
178 amo_op_char->execute(&test_char);
180 EXPECT_EQ(test_int, 2);
181 EXPECT_EQ(test_char,
'a');
187 char test_char =
'c';
189 std::unique_ptr<TypedAtomicOpFunctor<int>> amo_op_int =
190 std::make_unique<AtomicOpXor<int>>(2);
191 std::unique_ptr<TypedAtomicOpFunctor<char>> amo_op_char =
192 std::make_unique<AtomicOpXor<char>>(
'a');
193 amo_op_int->execute(&test_int);
194 amo_op_char->execute(&test_char);
196 EXPECT_EQ(test_int, 8);
197 EXPECT_EQ(test_char, 2);
203 bool test_bool =
true;
205 std::unique_ptr<TypedAtomicOpFunctor<int>> amo_op_int =
206 std::make_unique<AtomicOpOr<int>>(2);
207 std::unique_ptr<TypedAtomicOpFunctor<bool>> amo_op_bool =
208 std::make_unique<AtomicOpOr<bool>>(
false);
209 amo_op_int->execute(&test_int);
210 amo_op_bool->execute(&test_bool);
212 EXPECT_EQ(test_int, 10);
213 EXPECT_EQ(test_bool,
true);
219 char test_char =
'c';
221 std::unique_ptr<TypedAtomicOpFunctor<int>> amo_op_int =
222 std::make_unique<AtomicOpAnd<int>>(6);
223 std::unique_ptr<TypedAtomicOpFunctor<char>> amo_op_char =
224 std::make_unique<AtomicOpAnd<char>>(
'a');
225 amo_op_int->execute(&test_int);
226 amo_op_char->execute(&test_char);
228 EXPECT_EQ(test_int, 2);
229 EXPECT_EQ(test_char,
'a');