Compare commits
3 Commits
d8dd2fae04
...
28bf870959
Author | SHA1 | Date | |
---|---|---|---|
28bf870959 | |||
a354ded3de | |||
d4493c2994 |
@ -76,13 +76,13 @@ class deque {
|
|||||||
//! @{
|
//! @{
|
||||||
public:
|
public:
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
deque () noexcept :
|
constexpr deque () noexcept :
|
||||||
data_{},
|
data_{},
|
||||||
f{data_.data(), N},
|
f{data_.data(), N},
|
||||||
r{data_.data()} { }
|
r{data_.data()} { }
|
||||||
|
|
||||||
//! fill contructor
|
//! fill contructor
|
||||||
deque(const Data_t& value) noexcept {
|
constexpr deque(const Data_t& value) noexcept {
|
||||||
data_.fill(value);
|
data_.fill(value);
|
||||||
f = iterator(data_.data(), N);
|
f = iterator(data_.data(), N);
|
||||||
r = iterator(data_.data(), N);
|
r = iterator(data_.data(), N);
|
||||||
@ -90,9 +90,9 @@ class deque {
|
|||||||
|
|
||||||
//! Initializer list contructor
|
//! Initializer list contructor
|
||||||
template <typename ...It>
|
template <typename ...It>
|
||||||
deque(It&& ...it) noexcept :
|
constexpr deque(It&& ...it) noexcept :
|
||||||
data_{{std::forward<It>(it)...}},
|
data_{{std::forward<It>(it)...}},
|
||||||
f(data_.data(), sizeof...(It)),
|
f(data_.data(), N),
|
||||||
r(data_.data(), sizeof...(It)) { }
|
r(data_.data(), sizeof...(It)) { }
|
||||||
|
|
||||||
deque(const deque&) = delete; //!< No copies
|
deque(const deque&) = delete; //!< No copies
|
||||||
@ -103,38 +103,38 @@ class deque {
|
|||||||
//! \name Iterators
|
//! \name Iterators
|
||||||
//! @{
|
//! @{
|
||||||
public:
|
public:
|
||||||
iterator begin() noexcept { return f+1; }
|
constexpr iterator begin() noexcept { return f+1; }
|
||||||
const_iterator begin() const noexcept { return f+1; }
|
constexpr const_iterator begin() const noexcept { return f+1; }
|
||||||
const_iterator cbegin() const noexcept { return f+1; }
|
constexpr const_iterator cbegin() const noexcept { return f+1; }
|
||||||
|
|
||||||
iterator end() noexcept { return r; }
|
constexpr iterator end() noexcept { return r; }
|
||||||
const_iterator end() const noexcept { return r; }
|
constexpr const_iterator end() const noexcept { return r; }
|
||||||
const_iterator cend() const noexcept { return r; }
|
constexpr const_iterator cend() const noexcept { return r; }
|
||||||
|
|
||||||
reverse_iterator rbegin() noexcept { return r; }
|
constexpr reverse_iterator rbegin() noexcept { return r; }
|
||||||
const_reverse_iterator rbegin() const noexcept { return r; }
|
constexpr const_reverse_iterator rbegin() const noexcept { return r; }
|
||||||
const_reverse_iterator crbegin() const noexcept { return r; }
|
constexpr const_reverse_iterator crbegin() const noexcept { return r; }
|
||||||
|
|
||||||
reverse_iterator rend() noexcept { return f+1; }
|
constexpr reverse_iterator rend() noexcept { return f+1; }
|
||||||
const_reverse_iterator rend() const noexcept { return f+1; }
|
constexpr const_reverse_iterator rend() const noexcept { return f+1; }
|
||||||
const_reverse_iterator crend() const noexcept { return f+1; }
|
constexpr const_reverse_iterator crend() const noexcept { return f+1; }
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
//! \name Capacity
|
//! \name Capacity
|
||||||
//! @{
|
//! @{
|
||||||
public:
|
public:
|
||||||
//! \return The size of the deque. The items currently in queue.
|
//! \return The size of the deque. The items currently in queue.
|
||||||
size_t size() noexcept {
|
constexpr size_t size() noexcept {
|
||||||
return full() ? N: (r - f) -1;
|
return full() ? N: (r - f) -1;
|
||||||
}
|
}
|
||||||
//! \return The maximum size of the deque. The items the queue can hold.
|
//! \return The maximum size of the deque. The items the queue can hold.
|
||||||
size_t max_size() noexcept { return N; }
|
constexpr size_t max_size() noexcept { return N; }
|
||||||
//! \return The capacity of the deque. The items the queue can hold.
|
//! \return The capacity of the deque. The items the queue can hold.
|
||||||
size_t capacity() noexcept { return N; }
|
constexpr size_t capacity() noexcept { return N; }
|
||||||
//! \return True if the deque is empty
|
//! \return True if the deque is empty
|
||||||
bool empty() noexcept { return size() == 0 ? true : false; }
|
constexpr bool empty() noexcept { return size() == 0 ? true : false; }
|
||||||
//! \return True if the deque is full
|
//! \return True if the deque is full
|
||||||
bool full() noexcept { return (r == f) ? true : false; }
|
constexpr bool full() noexcept { return (r == f) ? true : false; }
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
//! \name Member access
|
//! \name Member access
|
||||||
@ -142,44 +142,44 @@ class deque {
|
|||||||
public:
|
public:
|
||||||
//! \brief Clears-empty the deque and return it to init state, without
|
//! \brief Clears-empty the deque and return it to init state, without
|
||||||
//! really deleting the contents.
|
//! really deleting the contents.
|
||||||
void clear() noexcept {
|
constexpr void clear() noexcept {
|
||||||
f = iterator_t(data_.data(), N);
|
f = iterator_t(data_.data(), N);
|
||||||
r = iterator_t(data_.data());
|
r = iterator_t(data_.data());
|
||||||
}
|
}
|
||||||
//! \brief Push an item in the front of the deque
|
//! \brief Push an item in the front of the deque
|
||||||
//! \param it The item to push
|
//! \param it The item to push
|
||||||
void push_front (const Data_t& it) {
|
constexpr void push_front (const Data_t& it) {
|
||||||
if (full()) return;
|
if (full()) return;
|
||||||
*f-- = it;
|
*f-- = it;
|
||||||
}
|
}
|
||||||
//! \brief Extract an item from the front of the deque and remove it from the deque
|
//! \brief Extract an item from the front of the deque and remove it from the deque
|
||||||
//! \param it The item to push
|
//! \param it The item to push
|
||||||
Data_t pop_front () {
|
constexpr Data_t pop_front () {
|
||||||
if (empty()) return Data_t{};
|
if (empty()) return Data_t{};
|
||||||
return *++f;
|
return *++f;
|
||||||
}
|
}
|
||||||
//! \brief Push an item in the back of the deque
|
//! \brief Push an item in the back of the deque
|
||||||
//! \param it The item to push
|
//! \param it The item to push
|
||||||
void push_back (const Data_t& it) {
|
constexpr void push_back (const Data_t& it) {
|
||||||
if (full()) return;
|
if (full()) return;
|
||||||
*r++ = it;
|
*r++ = it;
|
||||||
}
|
}
|
||||||
//! \brief Extract an item from the back of the deque and remove it from the deque
|
//! \brief Extract an item from the back of the deque and remove it from the deque
|
||||||
//! \param it The item to push
|
//! \param it The item to push
|
||||||
Data_t pop_back () {
|
constexpr Data_t pop_back () {
|
||||||
if (empty()) return Data_t{};
|
if (empty()) return Data_t{};
|
||||||
return *--r;
|
return *--r;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \brief Get a reference to the item in the front of the deque without extracting it.
|
//! \brief Get a reference to the item in the front of the deque without extracting it.
|
||||||
//! \return Reference to the item
|
//! \return Reference to the item
|
||||||
Data_t& front() noexcept { return *(f+1); }
|
constexpr Data_t& front() noexcept { return *(f+1); }
|
||||||
const Data_t& front() const noexcept { return *(f+1); }
|
constexpr const Data_t& front() const noexcept { return *(f+1); }
|
||||||
|
|
||||||
//! \brief Get a reference to the item in the front of the deque without extracting it.
|
//! \brief Get a reference to the item in the front of the deque without extracting it.
|
||||||
//! \return Reference to the item
|
//! \return Reference to the item
|
||||||
Data_t& back() noexcept { return *(r-1); }
|
constexpr Data_t& back() noexcept { return *(r-1); }
|
||||||
const Data_t& back() const noexcept { return *(r-1); }
|
constexpr const Data_t& back() const noexcept { return *(r-1); }
|
||||||
|
|
||||||
//! @}
|
//! @}
|
||||||
private:
|
private:
|
||||||
|
@ -56,7 +56,7 @@ namespace tbx {
|
|||||||
* \c Fn
|
* \c Fn
|
||||||
*
|
*
|
||||||
* \tparam Data_t The char-like queued item type. Usually \c char
|
* \tparam Data_t The char-like queued item type. Usually \c char
|
||||||
* \tparam N The size of deque
|
* \tparam N The size of edeque
|
||||||
* \tparam Fn The type of Callable
|
* \tparam Fn The type of Callable
|
||||||
*/
|
*/
|
||||||
template <typename Data_t, size_t N, typename Fn = std::function<void()>>
|
template <typename Data_t, size_t N, typename Fn = std::function<void()>>
|
||||||
@ -117,11 +117,11 @@ class edeque : public deque<Data_t, N> {
|
|||||||
//! @{
|
//! @{
|
||||||
public:
|
public:
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
edeque () noexcept :
|
constexpr edeque () noexcept :
|
||||||
base_type() { }
|
base_type() { }
|
||||||
|
|
||||||
//!
|
//!
|
||||||
edeque (size_match match, size_t size, callable_t&& fn) :
|
constexpr edeque (size_match match, size_t size, callable_t&& fn) :
|
||||||
base_type(),
|
base_type(),
|
||||||
mode_{match_mode::SIZE},
|
mode_{match_mode::SIZE},
|
||||||
callback_{std::forward<callable_t>(fn)} {
|
callback_{std::forward<callable_t>(fn)} {
|
||||||
@ -129,7 +129,7 @@ class edeque : public deque<Data_t, N> {
|
|||||||
trigger_.tsize.size = size;
|
trigger_.tsize.size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
edeque (data_match match, Data_t value, callable_t&& fn) :
|
constexpr edeque (data_match match, Data_t value, callable_t&& fn) :
|
||||||
base_type(),
|
base_type(),
|
||||||
mode_{match_mode::DATA},
|
mode_{match_mode::DATA},
|
||||||
callback_{std::forward<callable_t>(fn)} {
|
callback_{std::forward<callable_t>(fn)} {
|
||||||
|
144
include/cont/equeue.h
Normal file
144
include/cont/equeue.h
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
/*!
|
||||||
|
* \file cont/equeue.h
|
||||||
|
* \brief
|
||||||
|
* A queue with event based callables based on edeque.
|
||||||
|
*
|
||||||
|
* \copyright Copyright (C) 2021 Christos Choutouridis <christos@choutouridis.net>
|
||||||
|
*
|
||||||
|
* <dl class=\"section copyright\"><dt>License</dt><dd>
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
* </dd></dl>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TBX_CONT_EQUQUE_H_
|
||||||
|
#define TBX_CONT_EQUQUE_H_
|
||||||
|
|
||||||
|
#include <core/core.h>
|
||||||
|
#include <cont/edeque.h>
|
||||||
|
|
||||||
|
namespace tbx {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \class equeue
|
||||||
|
* \brief
|
||||||
|
* A statically allocated queue based on edeque with size and data matching
|
||||||
|
* event based callables.
|
||||||
|
*
|
||||||
|
* We use the \ref edeque::push_back() and \ref edeque::pop_front() pair from edeque's
|
||||||
|
* functionality, so at the \c push the increment performed after the insertion.
|
||||||
|
* Similarly at the \c pop the decrement performed before the exctraction. This way also
|
||||||
|
* the \ref edeque::front() and \ref edeque::back() stay the same ;)
|
||||||
|
*
|
||||||
|
* We also provide stream operators.
|
||||||
|
*
|
||||||
|
* \tparam Data_t The char-like queued item type. Usually \c char
|
||||||
|
* \tparam N The size of edeque
|
||||||
|
* \tparam Fn The type of Callable
|
||||||
|
*/
|
||||||
|
template <typename Data_t, size_t N, typename Fn = std::function<void()>>
|
||||||
|
class equeue : public edeque<Data_t, N, Fn> {
|
||||||
|
public:
|
||||||
|
// meta-identity types
|
||||||
|
using equeue_t = equeue<Data_t, N>;
|
||||||
|
using base_type = edeque<Data_t, N, Fn>;
|
||||||
|
|
||||||
|
// STL
|
||||||
|
using value_type = typename base_type::value_type;
|
||||||
|
using reference = typename base_type::reference;
|
||||||
|
using const_reference = typename base_type::const_reference;
|
||||||
|
using pointer = typename base_type::pointer;
|
||||||
|
using const_pointer = typename base_type::const_pointer;
|
||||||
|
using iterator = typename base_type::iterator;
|
||||||
|
using const_iterator = typename base_type::const_iterator;
|
||||||
|
using reverse_iterator = typename base_type::reverse_iterator;
|
||||||
|
using const_reverse_iterator= typename base_type::const_reverse_iterator;
|
||||||
|
|
||||||
|
//! \name Constructor / Destructor
|
||||||
|
//! @{
|
||||||
|
public:
|
||||||
|
//! Default constructor
|
||||||
|
constexpr equeue () noexcept : base_type() { }
|
||||||
|
|
||||||
|
//! fill contructor
|
||||||
|
constexpr equeue(const Data_t& value) noexcept : base_type(value) { }
|
||||||
|
|
||||||
|
//! Initializer list contructor
|
||||||
|
template <typename ...It>
|
||||||
|
constexpr equeue(It&& ...it) noexcept : base_type(std::forward<It>(it)...) { }
|
||||||
|
|
||||||
|
//! @}
|
||||||
|
|
||||||
|
//! \name Member access
|
||||||
|
//! @{
|
||||||
|
public:
|
||||||
|
//! \brief Push an item in the back of the queue
|
||||||
|
//! \param it The item to push
|
||||||
|
void push (const Data_t& it) {
|
||||||
|
base_type::push_back(it);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! \brief Extract an item from the front of the queue and remove it from the queue
|
||||||
|
//! \param it The item to push
|
||||||
|
Data_t pop () {
|
||||||
|
return base_type::pop_front();
|
||||||
|
}
|
||||||
|
|
||||||
|
//! \brief Push an item in the back of the queue
|
||||||
|
//! \param it The item to push
|
||||||
|
equeue_t& operator<< (const Data_t& it) {
|
||||||
|
push(it);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! \brief Push an item in the back of the queue
|
||||||
|
//! \param it The item to push
|
||||||
|
equeue_t& operator>> (Data_t& it) {
|
||||||
|
it = pop();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! @}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
* Pop an item from the front of the queue.
|
||||||
|
*
|
||||||
|
* This definition enables the "data << equeue" syntax for pop operation
|
||||||
|
*
|
||||||
|
* \tparam Data_t The char-like queued item type. Usually \c char
|
||||||
|
* \tparam N The size of queue
|
||||||
|
* \tparam Fn The type of Callable
|
||||||
|
*
|
||||||
|
* \param it The item to write to
|
||||||
|
* \param q The queue to read from
|
||||||
|
* \return Reference to the returned item
|
||||||
|
*/
|
||||||
|
template <typename Data_t, size_t N, typename Fn = std::function<void()>>
|
||||||
|
Data_t& operator<< (Data_t& it, equeue<Data_t, N, Fn>& q) {
|
||||||
|
it = q.pop();
|
||||||
|
return it;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* TBX_CONT_EQUQUE_H_ */
|
@ -37,7 +37,7 @@
|
|||||||
namespace tbx {
|
namespace tbx {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \class deque
|
* \class queue
|
||||||
* \brief
|
* \brief
|
||||||
* A statically allocated queue based on deque.
|
* A statically allocated queue based on deque.
|
||||||
*
|
*
|
||||||
@ -49,7 +49,7 @@ namespace tbx {
|
|||||||
* We also provide stream operators.
|
* We also provide stream operators.
|
||||||
*
|
*
|
||||||
* \tparam Data_t The char-like queued item type. Usually \c char
|
* \tparam Data_t The char-like queued item type. Usually \c char
|
||||||
* \tparam N The size of deque
|
* \tparam N The size of queue
|
||||||
*/
|
*/
|
||||||
template <typename Data_t, size_t N>
|
template <typename Data_t, size_t N>
|
||||||
class queue : public deque<Data_t, N> {
|
class queue : public deque<Data_t, N> {
|
||||||
@ -73,14 +73,14 @@ class queue : public deque<Data_t, N> {
|
|||||||
//! @{
|
//! @{
|
||||||
public:
|
public:
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
queue () noexcept : base_type() { }
|
constexpr queue () noexcept : base_type() { }
|
||||||
|
|
||||||
//! fill contructor
|
//! fill contructor
|
||||||
queue(const Data_t& value) noexcept : base_type(value) { }
|
constexpr queue(const Data_t& value) noexcept : base_type(value) { }
|
||||||
|
|
||||||
//! Initializer list contructor
|
//! Initializer list contructor
|
||||||
template <typename ...It>
|
template <typename ...It>
|
||||||
queue(It&& ...it) noexcept : base_type(std::forward<It>(it)...) { }
|
constexpr queue(It&& ...it) noexcept : base_type(std::forward<It>(it)...) { }
|
||||||
|
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
@ -89,34 +89,51 @@ class queue : public deque<Data_t, N> {
|
|||||||
public:
|
public:
|
||||||
//! \brief Push an item in the back of the queue
|
//! \brief Push an item in the back of the queue
|
||||||
//! \param it The item to push
|
//! \param it The item to push
|
||||||
void push (const Data_t& it) {
|
constexpr void push (const Data_t& it) {
|
||||||
base_type::push_back(it);
|
base_type::push_back(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \brief Extract an item from the front of the queue and remove it from the queue
|
//! \brief Extract an item from the front of the queue and remove it from the queue
|
||||||
//! \param it The item to push
|
//! \param it The item to push
|
||||||
Data_t pop () {
|
constexpr Data_t pop () {
|
||||||
return base_type::pop_front();
|
return base_type::pop_front();
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \brief Push an item in the back of the queue
|
//! \brief Push an item in the back of the queue
|
||||||
//! \param it The item to push
|
//! \param it The item to push
|
||||||
queue_t& operator<< (const Data_t& it) {
|
constexpr queue_t& operator<< (const Data_t& it) {
|
||||||
push(it);
|
push(it);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \brief Push an item in the back of the queue
|
//! \brief Pop an item from the front of the queue
|
||||||
//! \param it The item to push
|
//! \param it The item to write to
|
||||||
queue_t& operator>> (Data_t& it) {
|
constexpr queue_t& operator>> (Data_t& it) {
|
||||||
it = pop();
|
it = pop();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
* Pop an item from the front of the queue.
|
||||||
|
*
|
||||||
|
* This definition enables the "data << queue" syntax for pop operation
|
||||||
|
*
|
||||||
|
* \tparam Data_t The char-like queued item type. Usually \c char
|
||||||
|
* \tparam N The size of queue
|
||||||
|
*
|
||||||
|
* \param it The item to write to
|
||||||
|
* \param q The queue to read from
|
||||||
|
* \return Reference to the returned item
|
||||||
|
*/
|
||||||
|
template <typename Data_t, size_t N>
|
||||||
|
constexpr Data_t& operator<< (Data_t& it, queue<Data_t, N>& q) {
|
||||||
|
it = q.pop();
|
||||||
|
return it;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace tbx
|
||||||
|
|
||||||
#endif /* TBX_CONT_QUQUE_H_ */
|
#endif /* TBX_CONT_QUQUE_H_ */
|
||||||
|
@ -58,16 +58,16 @@ class ring_iterator {
|
|||||||
//! \name Constructor / Destructor
|
//! \name Constructor / Destructor
|
||||||
//! @{
|
//! @{
|
||||||
public:
|
public:
|
||||||
ring_iterator(const Iter_t base =nullptr) noexcept :
|
constexpr ring_iterator(const Iter_t base =nullptr) noexcept :
|
||||||
base_(base), iter_(base) { }
|
base_(base), iter_(base) { }
|
||||||
|
|
||||||
ring_iterator(const Iter_t base, size_t elem) noexcept :
|
constexpr ring_iterator(const Iter_t base, size_t elem) noexcept :
|
||||||
base_(base), iter_(base + elem) { }
|
base_(base), iter_(base + elem) { }
|
||||||
|
|
||||||
ring_iterator(const ring_iterator& it) noexcept :
|
constexpr ring_iterator(const ring_iterator& it) noexcept :
|
||||||
base_(it.base_), iter_(it.iter_) { }
|
base_(it.base_), iter_(it.iter_) { }
|
||||||
|
|
||||||
ring_iterator& operator= (const ring_iterator& it) noexcept {
|
constexpr ring_iterator& operator= (const ring_iterator& it) noexcept {
|
||||||
base_ = it.base_;
|
base_ = it.base_;
|
||||||
iter_ = it.iter_;
|
iter_ = it.iter_;
|
||||||
return *this;
|
return *this;
|
||||||
@ -77,18 +77,21 @@ class ring_iterator {
|
|||||||
//! \name Forward iterator requirements
|
//! \name Forward iterator requirements
|
||||||
//! @{
|
//! @{
|
||||||
public:
|
public:
|
||||||
reference operator*() const noexcept {
|
constexpr reference operator*() const noexcept {
|
||||||
return *iter_;
|
return *iter_;
|
||||||
}
|
}
|
||||||
pointer operator->() const noexcept {
|
|
||||||
|
constexpr pointer operator->() const noexcept {
|
||||||
return iter_;
|
return iter_;
|
||||||
}
|
}
|
||||||
ring_iterator& operator++() noexcept {
|
|
||||||
|
constexpr ring_iterator& operator++() noexcept {
|
||||||
if (static_cast<size_t>(++iter_ - base_) >= N)
|
if (static_cast<size_t>(++iter_ - base_) >= N)
|
||||||
iter_ = base_;
|
iter_ = base_;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
ring_iterator operator++(int) noexcept {
|
|
||||||
|
constexpr ring_iterator operator++(int) noexcept {
|
||||||
ring_iterator it = *this;
|
ring_iterator it = *this;
|
||||||
if (static_cast<size_t>(++iter_ - base_) >= N)
|
if (static_cast<size_t>(++iter_ - base_) >= N)
|
||||||
iter_ = base_;
|
iter_ = base_;
|
||||||
@ -99,12 +102,12 @@ class ring_iterator {
|
|||||||
//! \name Bidirectional iterator requirements
|
//! \name Bidirectional iterator requirements
|
||||||
//! @{
|
//! @{
|
||||||
public:
|
public:
|
||||||
ring_iterator& operator--() noexcept {
|
constexpr ring_iterator& operator--() noexcept {
|
||||||
if (--iter_ < base_)
|
if (--iter_ < base_)
|
||||||
iter_ = base_ + N -1;
|
iter_ = base_ + N -1;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
ring_iterator operator--(int) noexcept {
|
constexpr ring_iterator operator--(int) noexcept {
|
||||||
ring_iterator it = *this;
|
ring_iterator it = *this;
|
||||||
if (--iter_ < base_)
|
if (--iter_ < base_)
|
||||||
iter_ = base_ + N -1;
|
iter_ = base_ + N -1;
|
||||||
@ -114,33 +117,34 @@ class ring_iterator {
|
|||||||
|
|
||||||
//! \name Random access iterator requirements
|
//! \name Random access iterator requirements
|
||||||
//! @{
|
//! @{
|
||||||
reference operator[](difference_type n) const noexcept {
|
constexpr reference operator[](difference_type n) const noexcept {
|
||||||
difference_type k = iter_ - base_; // ptrdiff from base_
|
difference_type k = iter_ - base_; // ptrdiff from base_
|
||||||
return (static_cast<size_t>(k + n) < N) ?
|
return (static_cast<size_t>(k + n) < N) ?
|
||||||
base_[k + n] : // on range
|
base_[k + n] : // on range
|
||||||
base_[k + n - N]; // out of range, loop
|
base_[k + n - N]; // out of range, loop
|
||||||
}
|
}
|
||||||
ring_iterator& operator+=(difference_type n) noexcept {
|
constexpr ring_iterator& operator+=(difference_type n) noexcept {
|
||||||
difference_type k = iter_ - base_; // ptrdiff from base_
|
difference_type k = iter_ - base_; // ptrdiff from base_
|
||||||
iter_ += (static_cast<size_t>(k + n) < N) ?
|
iter_ += (static_cast<size_t>(k + n) < N) ?
|
||||||
n : // on range
|
n : // on range
|
||||||
n - N; // out of range, loop
|
n - N; // out of range, loop
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
ring_iterator operator+(difference_type n) const noexcept {
|
|
||||||
|
constexpr ring_iterator operator+(difference_type n) const noexcept {
|
||||||
difference_type k = iter_ - base_; // ptrdiff from base_
|
difference_type k = iter_ - base_; // ptrdiff from base_
|
||||||
return (static_cast<size_t>(k + n) < N) ?
|
return (static_cast<size_t>(k + n) < N) ?
|
||||||
ring_iterator(base_, k + n) : // on range
|
ring_iterator(base_, k + n) : // on range
|
||||||
ring_iterator(base_, k + n - N); // out of range, loop
|
ring_iterator(base_, k + n - N); // out of range, loop
|
||||||
}
|
}
|
||||||
ring_iterator& operator-=(difference_type n) noexcept {
|
constexpr ring_iterator& operator-=(difference_type n) noexcept {
|
||||||
difference_type k = iter_ - base_; // ptrdiff from base_
|
difference_type k = iter_ - base_; // ptrdiff from base_
|
||||||
iter_ -= ((k - n) < 0)?
|
iter_ -= ((k - n) < 0)?
|
||||||
n - N: // out of range, loop
|
n - N: // out of range, loop
|
||||||
n; // on range
|
n; // on range
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
ring_iterator operator-(difference_type n) const noexcept {
|
constexpr ring_iterator operator-(difference_type n) const noexcept {
|
||||||
difference_type k = iter_ - base_; // ptrdiff from base_
|
difference_type k = iter_ - base_; // ptrdiff from base_
|
||||||
return ((k - n) < 0) ?
|
return ((k - n) < 0) ?
|
||||||
ring_iterator(base_, k - n + N) : // out of range, loop
|
ring_iterator(base_, k - n + N) : // out of range, loop
|
||||||
@ -150,13 +154,13 @@ class ring_iterator {
|
|||||||
|
|
||||||
//! \name Data members and access
|
//! \name Data members and access
|
||||||
//! @{
|
//! @{
|
||||||
const Iter_t& base() const noexcept {
|
constexpr const Iter_t& base() const noexcept {
|
||||||
return base_;
|
return base_;
|
||||||
}
|
}
|
||||||
const Iter_t& iter() const noexcept {
|
constexpr const Iter_t& iter() const noexcept {
|
||||||
return iter_;
|
return iter_;
|
||||||
}
|
}
|
||||||
size_t size() noexcept {
|
constexpr size_t size() noexcept {
|
||||||
return N;
|
return N;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,9 +39,14 @@ namespace Tdeque {
|
|||||||
TEST(Tdeque, contruct) {
|
TEST(Tdeque, contruct) {
|
||||||
deque<int, 8> q1;
|
deque<int, 8> q1;
|
||||||
deque<int, 8> q2{1, 2, 3, 4, 5, 6, 7, 8};
|
deque<int, 8> q2{1, 2, 3, 4, 5, 6, 7, 8};
|
||||||
|
deque<int, 8> q3{1, 2, 3, 4, 5};
|
||||||
|
|
||||||
EXPECT_EQ (8UL, q1.capacity());
|
EXPECT_EQ (8UL, q1.capacity());
|
||||||
|
EXPECT_EQ (0UL, q1.size());
|
||||||
EXPECT_EQ (8UL, q2.capacity());
|
EXPECT_EQ (8UL, q2.capacity());
|
||||||
|
EXPECT_EQ (8UL, q2.size());
|
||||||
|
EXPECT_EQ (8UL, q3.capacity());
|
||||||
|
EXPECT_EQ (5UL, q3.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// simple push-pop functionality
|
// simple push-pop functionality
|
||||||
|
@ -60,10 +60,16 @@ namespace Tdeque {
|
|||||||
Edeque e3(Edeque::size_match::EQ, 7, vfun);
|
Edeque e3(Edeque::size_match::EQ, 7, vfun);
|
||||||
edeque<T, 8> e4(edeque<T, 8>::size_match::EQ, 2, vfoo{});
|
edeque<T, 8> e4(edeque<T, 8>::size_match::EQ, 2, vfoo{});
|
||||||
|
|
||||||
|
edeque<int, 8> q1;
|
||||||
|
edeque<int, 8> q2(edeque<int, 8>::size_match::DISABLED, 0, nullptr);
|
||||||
|
|
||||||
EXPECT_EQ (8UL, e1.capacity());
|
EXPECT_EQ (8UL, e1.capacity());
|
||||||
EXPECT_EQ (8UL, e2.capacity());
|
EXPECT_EQ (8UL, e2.capacity());
|
||||||
EXPECT_EQ (8UL, e3.capacity());
|
EXPECT_EQ (8UL, e3.capacity());
|
||||||
EXPECT_EQ (8UL, e4.capacity());
|
EXPECT_EQ (8UL, e4.capacity());
|
||||||
|
|
||||||
|
EXPECT_EQ (8UL, q1.capacity());
|
||||||
|
EXPECT_EQ (8UL, q2.capacity());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST (Tedeque, base_class) {
|
TEST (Tedeque, base_class) {
|
||||||
|
181
test/tests/equeue.cpp
Normal file
181
test/tests/equeue.cpp
Normal file
@ -0,0 +1,181 @@
|
|||||||
|
/*!
|
||||||
|
* \file equeue.cpp
|
||||||
|
* \brief
|
||||||
|
* Unit tests for equeue
|
||||||
|
*
|
||||||
|
* \copyright Copyright (C) 2020 Christos Choutouridis <christos@choutouridis.net>
|
||||||
|
*
|
||||||
|
* <dl class=\"section copyright\"><dt>License</dt><dd>
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
* </dd></dl>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#include <cont/equeue.h>
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
namespace Tequeue {
|
||||||
|
using namespace tbx;
|
||||||
|
|
||||||
|
int global_flag =0;
|
||||||
|
|
||||||
|
// Callable mocks
|
||||||
|
void vfun(void) { ++global_flag; }
|
||||||
|
|
||||||
|
struct vfoo {
|
||||||
|
void operator() (void) { ++global_flag; }
|
||||||
|
};
|
||||||
|
|
||||||
|
// Test construction
|
||||||
|
TEST(Tequeue, contruct) {
|
||||||
|
using Equeue = equeue<int, 8>;
|
||||||
|
struct T { int a,b; };
|
||||||
|
int local{};
|
||||||
|
|
||||||
|
Equeue e1(Equeue::size_match::GE, 3, [](){
|
||||||
|
++global_flag;
|
||||||
|
});
|
||||||
|
Equeue e2(Equeue::size_match::GE, 3, [&](){
|
||||||
|
++local;
|
||||||
|
});
|
||||||
|
Equeue e3(Equeue::size_match::EQ, 7, vfun);
|
||||||
|
equeue<T, 8> e4(equeue<T, 8>::size_match::EQ, 2, vfoo{});
|
||||||
|
|
||||||
|
equeue<int, 8> q1;
|
||||||
|
equeue<int, 8> q2(equeue<int, 8>::size_match::DISABLED, 0, nullptr);
|
||||||
|
|
||||||
|
EXPECT_EQ (8UL, e1.capacity());
|
||||||
|
EXPECT_EQ (8UL, e2.capacity());
|
||||||
|
EXPECT_EQ (8UL, e3.capacity());
|
||||||
|
EXPECT_EQ (8UL, e4.capacity());
|
||||||
|
|
||||||
|
EXPECT_EQ (8UL, q1.capacity());
|
||||||
|
EXPECT_EQ (8UL, q2.capacity());
|
||||||
|
}
|
||||||
|
|
||||||
|
// simple push-pop functionality
|
||||||
|
TEST(Tequeue, base_class) {
|
||||||
|
using Equeue = equeue<int, 8>;
|
||||||
|
|
||||||
|
Equeue e1(Equeue::size_match::GE, 3, [](){
|
||||||
|
++global_flag;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Access of base class functionality
|
||||||
|
EXPECT_EQ (8UL, e1.capacity());
|
||||||
|
EXPECT_EQ (0UL, e1.size());
|
||||||
|
EXPECT_EQ (true, e1.empty());
|
||||||
|
EXPECT_EQ (false, e1.full());
|
||||||
|
|
||||||
|
e1.push(42);
|
||||||
|
EXPECT_EQ (42, e1.front());
|
||||||
|
EXPECT_EQ (42, e1.back());
|
||||||
|
EXPECT_EQ (42, e1.pop());
|
||||||
|
|
||||||
|
e1.push(1);
|
||||||
|
e1.push(2);
|
||||||
|
e1.push(3);
|
||||||
|
|
||||||
|
int check_it=1;
|
||||||
|
for (auto it = e1.begin() ; it != e1.end() ; ++it)
|
||||||
|
EXPECT_EQ(*it, check_it++);
|
||||||
|
EXPECT_EQ(4, check_it); // run through all
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// trigger functionality
|
||||||
|
TEST (Tequeue, set_clear_check_trigger) {
|
||||||
|
using Equeue = equeue<int, 8>;
|
||||||
|
bool flag{};
|
||||||
|
|
||||||
|
Equeue e1(Equeue::size_match::GE, 1, [&](){ flag = true; });
|
||||||
|
|
||||||
|
flag = false;
|
||||||
|
e1.clear_trigger();
|
||||||
|
EXPECT_EQ (false, flag);
|
||||||
|
e1.push_back(1); // 1, no-trigger cleared
|
||||||
|
EXPECT_EQ (false, flag);
|
||||||
|
|
||||||
|
flag = false;
|
||||||
|
e1.clear();
|
||||||
|
e1.clear_trigger();
|
||||||
|
EXPECT_EQ (false, flag); // no spurious triggers
|
||||||
|
e1.push_back(1); // 1
|
||||||
|
e1.push_back(2); // 2
|
||||||
|
e1.set_trigger(Equeue::size_match::GE, 1, [&](){ flag = true; });
|
||||||
|
EXPECT_EQ (false, flag); // no spurious triggers
|
||||||
|
e1.check_trigger(); // manual trigger
|
||||||
|
EXPECT_EQ (true, flag);
|
||||||
|
|
||||||
|
flag = false;
|
||||||
|
e1.check_trigger(); // manual trigger attempt
|
||||||
|
EXPECT_EQ (false, flag); // [SIZE triggers are auto clear]
|
||||||
|
|
||||||
|
Equeue e2(Equeue::data_match::MATCH, 42, [&](){ flag = true; });
|
||||||
|
flag = false;
|
||||||
|
e2.clear_trigger();
|
||||||
|
EXPECT_EQ (false, flag);
|
||||||
|
e2.push_back(42); // push 42, no-trigger cleared
|
||||||
|
EXPECT_EQ (false, flag);
|
||||||
|
e2.set_trigger(Equeue::data_match::MATCH, 42, [&](){ flag = true; });
|
||||||
|
EXPECT_EQ (false, flag); // no spurious triggers
|
||||||
|
e2.pop_back(); // pop 42, trigger
|
||||||
|
EXPECT_EQ (true, flag);
|
||||||
|
|
||||||
|
flag = false;
|
||||||
|
e2.push_back(42); // push 42, re-trigger [DATA re-triggers]
|
||||||
|
EXPECT_EQ (true, flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
// stream push-pop
|
||||||
|
TEST(Tequeue, stream_push_pop) {
|
||||||
|
equeue<int, 8> q1;
|
||||||
|
|
||||||
|
q1 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8;
|
||||||
|
EXPECT_EQ (8UL, q1.capacity());
|
||||||
|
EXPECT_EQ (8UL, q1.size());
|
||||||
|
EXPECT_EQ (false, q1.empty());
|
||||||
|
EXPECT_EQ (true, q1.full());
|
||||||
|
|
||||||
|
q1 << 9; // try to insert in full queue
|
||||||
|
EXPECT_EQ (8UL, q1.capacity());
|
||||||
|
EXPECT_EQ (8UL, q1.size());
|
||||||
|
EXPECT_EQ (false, q1.empty());
|
||||||
|
EXPECT_EQ (true, q1.full());
|
||||||
|
|
||||||
|
int check_it=1;
|
||||||
|
for (auto it = q1.begin() ; it != q1.end() ; ++it)
|
||||||
|
EXPECT_EQ(*it, check_it++);
|
||||||
|
EXPECT_EQ(9, check_it); // run through all
|
||||||
|
|
||||||
|
for (int i =1 ; i <= 8 ; ++i) {
|
||||||
|
check_it << q1;
|
||||||
|
EXPECT_EQ(i, check_it);
|
||||||
|
}
|
||||||
|
EXPECT_EQ (8UL, q1.capacity());
|
||||||
|
EXPECT_EQ (0UL, q1.size());
|
||||||
|
EXPECT_EQ (true, q1.empty());
|
||||||
|
EXPECT_EQ (false, q1.full());
|
||||||
|
|
||||||
|
q1 >> check_it;
|
||||||
|
EXPECT_EQ (int{}, check_it);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -39,12 +39,17 @@ namespace Tqueue {
|
|||||||
TEST(Tqueue, contruct) {
|
TEST(Tqueue, contruct) {
|
||||||
queue<int, 8> q1;
|
queue<int, 8> q1;
|
||||||
queue<int, 8> q2{1, 2, 3, 4, 5, 6, 7, 8};
|
queue<int, 8> q2{1, 2, 3, 4, 5, 6, 7, 8};
|
||||||
|
queue<int, 8> q3{1, 2, 3, 4, 5};
|
||||||
|
|
||||||
EXPECT_EQ (8UL, q1.capacity());
|
EXPECT_EQ (8UL, q1.capacity());
|
||||||
|
EXPECT_EQ (0UL, q1.size());
|
||||||
EXPECT_EQ (8UL, q2.capacity());
|
EXPECT_EQ (8UL, q2.capacity());
|
||||||
|
EXPECT_EQ (8UL, q2.size());
|
||||||
|
EXPECT_EQ (8UL, q3.capacity());
|
||||||
|
EXPECT_EQ (5UL, q3.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// simple push-pop functionality
|
// base class functionality check
|
||||||
TEST(Tqueue, base_class) {
|
TEST(Tqueue, base_class) {
|
||||||
|
|
||||||
queue<int, 8> q1;
|
queue<int, 8> q1;
|
||||||
@ -55,34 +60,10 @@ namespace Tqueue {
|
|||||||
EXPECT_EQ (true, q1.empty());
|
EXPECT_EQ (true, q1.empty());
|
||||||
EXPECT_EQ (false, q1.full());
|
EXPECT_EQ (false, q1.full());
|
||||||
|
|
||||||
q1.push_back(7);
|
q1.push(42);
|
||||||
EXPECT_EQ (7, q1.front());
|
|
||||||
EXPECT_EQ (7, q1.back());
|
|
||||||
EXPECT_EQ (7, q1.pop_front());
|
|
||||||
|
|
||||||
q1.push_front(42);
|
|
||||||
EXPECT_EQ (42, q1.front());
|
EXPECT_EQ (42, q1.front());
|
||||||
EXPECT_EQ (42, q1.back());
|
EXPECT_EQ (42, q1.back());
|
||||||
EXPECT_EQ (42, q1.pop_back());
|
EXPECT_EQ (42, q1.pop());
|
||||||
|
|
||||||
q1.push_back(1);
|
|
||||||
q1.push_back(2);
|
|
||||||
q1.push_back(3);
|
|
||||||
|
|
||||||
int check_it=1;
|
|
||||||
for (auto it = q1.begin() ; it != q1.end() ; ++it)
|
|
||||||
EXPECT_EQ(*it, check_it++);
|
|
||||||
EXPECT_EQ(4, check_it); // run through all
|
|
||||||
}
|
|
||||||
|
|
||||||
// push-pop
|
|
||||||
TEST(Tqueue, front_back) {
|
|
||||||
queue<int, 8> q1;
|
|
||||||
|
|
||||||
q1.push(7);
|
|
||||||
EXPECT_EQ (7, q1.front());
|
|
||||||
EXPECT_EQ (7, q1.back());
|
|
||||||
EXPECT_EQ (7, q1.pop());
|
|
||||||
|
|
||||||
q1.push(1);
|
q1.push(1);
|
||||||
q1.push(2);
|
q1.push(2);
|
||||||
@ -92,28 +73,40 @@ namespace Tqueue {
|
|||||||
for (auto it = q1.begin() ; it != q1.end() ; ++it)
|
for (auto it = q1.begin() ; it != q1.end() ; ++it)
|
||||||
EXPECT_EQ(*it, check_it++);
|
EXPECT_EQ(*it, check_it++);
|
||||||
EXPECT_EQ(4, check_it); // run through all
|
EXPECT_EQ(4, check_it); // run through all
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// stream operations
|
// stream push-pop
|
||||||
TEST(Tqueue, capacity) {
|
TEST(Tqueue, stream_push_pop) {
|
||||||
queue<int, 8> q1;
|
queue<int, 8> q1;
|
||||||
|
|
||||||
// stream 5 items
|
q1 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8;
|
||||||
q1 << 1 << 2 << 3 << 4 << 5;
|
EXPECT_EQ (8UL, q1.capacity());
|
||||||
|
EXPECT_EQ (8UL, q1.size());
|
||||||
|
EXPECT_EQ (false, q1.empty());
|
||||||
|
EXPECT_EQ (true, q1.full());
|
||||||
|
|
||||||
|
q1 << 9; // try to insert in full queue
|
||||||
|
EXPECT_EQ (8UL, q1.capacity());
|
||||||
|
EXPECT_EQ (8UL, q1.size());
|
||||||
|
EXPECT_EQ (false, q1.empty());
|
||||||
|
EXPECT_EQ (true, q1.full());
|
||||||
|
|
||||||
int check_it=1;
|
int check_it=1;
|
||||||
for (auto it = q1.begin() ; it != q1.end() ; ++it)
|
for (auto it = q1.begin() ; it != q1.end() ; ++it)
|
||||||
EXPECT_EQ(*it, check_it++);
|
EXPECT_EQ(*it, check_it++);
|
||||||
EXPECT_EQ (6, check_it); // run through all
|
EXPECT_EQ(9, check_it); // run through all
|
||||||
|
|
||||||
// get all back
|
for (int i =1 ; i <= 8 ; ++i) {
|
||||||
int it;
|
check_it << q1;
|
||||||
for (int check_it=1 ; check_it<=5 ; ++check_it) {
|
EXPECT_EQ(i, check_it);
|
||||||
q1 >> it;
|
|
||||||
EXPECT_EQ (check_it, it);
|
|
||||||
}
|
}
|
||||||
|
EXPECT_EQ (8UL, q1.capacity());
|
||||||
|
EXPECT_EQ (0UL, q1.size());
|
||||||
|
EXPECT_EQ (true, q1.empty());
|
||||||
|
EXPECT_EQ (false, q1.full());
|
||||||
|
|
||||||
|
q1 >> check_it;
|
||||||
|
EXPECT_EQ (int{}, check_it);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user