Direct-BT
2.3.1
Direct-BT - Direct Bluetooth Programming.
|
Go to the documentation of this file.
31 #define CATCH_CONFIG_RUNNER
33 #include <catch2/catch_amalgamated.hpp>
60 TEST_CASE(
"JAU DArray Test 01 - jau::darray initializer list",
"[datatype][jau][darray]" ) {
76 template<
class Payload>
80 template<
class Payload>
84 template<
class Payload>
105 template<
class Payload>
126 template<
class Payload>
130 template<
class Payload>
134 template<
class Payload>
155 template<
class Payload>
176 template<
class Payload>
181 std::shared_ptr<Payload> sp(std::make_shared<Payload>( name+i ));
185 std::shared_ptr<Payload> sp(
new Payload( name+i ));
190 template<
class Payload>
192 printf(
"XXX1: %s\n", src.
toString().c_str());
195 printf(
"XXX2: %s\n", src.
toString().c_str());
199 template<
class Payload>
204 std::shared_ptr<Payload> sp(std::make_shared<Payload>( name+i ));
208 std::shared_ptr<Payload> sp(
new Payload( name+i ));
213 template<
class Payload>
218 Payload sp( name+i );
222 Payload sp( name+i );
227 template<
class Payload>
232 Payload sp( name+i );
236 Payload sp( name+i );
250 #define CHECK_TRAITS 0
252 template<
class Cont >
256 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",
259 std::is_trivially_copyable<typename Cont::value_type>::value,
269 printf(
"\nContainer Type %s (!darray, a cow %d); size %d bytes\n",
274 template<
class Payload>
284 CHECK(
true == std::is_trivially_copyable<Payload>::value);
300 printf(
"COPY-0: %s\n\n", data.
toString().c_str());
301 printf(
"COPY-1: %s\n\n", data2.
toString().c_str());
302 printf(
"COPY-2: %s\n\n", data3.
toString().c_str());
303 printf(
"COPY+2: %s\n\n", data8.
toString().c_str());
309 CHECK(
true == std::is_trivially_copyable<Payload>::value);
325 printf(
"COPY-0: %s\n\n", data.
toString().c_str());
326 printf(
"COPY-1: %s\n\n", data2.
toString().c_str());
327 printf(
"COPY-2: %s\n\n", data3.
toString().c_str());
328 printf(
"COPY+2: %s\n\n", data8.
toString().c_str());
334 CHECK(
true == std::is_trivially_copyable<std::shared_ptr<Payload>>::value);
350 printf(
"COPY-0: %s\n\n", data.
toString().c_str());
351 printf(
"COPY-1: %s\n\n", data2.
toString().c_str());
352 printf(
"COPY-2: %s\n\n", data3.
toString().c_str());
353 printf(
"COPY+2: %s\n\n", data8.
toString().c_str());
356 printf(
"MODI+2-2: %s\n\n", data8_mod.
toString().c_str());
364 Holder holder{ data };
366 printf(
"R1R1: %s\n\n", r1r1.
toString().c_str());
369 printf(
"R1C1: %s\n\n", r2c1.
toString().c_str());
372 printf(
"C1C2: %s\n\n", c1c2.
toString().c_str());
374 r1r1 = holder.get_ref2();
375 printf(
"R2R2: %s\n\n", r1r1.
toString().c_str());
381 CHECK(
true == std::is_trivially_copyable<std::shared_ptr<Payload>>::value);
397 printf(
"COPY-0: %s\n\n", data.
toString().c_str());
398 printf(
"COPY-1: %s\n\n", data2.
toString().c_str());
399 printf(
"COPY-2: %s\n\n", data3.
toString().c_str());
400 printf(
"COPY+2: %s\n\n", data8.
toString().c_str());
411 CHECK(
true == GattCharacteristicSpecList::uses_realloc);
413 CHECK(
true == GattCharacteristicSpecList::uses_memmove);
414 CHECK(
true == std::is_trivially_copyable<GattCharacteristicSpec>::value);
428 printf(
"COPY0-1: %s\n\n", gatt2.
toString().c_str());
429 printf(
"COPY1-2: %s\n\n", gatt2b.
toString().c_str());
430 printf(
"COPY2-3: %s\n\n", gatt2c.
toString().c_str());
433 TEST_CASE(
"JAU DArray Test 02 - jau::darray value_type behavior (type traits)",
"[datatype][jau][darray]" ) {
434 testDArrayValueType<uint64_t>(
"uint64_t");
435 testDArrayValueType<Addr48Bit>(
"Addr48Bit");
436 testDArrayValueType<DataType01>(
"DataType01");
std::string toString() const noexcept
TEST_CASE("JAU DArray Test 01 - jau::darray initializer list", "[datatype][jau][darray]")
std::string toString() const noexcept
template< class T > is_darray_type<T>::value compile-time Type Trait, determining whether the given t...
static NamedPayloadListMemMove< Payload > makeNamedPayloadListMemMove(int name)
constexpr const_iterator cbegin() const noexcept
constexpr UnaryFunction for_each(InputIt first, InputIt last, UnaryFunction f)
Like std::for_each() of 'algorithm'.
template< class T > is_cow_type<T>::value compile-time Type Trait, determining whether the given temp...
PRAGMA_DISABLE_WARNING_POP constexpr_cxx20 std::string to_string(const endian &v) noexcept
Return std::string representation of the given jau::endian.
Implementation of a dynamic linear array storage, aka vector.
constexpr void push_back(const value_type &x)
Like std::vector::push_back(), copy.
static NamedPayloadListDefault< Payload > makeNamedPayloadListDefault(int name)
PayloadListMemMove< Payload > payload
const jau::darray< const GattServiceCharacteristic * > GATT_SERVICES
static GattServiceCharacteristic returnGattSrvcChar(int i)
#define JAU_TYPENAME_CUE_ALL(A)
std::string toString() const noexcept
constexpr size_type size() const noexcept
Like std::vector::size().
static NamedSharedPayloadListMemMove< Payload > makeNamedSharedPayloadListMemMove(int name)
SharedPayloadListMemMove< Payload > payload
jau::darray< GattCharacteristicSpec > characteristics
PayloadListDefault< Payload > payload
std::string toString() const noexcept
SharedPayloadListDefault< Payload > payload
uint_fast32_t nsize_t
Natural 'size_t' alternative using uint_fast32_t as its natural sized type.
static void testDArrayGattServiceCharacteristic()
A simple allocator using POSIX C functions: ::malloc(), ::free() and ::realloc().
static void testDArrayValueType(const std::string &type_id)
static void print_container_info(const std::string &type_id, const Cont &c, std::enable_if_t< jau::is_darray_type< Cont >::value, bool >=true)
static NamedSharedPayloadListDefault< Payload > modifyCopyOfNamedSharedPayloadListDefault(NamedSharedPayloadListDefault< Payload > src)
static NamedSharedPayloadListDefault< Payload > makeNamedSharedPayloadListDefault(int name)
constexpr iterator erase(const_iterator pos)
Like std::vector::erase(), removes the elements at pos.
std::string toString() const noexcept
constexpr const_iterator cend() const noexcept