IRSOL
C++ code implementing socket server for interacting with Baumer camera.
test_queue.cpp
Go to the documentation of this file.
1#include "irsol/queue.hpp"
2
3#include <catch2/catch_all.hpp>
4
5TEST_CASE("SafeQueue<T>::done())", "[SafeQueue]")
6{
7 auto queue = irsol::utils::SafeQueue<int>(3);
8 CHECK_FALSE(queue.done());
9 queue.producerFinished();
10 CHECK(queue.done());
11}
12
13TEST_CASE("SafeQueue<T>::sizes", "[SafeQueue]")
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}
A thread-safe, optionally bounded queue with blocking push and pop operations.
Definition queue.hpp:66
Thread-safe queue implementation with optional bounded capacity.
auto value
CHECK(m.identifier==identifier)
CHECK_FALSE(m.hasDouble())
TEST_CASE("SafeQueue<T>::done())", "[SafeQueue]")
Definition test_queue.cpp:5