TEST (AudioDataTest, FrameMutatorBounds) { KeyFinder::AudioData a; a.setChannels(2); a.addToFrameCount(10); ASSERT_THROW(a.getSampleByFrame(-1, 0), KeyFinder::Exception); ASSERT_THROW(a.getSampleByFrame(10, 0), KeyFinder::Exception); ASSERT_THROW(a.getSampleByFrame( 0,-1), KeyFinder::Exception); ASSERT_THROW(a.getSampleByFrame( 0, 2), KeyFinder::Exception); }
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, 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, 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, FrameAccessBeforeChannelsInitialised) { KeyFinder::AudioData a; a.addToSampleCount(4); ASSERT_THROW(a.getSampleByFrame(0, 0), KeyFinder::Exception); }