Remove erroneous assert which I added earlier.
[ardour2.git] / libs / audiographer / tests / utils / identity_vertex_test.cc
blob799dcca386fca00d4363fefd08b3de3be0ca0f86
1 #include "tests/utils.h"
3 #include "audiographer/utils/identity_vertex.h"
5 using namespace AudioGrapher;
7 class IdentityVertexTest : public CppUnit::TestFixture
9 CPPUNIT_TEST_SUITE (IdentityVertexTest);
10 CPPUNIT_TEST (testProcess);
11 CPPUNIT_TEST (testRemoveOutput);
12 CPPUNIT_TEST (testClearOutputs);
13 CPPUNIT_TEST_SUITE_END ();
15 public:
16 void setUp()
18 frames = 128;
19 random_data = TestUtils::init_random_data(frames);
21 zero_data = new float[frames];
22 memset (zero_data, 0, frames * sizeof(float));
24 sink_a.reset (new VectorSink<float>());
25 sink_b.reset (new VectorSink<float>());
28 void tearDown()
30 delete [] random_data;
31 delete [] zero_data;
34 void testProcess()
36 vertex.reset (new IdentityVertex<float>());
37 vertex->add_output (sink_a);
38 vertex->add_output (sink_b);
40 framecnt_t frames_output = 0;
42 ProcessContext<float> c (random_data, frames, 1);
43 vertex->process (c);
45 frames_output = sink_a->get_data().size();
46 CPPUNIT_ASSERT_EQUAL (frames, frames_output);
48 frames_output = sink_b->get_data().size();
49 CPPUNIT_ASSERT_EQUAL (frames, frames_output);
51 CPPUNIT_ASSERT (TestUtils::array_equals (random_data, sink_a->get_array(), frames));
52 CPPUNIT_ASSERT (TestUtils::array_equals (random_data, sink_b->get_array(), frames));
55 void testRemoveOutput()
57 vertex.reset (new IdentityVertex<float>());
58 vertex->add_output (sink_a);
59 vertex->add_output (sink_b);
61 ProcessContext<float> c (random_data, frames, 1);
62 vertex->process (c);
64 vertex->remove_output (sink_a);
65 ProcessContext<float> zc (zero_data, frames, 1);
66 vertex->process (zc);
68 CPPUNIT_ASSERT (TestUtils::array_equals (random_data, sink_a->get_array(), frames));
69 CPPUNIT_ASSERT (TestUtils::array_equals (zero_data, sink_b->get_array(), frames));
72 void testClearOutputs()
74 vertex.reset (new IdentityVertex<float>());
75 vertex->add_output (sink_a);
76 vertex->add_output (sink_b);
78 ProcessContext<float> c (random_data, frames, 1);
79 vertex->process (c);
81 vertex->clear_outputs ();
82 ProcessContext<float> zc (zero_data, frames, 1);
83 vertex->process (zc);
85 CPPUNIT_ASSERT (TestUtils::array_equals (random_data, sink_a->get_array(), frames));
86 CPPUNIT_ASSERT (TestUtils::array_equals (random_data, sink_b->get_array(), frames));
89 private:
90 boost::shared_ptr<IdentityVertex<float> > vertex;
91 boost::shared_ptr<VectorSink<float> > sink_a;
92 boost::shared_ptr<VectorSink<float> > sink_b;
94 float * random_data;
95 float * zero_data;
96 framecnt_t frames;
99 CPPUNIT_TEST_SUITE_REGISTRATION (IdentityVertexTest);