32 #define CATCH_CONFIG_MAIN
33 #include <catch2/catch_amalgamated.hpp>
70 std::shared_ptr<SharedTypeRingbuffer> createEmpty(
jau::nsize_t initialCapacity) {
71 return std::shared_ptr<SharedTypeRingbuffer>(
new SharedTypeRingbuffer(
nullptr, initialCapacity));
73 std::shared_ptr<SharedTypeRingbuffer> createFull(
const std::vector<std::shared_ptr<Integer>> & source) {
78 std::vector<SharedType> array(capacity);
85 void getThreadType01(
const std::string msg, std::shared_ptr<SharedTypeRingbuffer> rb,
jau::nsize_t len) {
100 void getRangeThreadType02(
const std::string msg, std::shared_ptr<SharedTypeRingbuffer> rb,
jau::nsize_t len) {
106 std::vector<SharedType> array(len);
118 void putThreadType01(
const std::string msg, std::shared_ptr<SharedTypeRingbuffer> rb,
jau::nsize_t len,
IntegralType startValue) {
132 void putRangeThreadType02(
const std::string msg, std::shared_ptr<SharedTypeRingbuffer> rb,
jau::nsize_t len,
IntegralType startValue) {
137 std::vector<SharedType> data = createIntArray(len, startValue);
147 INFO_STR(
"\n\ntest01a_Read1Write1\n");
149 std::shared_ptr<SharedTypeRingbuffer> rb = createEmpty(capacity);
153 std::thread getThread01(&TestRingbuffer13::getThreadType01,
this,
"test01a.get01", rb, capacity);
154 std::thread putThread01(&TestRingbuffer13::putThreadType01,
this,
"test01a.put01", rb, capacity, 0);
163 INFO_STR(
"\n\ntest01b_Read1Write1_Range\n");
165 std::shared_ptr<SharedTypeRingbuffer> rb = createEmpty(capacity);
169 std::thread getThread01(&TestRingbuffer13::getRangeThreadType02,
this,
"test01b.getR01", rb, capacity);
170 std::thread putThread01(&TestRingbuffer13::putRangeThreadType02,
this,
"test01b.putR01", rb, capacity, 0);
179 INFO_STR(
"\n\ntest02a_Read4Write1\n");
181 std::shared_ptr<SharedTypeRingbuffer> rb = createEmpty(capacity);
185 std::thread getThread01(&TestRingbuffer13::getThreadType01,
this,
"test02a.get01", rb, capacity/4);
186 std::thread getThread02(&TestRingbuffer13::getThreadType01,
this,
"test02a.get02", rb, capacity/4);
187 std::thread putThread01(&TestRingbuffer13::putThreadType01,
this,
"test02a.put01", rb, capacity, 0);
188 std::thread getThread03(&TestRingbuffer13::getThreadType01,
this,
"test02a.get03", rb, capacity/4);
189 std::thread getThread04(&TestRingbuffer13::getThreadType01,
this,
"test02a.get04", rb, capacity/4);
201 INFO_STR(
"\n\ntest02b_Read4Write1_Range\n");
203 std::shared_ptr<SharedTypeRingbuffer> rb = createEmpty(capacity);
207 std::thread getThread01(&TestRingbuffer13::getRangeThreadType02,
this,
"test02b.getR01", rb, capacity/4);
208 std::thread getThread02(&TestRingbuffer13::getRangeThreadType02,
this,
"test02b.getR02", rb, capacity/4);
209 std::thread putThread01(&TestRingbuffer13::putRangeThreadType02,
this,
"test02b.putR01", rb, capacity, 0);
210 std::thread getThread03(&TestRingbuffer13::getRangeThreadType02,
this,
"test02b.getR03", rb, capacity/4);
211 std::thread getThread04(&TestRingbuffer13::getRangeThreadType02,
this,
"test02b.getR04", rb, capacity/4);
223 INFO_STR(
"\n\ntest03a_Read8Write2\n");
225 std::shared_ptr<SharedTypeRingbuffer> rb = createEmpty(capacity);
229 std::thread getThread01(&TestRingbuffer13::getThreadType01,
this,
"test03a.get01", rb, capacity/8);
230 std::thread getThread02(&TestRingbuffer13::getThreadType01,
this,
"test03a.get02", rb, capacity/8);
231 std::thread putThread01(&TestRingbuffer13::putThreadType01,
this,
"test03a.put01", rb, capacity/2, 0);
232 std::thread getThread03(&TestRingbuffer13::getThreadType01,
this,
"test03a.get03", rb, capacity/8);
233 std::thread getThread04(&TestRingbuffer13::getThreadType01,
this,
"test03a.get04", rb, capacity/8);
235 std::thread getThread05(&TestRingbuffer13::getThreadType01,
this,
"test03a.get05", rb, capacity/8);
236 std::thread getThread06(&TestRingbuffer13::getThreadType01,
this,
"test03a.get06", rb, capacity/8);
237 std::thread putThread02(&TestRingbuffer13::putThreadType01,
this,
"test03a.put02", rb, capacity/2, 400);
238 std::thread getThread07(&TestRingbuffer13::getThreadType01,
this,
"test03a.get07", rb, capacity/8);
239 std::thread getThread08(&TestRingbuffer13::getThreadType01,
this,
"test03a.get08", rb, capacity/8);
257 INFO_STR(
"\n\ntest03b_Read8Write2_Range\n");
259 std::shared_ptr<SharedTypeRingbuffer> rb = createEmpty(capacity);
263 std::thread getThread01(&TestRingbuffer13::getRangeThreadType02,
this,
"test03b.getR01", rb, capacity/8);
264 std::thread getThread02(&TestRingbuffer13::getRangeThreadType02,
this,
"test03b.getR02", rb, capacity/8);
265 std::thread putThread01(&TestRingbuffer13::putRangeThreadType02,
this,
"test03b.putR01", rb, capacity/2, 0);
266 std::thread getThread03(&TestRingbuffer13::getRangeThreadType02,
this,
"test03b.getR03", rb, capacity/8);
267 std::thread getThread04(&TestRingbuffer13::getRangeThreadType02,
this,
"test03b.getR04", rb, capacity/8);
269 std::thread getThread05(&TestRingbuffer13::getRangeThreadType02,
this,
"test03b.getR05", rb, capacity/8);
270 std::thread getThread06(&TestRingbuffer13::getRangeThreadType02,
this,
"test03b.getR06", rb, capacity/8);
271 std::thread putThread02(&TestRingbuffer13::putRangeThreadType02,
this,
"test03b.putR02", rb, capacity/2, 400);
272 std::thread getThread07(&TestRingbuffer13::getRangeThreadType02,
this,
"test03b.getR07", rb, capacity/8);
273 std::thread getThread08(&TestRingbuffer13::getRangeThreadType02,
this,
"test03b.getR08", rb, capacity/8);
291 test01a_Read1Write1();
292 test02a_Read4Write1();
293 test03a_Read8Write2();
295 test01a_Read1Write1();
296 test02a_Read4Write1();
297 test03a_Read8Write2();
299 test03a_Read8Write2();
300 test03a_Read8Write2();
301 test03a_Read8Write2();
306 test01b_Read1Write1_Range();
307 test02b_Read4Write1_Range();
308 test03b_Read8Write2_Range();
310 test01b_Read1Write1_Range();
311 test02b_Read4Write1_Range();
312 test03b_Read8Write2_Range();
314 test01b_Read1Write1_Range();
315 test02b_Read4Write1_Range();
316 test03b_Read8Write2_Range();