aare/src/core/test/ProducerConsumerQueue.test.cpp
Bechir Braham 91a628cd6c
pedestal (#67)
* add config files for multimodule receiving

* read subfiles with unordered and missing frames

* save work debugging

* Revert "save work debugging"

This reverts commit e791992a05efd754f93a80c980d17397eb4b6045.

* Revert "read subfiles with unordered and missing frames"

This reverts commit 1177fd129d3690db92e9597ccda62598e5a44d41.

* throw when two frames have different frame numbers

* write single part RawFile (working beta)

* correct total number of frames in master file

* add new mythen file with syncd frames

* save work

* save work for receive multimodule
multimodule config results in too much packet loss. needs more debugging.

* setup Task Distributiosn/ parallelization programming model

* read frames with same frame number

* clang-tidy fixes, formatting, add tests

* added second receiver

* Synchronize between zmq streams and merge frames

* improve readability in loop

* fix failing tests

* add simple test for merge frames

* restructure files and use top-level header

* working pedestal + tests

* test_pedestal statistics

* QA test pedestal, fix clang-tidy errors

---------

Co-authored-by: Bechir <bechir.brahem420@gmail.com>
Co-authored-by: Erik Frojdh <erik.frojdh@gmail.com>
2024-05-08 12:33:51 +02:00

50 lines
1013 B
C++

#include "aare/core/ProducerConsumerQueue.hpp"
#include <catch2/catch_all.hpp>
// using arve::SimpleQueue;
TEST_CASE("push pop") {
folly::ProducerConsumerQueue<int> q(5);
int a = 3;
int b = 8;
CHECK(q.sizeGuess() == 0);
CHECK(q.write(a));
CHECK(q.sizeGuess() == 1);
CHECK(q.write(b));
CHECK(q.sizeGuess() == 2);
int c = 0;
CHECK(q.read(c));
CHECK(c == 3);
CHECK(q.sizeGuess() == 1);
CHECK(q.read(c));
CHECK(c == 8);
CHECK(q.sizeGuess() == 0);
}
TEST_CASE("Cannot push to a full queue") {
folly::ProducerConsumerQueue<int> q(3);
int a = 3;
int b = 4;
int c = 0;
CHECK(q.write(a));
CHECK(q.write(b));
CHECK_FALSE(q.write(a));
// values are still ok
CHECK(q.read(c));
CHECK(c == 3);
CHECK(q.read(c));
CHECK(c == 4);
}
TEST_CASE("Cannot pop from an empty queue") {
folly::ProducerConsumerQueue<int> q(2);
int a = 0;
CHECK_FALSE(q.read(a));
}
// TEST_CASE("fail"){
// CHECK(false);
// }