summaryrefslogtreecommitdiff
path: root/libs/audiographer/tests
diff options
context:
space:
mode:
authorSakari Bergen <sakari.bergen@beatwaves.net>2012-10-30 20:15:11 +0000
committerSakari Bergen <sakari.bergen@beatwaves.net>2012-10-30 20:15:11 +0000
commitb5c5fc7a08a4f02d80a664ee18812e84d08dc6fd (patch)
tree4881c088a06c187e43bd4bc403ab037aa84c4b15 /libs/audiographer/tests
parenta2de07a48faf17ef9ec61322add18960676037ce (diff)
Fix chunker to handle end of input properly
git-svn-id: svn://localhost/ardour2/branches/3.0@13370 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/audiographer/tests')
-rw-r--r--libs/audiographer/tests/general/chunker_test.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/libs/audiographer/tests/general/chunker_test.cc b/libs/audiographer/tests/general/chunker_test.cc
index ea5c29a410..d3adab3691 100644
--- a/libs/audiographer/tests/general/chunker_test.cc
+++ b/libs/audiographer/tests/general/chunker_test.cc
@@ -14,6 +14,7 @@ class ChunkerTest : public CppUnit::TestFixture
CPPUNIT_TEST (testSynchronousProcess);
CPPUNIT_TEST (testAsynchronousProcess);
CPPUNIT_TEST (testChoppingProcess);
+ CPPUNIT_TEST (testEndOfInputFlagHandling);
CPPUNIT_TEST_SUITE_END ();
public:
@@ -136,6 +137,36 @@ class ChunkerTest : public CppUnit::TestFixture
CPPUNIT_ASSERT (TestUtils::array_equals (random_data, &sink->get_array()[ 3 * frames / 2], frames / 2));
}
+ void testEndOfInputFlagHandling()
+ {
+ boost::shared_ptr<ProcessContextGrabber<float> > grabber(new ProcessContextGrabber<float>());
+
+ assert (frames % 2 == 0);
+ chunker.reset (new Chunker<float>(frames));
+ chunker->add_output (grabber);
+
+ ProcessContext<float> const half_context (random_data, frames / 2, 1);
+ ProcessContext<float> const context (random_data, frames, 1);
+ context.set_flag(ProcessContext<>::EndOfInput);
+
+ // Process 0.5 then 1.0
+ chunker->process (half_context);
+ chunker->process (context);
+
+ // Should output two contexts
+ CPPUNIT_ASSERT_EQUAL((int)grabber->contexts.size(), 2);
+ ProcessContextGrabber<float>::ContextList::iterator it = grabber->contexts.begin();
+
+ // first 1.0 not end of input
+ CPPUNIT_ASSERT_EQUAL(it->frames(), frames);
+ CPPUNIT_ASSERT(!it->has_flag(ProcessContext<>::EndOfInput));
+
+ // Then 0.5 with end of input
+ ++it;
+ CPPUNIT_ASSERT_EQUAL(it->frames(), frames / 2);
+ CPPUNIT_ASSERT(it->has_flag(ProcessContext<>::EndOfInput));
+ }
+
private:
boost::shared_ptr<Chunker<float> > chunker;
boost::shared_ptr<VectorSink<float> > sink;