예제 #1
0
TEST (AudioDataTest, AppendToInitialised) {
  KeyFinder::AudioData a;
  KeyFinder::AudioData b;

  a.setChannels(1);
  a.setFrameRate(1);
  ASSERT_THROW(a.append(b), KeyFinder::Exception);

  b.setChannels(2);
  b.setFrameRate(1);
  ASSERT_THROW(a.append(b), KeyFinder::Exception);

  b.setChannels(1);
  b.setFrameRate(2);
  ASSERT_THROW(a.append(b), KeyFinder::Exception);

  b.setChannels(1);
  b.setFrameRate(1);
  ASSERT_NO_THROW(a.append(b));

  a.addToFrameCount(1);
  b.addToFrameCount(1);
  a.setSampleByFrame(0, 0, 10.0);
  b.setSampleByFrame(0, 0, 20.0);

  a.append(b);
  ASSERT_EQ(2, a.getFrameCount());
  ASSERT_FLOAT_EQ(10.0, a.getSampleByFrame(0, 0));
  ASSERT_FLOAT_EQ(20.0, a.getSampleByFrame(1, 0));
}
예제 #2
0
TEST (AudioDataTest, AppendToNew) {
  KeyFinder::AudioData a;
  KeyFinder::AudioData b;

  ASSERT_NO_THROW(a.append(b));
  ASSERT_EQ(0, a.getChannels());
  ASSERT_EQ(0, a.getFrameRate());

  b.setChannels(1);
  b.setFrameRate(1);
  b.addToFrameCount(1);

  ASSERT_NO_THROW(a.append(b));
  ASSERT_EQ(1, a.getChannels());
  ASSERT_EQ(1, a.getFrameRate());
  ASSERT_EQ(1, a.getFrameCount());
}