1 #include <boost/test/unit_test.hpp>
3 #include "dsp_thread_queue/dsp_thread_queue.hpp"
14 void operator()(unsigned int dummy
)
25 typedef nova::dsp_queue_interpreter
<dummy_runnable
> dsp_queue_interpreter
;
26 typedef nova::dsp_thread_queue_item
<dummy_runnable
> dsp_thread_queue_item
;
27 typedef nova::dsp_thread_queue
<dummy_runnable
> dsp_thread_queue
;
29 BOOST_AUTO_TEST_CASE( dsp_thread_queue_test_1
)
31 dsp_queue_interpreter
interpreter(1);
33 bool runnable
= interpreter
.init_tick();
34 BOOST_REQUIRE(!runnable
);
37 BOOST_AUTO_TEST_CASE( dsp_thread_queue_test_2
)
39 dsp_queue_interpreter
interpreter(1);
41 bool runnable
= interpreter
.init_tick();
46 BOOST_AUTO_TEST_CASE( dsp_thread_queue_test_3
)
48 dsp_queue_interpreter
interpreter(1);
50 std::unique_ptr
<dsp_thread_queue
> q (new dsp_thread_queue(1));
52 dsp_thread_queue_item
* item
= q
->allocate_queue_item(dummy
, dsp_thread_queue_item::successor_list(), 0);
54 q
->add_initially_runnable(item
);
56 interpreter
.reset_queue(std::move(q
));
58 bool runnable
= interpreter
.init_tick();
59 BOOST_REQUIRE(runnable
);
63 BOOST_REQUIRE_EQUAL(item
->get_job().i
, 1);
66 BOOST_AUTO_TEST_CASE( dsp_thread_queue_test_4
)
68 dsp_queue_interpreter
interpreter(1);
70 std::unique_ptr
<dsp_thread_queue
> q (new dsp_thread_queue(2));
72 dsp_thread_queue_item
* item1
= q
->allocate_queue_item(dummy
, dsp_thread_queue_item::successor_list(), 1);
74 dsp_thread_queue_item::successor_list
sl(1);
77 dsp_thread_queue_item
* item2
= q
->allocate_queue_item(dummy
, sl
, 0);
78 q
->add_initially_runnable(item2
);
80 interpreter
.reset_queue(std::move(q
));
82 bool runnable
= interpreter
.init_tick();
83 BOOST_REQUIRE(runnable
);
86 BOOST_REQUIRE_EQUAL(item1
->get_job().i
, 1);
87 BOOST_REQUIRE_EQUAL(item2
->get_job().i
, 1);
90 BOOST_AUTO_TEST_CASE( dsp_thread_queue_test_5
)
92 dsp_queue_interpreter
interpreter(1);
95 std::unique_ptr
<dsp_thread_queue
> q (new dsp_thread_queue(2));
97 dsp_thread_queue_item
* item1
= q
->allocate_queue_item(dummy
, dsp_thread_queue_item::successor_list(), 1);
99 dsp_thread_queue_item::successor_list
sl(1);
102 dsp_thread_queue_item
* item2
= q
->allocate_queue_item(dummy
, sl
, 0);
104 q
->add_initially_runnable(item2
);
106 interpreter
.reset_queue(std::move(q
));
108 for (int i
= 0; i
!= 2; ++i
) {
109 bool runnable
= interpreter
.init_tick();
110 BOOST_REQUIRE(runnable
);
113 BOOST_REQUIRE_EQUAL(item1
->get_job().i
, 2);
114 BOOST_REQUIRE_EQUAL(item2
->get_job().i
, 2);
118 std::unique_ptr
<dsp_thread_queue
> q (new dsp_thread_queue(2));
120 dsp_thread_queue_item
* item1
= q
->allocate_queue_item(dummy
, dsp_thread_queue_item::successor_list(), 1);
122 dsp_thread_queue_item::successor_list
sl(1);
125 dsp_thread_queue_item
* item2
= q
->allocate_queue_item(dummy
, sl
, 0);
127 q
->add_initially_runnable(item2
);
129 interpreter
.reset_queue(std::move(q
));
131 for (int i
= 0; i
!= 2; ++i
) {
132 bool runnable
= interpreter
.init_tick();
133 BOOST_REQUIRE(runnable
);
136 BOOST_REQUIRE_EQUAL(item1
->get_job().i
, 2);
137 BOOST_REQUIRE_EQUAL(item2
->get_job().i
, 2);