1 #include <boost/test/unit_test.hpp>
3 #include "server/node_graph.hpp"
5 #include "test_synth.hpp"
7 #ifdef __GXX_EXPERIMENTAL_CXX0X__
8 #define auto_ptr unique_ptr
14 BOOST_AUTO_TEST_CASE( simple_synth_test_1
)
16 rt_pool
.init(1024 * 1024);
20 node_position_constraint to_root
= std::make_pair(n
.root_group(), insert
);
23 test_synth
* s
= new test_synth(1000, 0);
24 n
.add_node(s
, to_root
);
25 BOOST_REQUIRE_EQUAL(n
.synth_count(), 1u);
26 BOOST_REQUIRE_EQUAL(n
.find_synth(1000), s
);
28 BOOST_REQUIRE_EQUAL(n
.synth_count(), 0u);
31 BOOST_REQUIRE_EQUAL(n
.group_count(), 1u);
34 test_synth
* s
= new test_synth(1000, 0);
35 n
.add_node(s
/* , node_position_constraint() */);
36 BOOST_REQUIRE_EQUAL(n
.synth_count(), 1u);
38 BOOST_REQUIRE_EQUAL(n
.synth_count(), 0u);
41 BOOST_REQUIRE_EQUAL(n
.group_count(), 1u);
44 BOOST_AUTO_TEST_CASE( simple_synth_test_2
)
48 group
* g
= new group(1);
50 BOOST_REQUIRE_EQUAL(n
.find_group(1), g
);
54 BOOST_AUTO_TEST_CASE( simple_synth_test_3
)
58 group
* g
= new group(1);
63 node_position_constraint to_group
= std::make_pair(g
, insert
);
65 test_synth
* s
= new test_synth(1000, 0);
67 n
.add_node(s
, to_group
);
73 BOOST_AUTO_TEST_CASE( simple_synth_test_4
)
77 group
* g
= new group(1);
81 test_synth
* s
= new test_synth(1000, 0);
83 node_position_constraint to_group
= std::make_pair(g
, insert
);
85 n
.add_node(s
, to_group
);
90 BOOST_AUTO_TEST_CASE( simple_synth_test_5
)
94 test_synth
* s
= new test_synth(1000, 0);
95 test_synth
* s2
= new test_synth(1001, 0);
105 BOOST_AUTO_TEST_CASE( simple_synth_test_6
)
109 test_synth
* s1
= new test_synth(1000, 0);
112 test_synth
* s2
= new test_synth(1001, 0);
114 node_position_constraint to_group
= std::make_pair(n
.root_group(), insert
);
116 n
.add_node(s2
, to_group
);
119 test_synth
* s3
= new test_synth(1002, 0);
121 node_position_constraint position
= std::make_pair(s1
, after
);
123 n
.add_node(s3
, position
);
126 test_synth
* s4
= new test_synth(1003, 0);
128 node_position_constraint position
= std::make_pair(s1
, before
);
130 n
.add_node(s4
, position
);
133 //n.dump("test.dot");
141 BOOST_AUTO_TEST_CASE( free_all_test
)
145 group
* g
= new group(1);
148 BOOST_REQUIRE_EQUAL(n
.group_count(), 2u);
150 node_position_constraint to_group
= std::make_pair(g
, insert
);
152 test_synth
* s
= new test_synth(1000, 0);
153 n
.add_node(s
, to_group
);
155 test_synth
* s2
= new test_synth(1001, 0);
156 n
.add_node(s2
, to_group
);
158 group
* g2
= new group(1002);
159 n
.add_node(g2
, to_group
);
161 BOOST_REQUIRE_EQUAL(n
.synth_count(), 2u);
162 BOOST_REQUIRE_EQUAL(n
.group_count(), 3u);
164 BOOST_REQUIRE(n
.find_node(s
->id()));
165 BOOST_REQUIRE(n
.find_node(s2
->id()));
166 BOOST_REQUIRE(n
.find_node(g2
->id()));
168 BOOST_REQUIRE(n
.group_free_all(g
));
170 BOOST_REQUIRE(!n
.find_node(s
->id()));
171 BOOST_REQUIRE(!n
.find_node(s2
->id()));
172 BOOST_REQUIRE(!n
.find_node(g2
->id()));
174 BOOST_REQUIRE_EQUAL(n
.synth_count(), 0u);
175 BOOST_REQUIRE_EQUAL(n
.group_count(), 2u);
177 BOOST_REQUIRE(n
.find_node(g
->id()));
179 BOOST_REQUIRE(!n
.find_node(g
->id()));
180 BOOST_REQUIRE_EQUAL(n
.group_count(), 1u);
183 BOOST_AUTO_TEST_CASE( free_deep_test
)
187 group
* g
= new group(1);
190 BOOST_REQUIRE_EQUAL(n
.group_count(), 2u);
192 node_position_constraint to_group
= std::make_pair(g
, insert
);
194 test_synth
* s
= new test_synth(1000, 0);
195 n
.add_node(s
, to_group
);
197 test_synth
* s2
= new test_synth(1001, 0);
198 n
.add_node(s2
, to_group
);
200 group
* g2
= new group(1002);
201 n
.add_node(g2
, to_group
);
203 BOOST_REQUIRE_EQUAL(n
.synth_count(), 2u);
204 BOOST_REQUIRE_EQUAL(n
.group_count(), 3u);
206 BOOST_REQUIRE(n
.find_node(s
->id()));
207 BOOST_REQUIRE(n
.find_node(s2
->id()));
208 BOOST_REQUIRE(n
.find_node(g2
->id()));
210 BOOST_REQUIRE(n
.group_free_deep(g
));
212 BOOST_REQUIRE(!n
.find_node(s
->id()));
213 BOOST_REQUIRE(!n
.find_node(s2
->id()));
214 BOOST_REQUIRE(n
.find_node(g2
->id()));
216 BOOST_REQUIRE_EQUAL(n
.synth_count(), 0u);
217 BOOST_REQUIRE_EQUAL(n
.group_count(), 3u);
219 BOOST_REQUIRE(n
.find_node(g2
->id()));
220 BOOST_REQUIRE(n
.find_node(g
->id()));
222 BOOST_REQUIRE(!n
.find_node(g
->id()));
223 BOOST_REQUIRE(!n
.find_node(g2
->id()));
224 BOOST_REQUIRE_EQUAL(n
.group_count(), 1u);
228 BOOST_AUTO_TEST_CASE( queue_construction_test_1
)
232 test_synth
* s
= new test_synth(1000, 0);
233 test_synth
* s2
= new test_synth(1001, 0);
238 auto_ptr
<node_graph::dsp_thread_queue
> q
= n
.generate_dsp_queue();
244 BOOST_AUTO_TEST_CASE( queue_construction_test_2
)
248 group
* g
= new group(1);
251 auto_ptr
<node_graph::dsp_thread_queue
> q
= n
.generate_dsp_queue();
252 BOOST_REQUIRE_EQUAL(q
->get_total_node_count(), 0u);
257 BOOST_AUTO_TEST_CASE( queue_construction_test_3
)
261 test_synth
* s
= new test_synth(1000, 0);
264 auto_ptr
<node_graph::dsp_thread_queue
> q1
= n
.generate_dsp_queue();
265 BOOST_REQUIRE_EQUAL(q1
->get_total_node_count(), 1u);
267 test_synth
* s2
= new test_synth(3, 0);
270 auto_ptr
<node_graph::dsp_thread_queue
> q2
= n
.generate_dsp_queue();
271 BOOST_REQUIRE_EQUAL(q2
->get_total_node_count(), 1u);
280 BOOST_AUTO_TEST_CASE( pgroup_test_1
)
284 parallel_group
* g
= new parallel_group(1);
286 BOOST_REQUIRE_EQUAL(n
.find_group(1), g
);
288 auto_ptr
<node_graph::dsp_thread_queue
> q
= n
.generate_dsp_queue();
289 BOOST_REQUIRE_EQUAL(q
->get_total_node_count(), 0u);
294 BOOST_AUTO_TEST_CASE( pgroup_test_2
)
298 parallel_group
* g
= new parallel_group(1);
303 node_position_constraint to_group
= std::make_pair(g
, insert
);
305 test_synth
* s
= new test_synth(2, 0);
306 n
.add_node(s
, to_group
);
312 BOOST_AUTO_TEST_CASE( pgroup_test_3
)
316 parallel_group
* g
= new parallel_group(1);
320 test_synth
* s
= new test_synth(2, 0);
322 node_position_constraint to_group
= std::make_pair(g
, insert
);
324 n
.add_node(s
, to_group
);
329 BOOST_AUTO_TEST_CASE( pgroup_test_4
)
333 parallel_group
* g
= new parallel_group(1);
338 node_position_constraint to_group
= std::make_pair(g
, insert
);
340 test_synth
* s
= new test_synth(2, 0);
341 n
.add_node(s
, to_group
);
343 auto_ptr
<node_graph::dsp_thread_queue
> q
= n
.generate_dsp_queue();
344 BOOST_REQUIRE_EQUAL(q
->get_total_node_count(), 1u);
352 BOOST_AUTO_TEST_CASE( pgroup_test_5
)
356 parallel_group
* g
= new parallel_group(1);
361 node_position_constraint to_group
= std::make_pair(g
, insert
);
363 test_synth
* s1
= new test_synth(2, 0);
364 test_synth
* s2
= new test_synth(3, 0);
365 n
.add_node(s1
, to_group
);
366 n
.add_node(s2
, to_group
);
368 auto_ptr
<node_graph::dsp_thread_queue
> q
= n
.generate_dsp_queue();
370 BOOST_REQUIRE_EQUAL(q
->get_total_node_count(), 2u);
378 BOOST_AUTO_TEST_CASE( pgroup_test_6
)
382 parallel_group
* g
= new parallel_group(1);
387 node_position_constraint to_group
= std::make_pair(g
, insert
);
389 test_synth
* s1
= new test_synth(2, 0);
390 test_synth
* s2
= new test_synth(3, 0);
391 test_synth
* s3
= new test_synth(4, 0);
392 n
.add_node(s1
, to_group
);
393 n
.add_node(s2
, to_group
);
394 n
.add_node(s3
, to_group
);
396 auto_ptr
<node_graph::dsp_thread_queue
> q
= n
.generate_dsp_queue();
397 BOOST_REQUIRE_EQUAL(q
->get_total_node_count(), 3u);
402 BOOST_AUTO_TEST_CASE( pgroup_test_7
)
406 parallel_group
* g
= new parallel_group(1);
411 node_position_constraint to_group
= std::make_pair(g
, insert
);
413 group
* g1
= new group(2);
414 group
* g2
= new group(3);
415 group
* g3
= new group(4);
416 n
.add_node(g1
, to_group
);
417 n
.add_node(g2
, to_group
);
418 n
.add_node(g3
, to_group
);
420 node_position_constraint to_g1
= std::make_pair(g1
, insert
);
421 node_position_constraint to_g2
= std::make_pair(g2
, insert
);
422 test_synth
* s1
= new test_synth(1000, 0);
423 test_synth
* s2
= new test_synth(1001, 0);
424 n
.add_node(s1
, to_g1
);
425 n
.add_node(s2
, to_g2
);
427 auto_ptr
<node_graph::dsp_thread_queue
> q
= n
.generate_dsp_queue();
428 BOOST_REQUIRE_EQUAL(q
->get_total_node_count(), 2u);
433 BOOST_AUTO_TEST_CASE( noid_test
)
435 rt_pool
.init(1024 * 1024);
439 node_position_constraint to_root
= std::make_pair(n
.root_group(), insert
);
442 test_synth
* s
= new test_synth(1000, 0);
443 n
.add_node(s
, to_root
);
444 BOOST_REQUIRE(s
->id() == 1000 );
445 n
.synth_reassign_id(1000);
446 BOOST_REQUIRE(s
->id() != 1000 );
451 test_synth
* s
= new test_synth(1000, 0);
452 n
.add_node(s
/* , node_position_constraint() */);
453 BOOST_REQUIRE(s
->id() == 1000 );
454 n
.synth_reassign_id(1000);
455 BOOST_REQUIRE(s
->id() != 1000 );