#include <iostream>
#include <cassert>
#include <cinttypes>
#include <cstring>
#include <memory>
#define CATCH_CONFIG_MAIN
#include <catch2/catch_amalgamated.hpp>
private:
return rb;
}
return rb;
}
std::vector<TrivialType> array(capacity);
}
return array;
}
(void) clearRef;
}
}
(void) clearRef;
}
}
(void) clearRef;
std::vector<TrivialType> array(len);
}
}
}
}
}
}
}
}
}
public:
void test00_PrintInfo() {
", trivially_copyable "+
std::to_string(std::is_trivially_copyable<typename TrivialTypeRingbuffer::value_type>::value)+
fprintf(stderr, "%s", msg.c_str());
}
void test01_FullRead() {
std::vector<TrivialType> source = createIntArray(capacity, 0);
readTestImpl(rb, true, capacity, capacity, 0);
}
void test02_EmptyWrite() {
INFO( std::string(
"test02_EmptyWrite: Created / ") + rb.
toString().c_str());
writeTestImpl(rb, capacity, capacity, 0);
INFO( std::string(
"test02_EmptyWrite: PostWrite / ") + rb.
toString().c_str());
readTestImpl(rb, true, capacity, capacity, 0);
INFO( std::string(
"test02_EmptyWrite: PostRead / ") + rb.
toString().c_str());
}
void test03_EmptyWriteRange() {
{
INFO( std::string(
"test03_EmptyWriteRange: Created / ") + rb.
toString().c_str());
std::vector<TrivialType> new_data = createIntArray(capacity, 0);
writeRangeTestImpl(rb, capacity, new_data);
INFO( std::string(
"test03_EmptyWriteRange: PostWrite / ") + rb.
toString().c_str());
readRangeTestImpl(rb, true, capacity, capacity, 0);
INFO( std::string(
"test03_EmptyWriteRange: PostRead / ") + rb.
toString().c_str());
}
{
INFO( std::string(
"test03_EmptyWriteRange: Created / ") + rb.
toString().c_str());
std::vector<TrivialType> new_data = createIntArray(capacity, 0);
writeRangeTestImpl(rb, capacity, new_data);
INFO( std::string(
"test03_EmptyWriteRange: PostWrite / ") + rb.
toString().c_str());
readRangeTestImpl(rb, true, capacity, capacity, 0);
INFO( std::string(
"test03_EmptyWriteRange: PostRead / ") + rb.
toString().c_str());
}
{
INFO( std::string(
"test03_EmptyWriteRange: Created / ") + rb.
toString().c_str());
std::vector<TrivialType> new_data = createIntArray(capacity-2, 0);
writeRangeTestImpl(rb, capacity, new_data);
INFO( std::string(
"test03_EmptyWriteRange: PostWrite / ") + rb.
toString().c_str());
readRangeTestImpl(rb, true, capacity, capacity-2, 0);
INFO( std::string(
"test03_EmptyWriteRange: PostRead / ") + rb.
toString().c_str());
}
{
INFO( std::string(
"test03_EmptyWriteRange: Created / ") + rb.
toString().c_str());
for(
int i=0; i<11; i++) { rb.
put(dummy); }
for(
int i=0; i<2; i++) { rb.
put(dummy); }
std::vector<TrivialType> new_data = createIntArray(capacity-3, 0);
writeRangeTestImpl(rb, capacity, new_data);
INFO( std::string(
"test03_EmptyWriteRange: PostWrite / ") + rb.
toString().c_str());
readRangeTestImpl(rb, true, capacity, capacity-3, 0);
INFO( std::string(
"test03_EmptyWriteRange: PostRead / ") + rb.
toString().c_str());
}
}
void test04_FullReadReset() {
std::vector<TrivialType> source = createIntArray(capacity, 0);
readTestImpl(rb, false, capacity, capacity, 0);
readTestImpl2(rb, false, capacity, capacity, 0);
}
void test05_EmptyWriteClear() {
writeTestImpl(rb, capacity, capacity, 0);
readTestImpl(rb, false, capacity, capacity, 0);
writeTestImpl(rb, capacity, capacity, 0);
readTestImpl2(rb, false, capacity, capacity, 0);
}
void test06_ReadResetMid01() {
std::vector<TrivialType> source = createIntArray(capacity, 0);
readTestImpl(rb, false, capacity, 5, 0);
readTestImpl(rb, false, capacity, capacity, 0);
}
void test07_ReadResetMid02() {
std::vector<TrivialType> source = createIntArray(capacity, 0);
moveGetPutImpl(rb, 5);
readTestImpl(rb, false, capacity, 5, 5);
readTestImpl(rb, false, capacity, capacity, 0);
}
private:
std::vector<TrivialType> source = createIntArray(initialCapacity, 0);
}
moveGetPutImpl(rb, pos);
}
}
}
}
public:
void test20_GrowFull01_Begin() {
test_GrowFullImpl(11, 0);
}
void test21_GrowFull02_Begin1() {
test_GrowFullImpl(11, 0+1);
}
void test22_GrowFull03_Begin2() {
test_GrowFullImpl(11, 0+2);
}
void test23_GrowFull04_Begin3() {
test_GrowFullImpl(11, 0+3);
}
void test24_GrowFull05_End() {
test_GrowFullImpl(11, 11-1);
}
void test25_GrowFull11_End1() {
test_GrowFullImpl(11, 11-1-1);
}
void test26_GrowFull12_End2() {
test_GrowFullImpl(11, 11-1-2);
}
void test27_GrowFull13_End3() {
test_GrowFullImpl(11, 11-1-3);
}
};
#if 1
#else
#endif