TEST (AudioDataTest, PrependToInitialised) { KeyFinder::AudioData a; KeyFinder::AudioData b; a.setChannels(1); a.setFrameRate(1); ASSERT_THROW(a.prepend(b), KeyFinder::Exception); b.setChannels(2); b.setFrameRate(1); ASSERT_THROW(a.prepend(b), KeyFinder::Exception); b.setChannels(1); b.setFrameRate(2); ASSERT_THROW(a.prepend(b), KeyFinder::Exception); b.setChannels(1); b.setFrameRate(1); ASSERT_NO_THROW(a.prepend(b)); a.addToFrameCount(1); b.addToFrameCount(1); a.setSampleByFrame(0, 0, 10.0); b.setSampleByFrame(0, 0, 20.0); a.prepend(b); ASSERT_EQ(2, a.getFrameCount()); ASSERT_FLOAT_EQ(20.0, a.getSampleByFrame(0, 0)); ASSERT_FLOAT_EQ(10.0, a.getSampleByFrame(1, 0)); }
TEST (AudioDataTest, FrameMutator) { KeyFinder::AudioData a; a.setChannels(4); a.addToFrameCount(5); ASSERT_EQ(5, a.getFrameCount()); ASSERT_EQ(20, a.getSampleCount()); a.setSample(6, 10.0); ASSERT_FLOAT_EQ(10.0, a.getSample(6)); ASSERT_FLOAT_EQ(10.0, a.getSampleByFrame(1, 2)); a.setSampleByFrame(1, 2, 20.0); ASSERT_FLOAT_EQ(20.0, a.getSample(6)); ASSERT_FLOAT_EQ(20.0, a.getSampleByFrame(1, 2)); }
TEST (AudioDataTest, DiscardFromFront) { KeyFinder::AudioData a; a.setChannels(1); a.setFrameRate(1); ASSERT_THROW(a.discardFramesFromFront(1), KeyFinder::Exception); a.addToFrameCount(10); ASSERT_THROW(a.discardFramesFromFront(11), KeyFinder::Exception); ASSERT_NO_THROW(a.discardFramesFromFront(0)); a.setSampleByFrame(5, 0, 10.0); ASSERT_NO_THROW(a.discardFramesFromFront(5)); ASSERT_EQ(5, a.getFrameCount()); ASSERT_FLOAT_EQ(10.0, a.getSampleByFrame(0, 0)); }
TEST (AudioDataTest, PrependToNew) { KeyFinder::AudioData a; KeyFinder::AudioData b; ASSERT_NO_THROW(a.prepend(b)); ASSERT_EQ(0, a.getChannels()); ASSERT_EQ(0, a.getFrameRate()); b.setChannels(1); b.setFrameRate(1); b.addToFrameCount(1); ASSERT_NO_THROW(a.prepend(b)); ASSERT_EQ(1, a.getChannels()); ASSERT_EQ(1, a.getFrameRate()); ASSERT_EQ(1, a.getFrameCount()); }