#include <iostream>
#include <cassert>
#include <cinttypes>
#include <cstring>
#include <random>
#include <vector>
#define CATCH_CONFIG_RUNNER
#include <catch2/catch_amalgamated.hpp>
TEST_CASE(
"JAU DArray Test 01 - jau::darray initializer list",
"[datatype][jau][darray]" ) {
int i = 0;
(void)ml;
++i;
});
REQUIRE(3 == i);
}
template<class Payload>
template<class Payload>
template<class Payload>
int name;
std::string toString() const noexcept {
int i=0;
if(0<i) {
res += ", ";
}
++i;
} );
res += "]";
return res;
}
};
template<class Payload>
int i=0;
if(0<i) {
res += ", ";
}
++i;
} );
res += "]";
return res;
}
};
template<class Payload>
template<class Payload>
template<class Payload>
int i=0;
if(0<i) {
res += ", ";
}
++i;
} );
res += "]";
return res;
}
};
template<class Payload>
int i=0;
if(0<i) {
res += ", ";
}
++i;
} );
res += "]";
return res;
}
};
template<class Payload>
int i=0;
for(i=0; i<2; i++) {
std::shared_ptr<Payload> sp(std::make_shared<Payload>( name+i ));
}
for(i=2; i<4; i++) {
std::shared_ptr<Payload> sp(new Payload( name+i ));
}
}
template<class Payload>
printf(
"XXX1: %s\n", src.
toString().c_str());
printf(
"XXX2: %s\n", src.
toString().c_str());
return src;
}
template<class Payload>
int i=0;
for(i=0; i<2; i++) {
std::shared_ptr<Payload> sp(std::make_shared<Payload>( name+i ));
}
for(i=2; i<4; i++) {
std::shared_ptr<Payload> sp(new Payload( name+i ));
}
}
template<class Payload>
int i=0;
for(i=0; i<2; i++) {
Payload sp( name+i );
}
for(i=2; i<4; i++) {
Payload sp( name+i );
}
}
template<class Payload>
int i=0;
for(i=0; i<2; i++) {
Payload sp( name+i );
}
for(i=2; i<4; i++) {
Payload sp( name+i );
}
}
#define CHECK_TRAITS 0
template< class Cont >
{
printf("\nContainer Type %s (a darray, a cow %d):\n - Uses memcpy %d (trivially_copyable %d); realloc %d; base_of jau::callocator %d; size %d bytes\n",
Cont::uses_memmove,
std::is_trivially_copyable<typename Cont::value_type>::value,
Cont::uses_realloc,
(int)sizeof(c));
}
template<class Cont>
{
printf("\nContainer Type %s (!darray, a cow %d); size %d bytes\n",
}
template<class Payload>
{
}
{
#if CHECK_TRAITS
CHECK( true == std::is_trivially_copyable<Payload>::value);
#endif
data3.payload.erase(data3.payload.begin(), data3.payload.cbegin()+data3.payload.size()/2);
printf(
"COPY-0: %s\n\n", data.
toString().c_str());
printf(
"COPY-1: %s\n\n", data2.
toString().c_str());
printf("COPY-2: %s\n\n", data3.toString().c_str());
printf(
"COPY+2: %s\n\n", data8.
toString().c_str());
}
{
#if CHECK_TRAITS
CHECK( true == std::is_trivially_copyable<Payload>::value);
#endif
data3.payload.erase(data3.payload.begin(), data3.payload.cbegin()+data3.payload.size()/2);
printf(
"COPY-0: %s\n\n", data.
toString().c_str());
printf(
"COPY-1: %s\n\n", data2.
toString().c_str());
printf("COPY-2: %s\n\n", data3.toString().c_str());
printf(
"COPY+2: %s\n\n", data8.
toString().c_str());
}
{
#if CHECK_TRAITS
CHECK( true == std::is_trivially_copyable<std::shared_ptr<Payload>>::value);
#endif
data3.payload.erase(data3.payload.begin(), data3.payload.cbegin()+data3.payload.size()/2);
printf(
"COPY-0: %s\n\n", data.
toString().c_str());
printf(
"COPY-1: %s\n\n", data2.
toString().c_str());
printf("COPY-2: %s\n\n", data3.toString().c_str());
printf(
"COPY+2: %s\n\n", data8.
toString().c_str());
printf("MODI+2-2: %s\n\n", data8_mod.toString().c_str());
struct Holder {
};
Holder holder{ data };
printf(
"R1R1: %s\n\n", r1r1.
toString().c_str());
printf(
"R1C1: %s\n\n", r2c1.
toString().c_str());
printf(
"C1C2: %s\n\n", c1c2.
toString().c_str());
r1r1 = holder.get_ref2();
printf(
"R2R2: %s\n\n", r1r1.
toString().c_str());
}
{
#if CHECK_TRAITS
CHECK( true == std::is_trivially_copyable<std::shared_ptr<Payload>>::value);
#endif
data3.payload.erase(data3.payload.begin(), data3.payload.cbegin()+data3.payload.size()/2);
printf(
"COPY-0: %s\n\n", data.
toString().c_str());
printf(
"COPY-1: %s\n\n", data2.
toString().c_str());
printf("COPY-2: %s\n\n", data3.toString().c_str());
printf(
"COPY+2: %s\n\n", data8.
toString().c_str());
}
}
}
#if CHECK_TRAITS
CHECK( true == GattCharacteristicSpecList::uses_realloc);
CHECK( true == GattCharacteristicSpecList::uses_memmove);
CHECK( true == std::is_trivially_copyable<GattCharacteristicSpec>::value);
#endif
gatt2c.characteristics.erase(gatt2c.characteristics.cbegin());
printf(
"COPY0-1: %s\n\n", gatt2.
toString().c_str());
printf(
"COPY1-2: %s\n\n", gatt2b.
toString().c_str());
printf("COPY2-3: %s\n\n", gatt2c.toString().c_str());
}
TEST_CASE(
"JAU DArray Test 02 - jau::darray value_type behavior (type traits)",
"[datatype][jau][darray]" ) {
testDArrayValueType<uint64_t>("uint64_t");
testDArrayValueType<Addr48Bit>("Addr48Bit");
testDArrayValueType<DataType01>("DataType01");
}