Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
test_lfringbuffer03.cpp
Go to the documentation of this file.
1/*
2 * Author: Sven Gothel <sgothel@jausoft.com>
3 * Copyright (c) 2020 Gothel Software e.K.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24#include <cassert>
25#include <cinttypes>
26#include <cstring>
27#include <memory>
28
29#include <jau/ringbuffer.hpp>
30
32
33using namespace jau;
34
36
37class Integer {
38 public:
40
42
43 Integer() noexcept : value(-1) { }
44
45 Integer(const Integer &o) noexcept = default;
46 Integer(Integer &&o) noexcept = default;
47 Integer& operator=(const Integer &o) noexcept = default;
48 Integer& operator=(Integer &&o) noexcept = default;
49
50 operator Integral_type() const {
51 return value;
52 }
53 Integral_type getValue() const { return value; }
54 static Integer valueOf(const Integral_type i) { return Integer(i); }
55};
56typedef std::shared_ptr<Integer> Value_type;
57
58template<>
59Value_type getDefault() { return std::make_shared<Integer>(); }
60
61template<>
62Value_type createValue(const Integral_type& v) { return std::make_shared<Integer>(v); }
63
64template<>
65Integral_type getValue(const Value_type& e) { return e->getValue(); }
66
67TEST_CASE( "TestRingbuffer_A_03_a<Integral_type=jau::snsize_t, Value_type=std::shared_ptr<Integer>, Size_type=jau::nsize_t, exp_memmove=false, exp_memcpy=false, exp_secmem=false>", "[ringbuffer]" ) {
69 false /* exp_memmove */, false /* exp_memcpy */, false /* exp_secmem */>();
70}
71
72TEST_CASE( "TestRingbuffer_A_03_c<Integral_type=jau::snsize_t, Value_type=std::shared_ptr<Integer>, Size_type=jau::nsize_t, exp_memmove=false, exp_memcpy=false, exp_secmem=true>", "[ringbuffer]" ) {
74 false /* exp_memmove */, false /* exp_memcpy */, true /* exp_secmem */,
75 false /* use_memmove */, false /* use_memcpy */, true /* use_secmem */>();
76}
Integer(const Integer &o) noexcept=default
static Integer valueOf(const Integral_type i)
Integral_type value
Integer(Integer &&o) noexcept=default
Integer(Integral_type v)
Integral_type getValue() const
Integer & operator=(Integer &&o) noexcept=default
Integer() noexcept
Integer & operator=(const Integer &o) noexcept=default
uint_fast32_t nsize_t
Natural 'size_t' alternative using uint_fast32_t as its natural sized type.
Definition: int_types.hpp:53
int_fast32_t snsize_t
Natural 'ssize_t' alternative using int_fast32_t as its natural sized type.
Definition: int_types.hpp:65
__pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
Definition: backtrace.hpp:32
uint8_t Value_type
uint8_t Integral_type
jau::snsize_t Integral_type
Value_type createValue(const Integral_type &v)
Value_type getDefault()
TEST_CASE("TestRingbuffer_A_03_a<Integral_type=jau::snsize_t, Value_type=std::shared_ptr<Integer>, Size_type=jau::nsize_t, exp_memmove=false, exp_memcpy=false, exp_secmem=false>", "[ringbuffer]")
std::shared_ptr< Integer > Value_type
Integral_type getValue(const Value_type &e)
void PerformRingbufferTests()