Skip to content

Commit

Permalink
Added an additional unittest for DummyReader (for invalid frame)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonoomph committed Jun 6, 2020
1 parent 7831cfe commit d29027a
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/DummyReader_Tests.cpp
Expand Up @@ -99,4 +99,23 @@ TEST (DummyReader_Fake_Frame) {
CHECK_EQUAL(2, r.GetFrame(2)->GetAudioSamples(0)[0]);
CHECK_CLOSE(2.00068033, r.GetFrame(2)->GetAudioSamples(0)[1], 0.00001);
CHECK_CLOSE(2.00136054, r.GetFrame(2)->GetAudioSamples(0)[2], 0.00001);
}

TEST (DummyReader_Invalid_Fake_Frame) {
// Create a default fraction (should be 1/1)
openshot::DummyReader r(openshot::Fraction(30, 1), 1920, 1080, 44100, 2, 30.0);
r.Open();

// Create fake frames (with specific frame #, samples, and channels)
std::shared_ptr<openshot::Frame> f1(new openshot::Frame(1, 1470, 2));
std::shared_ptr<openshot::Frame> f2(new openshot::Frame(2, 1470, 2));

// Write test frames to dummy reader
r.WriteFrame(f1);
r.WriteFrame(f2);

// Verify exception
CHECK_EQUAL(1, r.GetFrame(1)->number);
CHECK_EQUAL(2, r.GetFrame(2)->number);
CHECK_THROW(r.GetFrame(3)->number, InvalidFile);
}

0 comments on commit d29027a

Please sign in to comment.