IRSOL
C++ code implementing socket server for interacting with Baumer camera.
test_queue.cpp File Reference
#include "irsol/queue.hpp"
#include <catch2/catch_all.hpp>

Go to the source code of this file.

Functions

 TEST_CASE ("SafeQueue<T>::done())", "[SafeQueue]")
 
 TEST_CASE ("SafeQueue<T>::sizes", "[SafeQueue]")
 

Function Documentation

◆ TEST_CASE() [1/2]

TEST_CASE ( "SafeQueue<T>  ::done())

Definition at line 5 of file test_queue.cpp.

6{
7 auto queue = irsol::utils::SafeQueue<int>(3);
8 CHECK_FALSE(queue.done());
9 queue.producerFinished();
10 CHECK(queue.done());
11}
A thread-safe, optionally bounded queue with blocking push and pop operations.
Definition queue.hpp:66
CHECK(m.identifier==identifier)
CHECK_FALSE(m.hasDouble())

◆ TEST_CASE() [2/2]

TEST_CASE ( "SafeQueue<T>::sizes"  ,
""  [SafeQueue] 
)

Definition at line 13 of file test_queue.cpp.

14{
15 auto queue = irsol::utils::SafeQueue<int>(3);
16 CHECK(queue.empty());
17 for(size_t i = 0; i < 3; ++i) {
18 CHECK_FALSE(queue.full());
19 CHECK(queue.size() == i);
20 queue.push(i);
21 CHECK(queue.size() == i + 1);
22 }
23 CHECK(queue.full());
24 CHECK_FALSE(queue.empty());
25
26 int value;
27 for(size_t i = 0; i < 3; ++i) {
28 CHECK_FALSE(queue.empty());
29 CHECK(queue.pop(value));
30 CHECK(value == static_cast<int>(i));
31 CHECK(queue.size() == 2 - i);
32 }
33 CHECK(queue.empty());
34 CHECK_FALSE(queue.full());
35}
auto value