#include #include #include "c_testcase.h" #include "dataqueue.hpp" TEST_CASE(init) { DataQueue q; assert(q.Empty()); assert_eq(q.Size(), 0); END_TEST; } TEST_CASE(push) { DataQueue q; q.Push(10); assert_eq(q.Size(), 1); assert_eq(q.Pop(), 10); END_TEST; } TEST_CASE(pop) { DataQueue q; std::thread t([&]() { for (int i = 0; i < 10; i++) { q.Push(i); usleep(100); } }); for (int i = 0; i < 10; i++) { assert_eq(q.Pop(), i); } t.join(); END_TEST; }