diff options
author | John Glover <j@johnglover.net> | 2013-06-12 23:06:31 +0200 |
---|---|---|
committer | John Glover <j@johnglover.net> | 2013-06-12 23:06:31 +0200 |
commit | a06d3352a08deab4175b571cdc51d3ef3fc74f36 (patch) | |
tree | a4bbea518eb37934838a1fb278ee3a9c682698f6 /tests/test_base.cpp | |
parent | 5fa3a7b126c169bd5c3607cbbd503b002093e2ca (diff) | |
download | simpl-a06d3352a08deab4175b571cdc51d3ef3fc74f36.tar.gz simpl-a06d3352a08deab4175b571cdc51d3ef3fc74f36.tar.bz2 simpl-a06d3352a08deab4175b571cdc51d3ef3fc74f36.zip |
Make Frame objects able to accept a single hop-size buffer of audio. Samples are rotated internally.
Diffstat (limited to 'tests/test_base.cpp')
-rw-r--r-- | tests/test_base.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/test_base.cpp b/tests/test_base.cpp index 1a0816f..44b353c 100644 --- a/tests/test_base.cpp +++ b/tests/test_base.cpp @@ -19,7 +19,7 @@ void TestPeak::tearDown() { // --------------------------------------------------------------------------- void TestFrame::setUp() { - frame = new Frame(); + frame = new Frame(512, true); } void TestFrame::tearDown() { @@ -66,3 +66,26 @@ void TestFrame::test_clear() { frame->clear(); CPPUNIT_ASSERT(frame->num_peaks() == 0); } + +void TestFrame::test_audio() { + sample samples[8] = {0, 1, 2, 3, 4, 5, 6, 7}; + frame->size(8); + frame->audio(&samples[0], 8); + + CPPUNIT_ASSERT(frame->size() == 8); + + for(int i = 0; i < 8; i++) { + CPPUNIT_ASSERT(frame->audio()[i] == samples[i]); + } + + sample new_samples[2] = {8, 9}; + sample rotated_samples[8] = {2, 3, 4, 5, 6, 7, 8, 9}; + + frame->audio(&new_samples[0], 2); + + CPPUNIT_ASSERT(frame->size() == 8); + + for(int i = 0; i < 8; i++) { + CPPUNIT_ASSERT(frame->audio()[i] == rotated_samples[i]); + } +} |