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 #ifdef __GXX_EXPERIMENTAL_CXX0X__
30 #define auto_ptr unique_ptr
31 #define MOVE(X) std::move(X)
36 BOOST_AUTO_TEST_CASE( dsp_thread_queue_test_1
)
38 dsp_queue_interpreter
interpreter(1);
40 bool runnable
= interpreter
.init_tick();
41 BOOST_REQUIRE(!runnable
);
44 BOOST_AUTO_TEST_CASE( dsp_thread_queue_test_2
)
46 dsp_queue_interpreter
interpreter(1);
48 bool runnable
= interpreter
.init_tick();
53 BOOST_AUTO_TEST_CASE( dsp_thread_queue_test_3
)
55 dsp_queue_interpreter
interpreter(1);
57 std::auto_ptr
<dsp_thread_queue
> q (new dsp_thread_queue(1));
59 dsp_thread_queue_item
* item
= q
->allocate_queue_item(dummy
, dsp_thread_queue_item::successor_list(), 0);
61 q
->add_initially_runnable(item
);
63 interpreter
.reset_queue(MOVE(q
));
65 bool runnable
= interpreter
.init_tick();
66 BOOST_REQUIRE(runnable
);
70 BOOST_REQUIRE_EQUAL(item
->get_job().i
, 1);
73 BOOST_AUTO_TEST_CASE( dsp_thread_queue_test_4
)
75 dsp_queue_interpreter
interpreter(1);
77 std::auto_ptr
<dsp_thread_queue
> q (new dsp_thread_queue(2));
79 dsp_thread_queue_item
* item1
= q
->allocate_queue_item(dummy
, dsp_thread_queue_item::successor_list(), 1);
81 dsp_thread_queue_item::successor_list
sl(1);
84 dsp_thread_queue_item
* item2
= q
->allocate_queue_item(dummy
, sl
, 0);
85 q
->add_initially_runnable(item2
);
87 interpreter
.reset_queue(MOVE(q
));
89 bool runnable
= interpreter
.init_tick();
90 BOOST_REQUIRE(runnable
);
93 BOOST_REQUIRE_EQUAL(item1
->get_job().i
, 1);
94 BOOST_REQUIRE_EQUAL(item2
->get_job().i
, 1);
97 BOOST_AUTO_TEST_CASE( dsp_thread_queue_test_5
)
99 dsp_queue_interpreter
interpreter(1);
102 std::auto_ptr
<dsp_thread_queue
> q (new dsp_thread_queue(2));
104 dsp_thread_queue_item
* item1
= q
->allocate_queue_item(dummy
, dsp_thread_queue_item::successor_list(), 1);
106 dsp_thread_queue_item::successor_list
sl(1);
109 dsp_thread_queue_item
* item2
= q
->allocate_queue_item(dummy
, sl
, 0);
111 q
->add_initially_runnable(item2
);
113 interpreter
.reset_queue(MOVE(q
));
115 for (int i
= 0; i
!= 2; ++i
) {
116 bool runnable
= interpreter
.init_tick();
117 BOOST_REQUIRE(runnable
);
120 BOOST_REQUIRE_EQUAL(item1
->get_job().i
, 2);
121 BOOST_REQUIRE_EQUAL(item2
->get_job().i
, 2);
125 std::auto_ptr
<dsp_thread_queue
> q (new dsp_thread_queue(2));
127 dsp_thread_queue_item
* item1
= q
->allocate_queue_item(dummy
, dsp_thread_queue_item::successor_list(), 1);
129 dsp_thread_queue_item::successor_list
sl(1);
132 dsp_thread_queue_item
* item2
= q
->allocate_queue_item(dummy
, sl
, 0);
134 q
->add_initially_runnable(item2
);
136 interpreter
.reset_queue(MOVE(q
));
138 for (int i
= 0; i
!= 2; ++i
) {
139 bool runnable
= interpreter
.init_tick();
140 BOOST_REQUIRE(runnable
);
143 BOOST_REQUIRE_EQUAL(item1
->get_job().i
, 2);
144 BOOST_REQUIRE_EQUAL(item2
->get_job().i
, 2);