From 73461494d75ab794224cbe93021acfa51a8c98a9 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 9 Dec 2011 19:59:23 +0000 Subject: Add simple framewalk_to_beats test and normalise naming of test files. git-svn-id: svn://localhost/ardour2/branches/3.0@10954 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/test/bbt_test.cc | 37 ++++++ libs/ardour/test/bbt_test.cpp | 37 ------ libs/ardour/test/framewalk_to_beats_test.cc | 33 ++++++ libs/ardour/test/framewalk_to_beats_test.h | 17 +++ libs/ardour/test/interpolation_test.cc | 168 ++++++++++++++++++++++++++++ libs/ardour/test/interpolation_test.cpp | 168 ---------------------------- libs/ardour/test/mantis_3356.cc | 69 ------------ libs/ardour/test/mantis_3356.h | 13 --- libs/ardour/test/midi_clock_slave_test.cc | 45 ++++++++ libs/ardour/test/midi_clock_slave_test.cpp | 45 -------- libs/ardour/test/resampled_source.cc | 31 ----- libs/ardour/test/resampled_source.h | 12 -- libs/ardour/test/resampled_source_test.cc | 31 +++++ libs/ardour/test/resampled_source_test.h | 12 ++ libs/ardour/test/testrunner.cc | 30 +++++ libs/ardour/test/testrunner.cpp | 30 ----- libs/ardour/wscript | 16 ++- 17 files changed, 383 insertions(+), 411 deletions(-) create mode 100644 libs/ardour/test/bbt_test.cc delete mode 100644 libs/ardour/test/bbt_test.cpp create mode 100644 libs/ardour/test/framewalk_to_beats_test.cc create mode 100644 libs/ardour/test/framewalk_to_beats_test.h create mode 100644 libs/ardour/test/interpolation_test.cc delete mode 100644 libs/ardour/test/interpolation_test.cpp delete mode 100644 libs/ardour/test/mantis_3356.cc delete mode 100644 libs/ardour/test/mantis_3356.h create mode 100644 libs/ardour/test/midi_clock_slave_test.cc delete mode 100644 libs/ardour/test/midi_clock_slave_test.cpp delete mode 100644 libs/ardour/test/resampled_source.cc delete mode 100644 libs/ardour/test/resampled_source.h create mode 100644 libs/ardour/test/resampled_source_test.cc create mode 100644 libs/ardour/test/resampled_source_test.h create mode 100644 libs/ardour/test/testrunner.cc delete mode 100644 libs/ardour/test/testrunner.cpp (limited to 'libs') diff --git a/libs/ardour/test/bbt_test.cc b/libs/ardour/test/bbt_test.cc new file mode 100644 index 0000000000..4dab5c6f32 --- /dev/null +++ b/libs/ardour/test/bbt_test.cc @@ -0,0 +1,37 @@ +#include +#include "ardour/tempo.h" +#include "bbt_test.h" + +CPPUNIT_TEST_SUITE_REGISTRATION(BBTTest); + +using namespace std; +using namespace ARDOUR; + +using Timecode::BBT_Time; + +void +BBTTest::addTest () +{ + TempoMap map(48000); + Tempo tempo(120); + Meter meter(4.0, 4.0); + + map.add_meter (meter, BBT_Time(1, 1, 0)); + + // Test basic operations with a flat tempo map + BBT_Time time = map.bbt_add(BBT_Time(1, 1, 0), BBT_Time(1, 2, 3)); + //cout << "result: BBT_Time(" << time.bars << ", " << time.beats << ", " + // << time.ticks << ")" << endl; + CPPUNIT_ASSERT(time == BBT_Time(2, 3, 3)); + + + time = map.bbt_add(BBT_Time(1, 2, 3), BBT_Time(2, 2, 3)); + //cerr << "result: BBT_Time(" << time.bars << ", " << time.beats << ", " + // << time.ticks << ")" << endl; + CPPUNIT_ASSERT(time == BBT_Time(3, 4, 6)); +} + +void +BBTTest::subtractTest () +{ +} diff --git a/libs/ardour/test/bbt_test.cpp b/libs/ardour/test/bbt_test.cpp deleted file mode 100644 index 4dab5c6f32..0000000000 --- a/libs/ardour/test/bbt_test.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include -#include "ardour/tempo.h" -#include "bbt_test.h" - -CPPUNIT_TEST_SUITE_REGISTRATION(BBTTest); - -using namespace std; -using namespace ARDOUR; - -using Timecode::BBT_Time; - -void -BBTTest::addTest () -{ - TempoMap map(48000); - Tempo tempo(120); - Meter meter(4.0, 4.0); - - map.add_meter (meter, BBT_Time(1, 1, 0)); - - // Test basic operations with a flat tempo map - BBT_Time time = map.bbt_add(BBT_Time(1, 1, 0), BBT_Time(1, 2, 3)); - //cout << "result: BBT_Time(" << time.bars << ", " << time.beats << ", " - // << time.ticks << ")" << endl; - CPPUNIT_ASSERT(time == BBT_Time(2, 3, 3)); - - - time = map.bbt_add(BBT_Time(1, 2, 3), BBT_Time(2, 2, 3)); - //cerr << "result: BBT_Time(" << time.bars << ", " << time.beats << ", " - // << time.ticks << ")" << endl; - CPPUNIT_ASSERT(time == BBT_Time(3, 4, 6)); -} - -void -BBTTest::subtractTest () -{ -} diff --git a/libs/ardour/test/framewalk_to_beats_test.cc b/libs/ardour/test/framewalk_to_beats_test.cc new file mode 100644 index 0000000000..c7fb45cada --- /dev/null +++ b/libs/ardour/test/framewalk_to_beats_test.cc @@ -0,0 +1,33 @@ +#include "framewalk_to_beats_test.h" +#include "ardour/tempo.h" +#include "timecode/bbt_time.h" + +CPPUNIT_TEST_SUITE_REGISTRATION (FramewalkToBeatsTest); + +using namespace std; +using namespace ARDOUR; +using namespace Timecode; + +void +FramewalkToBeatsTest::singleTempoTest () +{ + int const sampling_rate = 48000; + int const bpm = 120; + + double const frames_per_beat = (60 / double (bpm)) * double (sampling_rate); + + TempoMap map (sampling_rate); + Tempo tempo (bpm); + Meter meter (4, 4); + + map.add_meter (meter, BBT_Time (1, 1, 0)); + map.add_tempo (tempo, BBT_Time (1, 1, 0)); + + /* Add 1 beats-worth of frames to a 2 beat starting point */ + double r = map.framewalk_to_beats (frames_per_beat * 2, frames_per_beat * 1); + CPPUNIT_ASSERT (r == 1); + + /* Add 6 beats-worth of frames to a 3 beat starting point */ + r = map.framewalk_to_beats (frames_per_beat * 3, frames_per_beat * 6); + CPPUNIT_ASSERT (r == 6); +} diff --git a/libs/ardour/test/framewalk_to_beats_test.h b/libs/ardour/test/framewalk_to_beats_test.h new file mode 100644 index 0000000000..3dd24553e2 --- /dev/null +++ b/libs/ardour/test/framewalk_to_beats_test.h @@ -0,0 +1,17 @@ +#include +#include +#include + +class FramewalkToBeatsTest : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE (FramewalkToBeatsTest); + CPPUNIT_TEST (singleTempoTest); + CPPUNIT_TEST_SUITE_END (); + +public: + void setUp () {} + void tearDown () {} + + void singleTempoTest (); +}; + diff --git a/libs/ardour/test/interpolation_test.cc b/libs/ardour/test/interpolation_test.cc new file mode 100644 index 0000000000..0bbb697b85 --- /dev/null +++ b/libs/ardour/test/interpolation_test.cc @@ -0,0 +1,168 @@ +#include +#include "interpolation_test.h" + +CPPUNIT_TEST_SUITE_REGISTRATION(InterpolationTest); + +using namespace std; +using namespace ARDOUR; + +void +InterpolationTest::linearInterpolationTest () +{ + framecnt_t result = 0; +// cout << "\nLinear Interpolation Test\n"; + +// cout << "\nSpeed: 1/3"; + for (int i = 0; 3*i < NUM_SAMPLES - 1024;) { + linear.set_speed (double(1.0)/double(3.0)); + linear.set_target_speed (double(1.0)/double(3.0)); + result = linear.interpolate (0, 1024, input + i, output + i*3); + i += result; + } + +// cout << "\nSpeed: 1.0"; + linear.reset(); + linear.set_speed (1.0); + linear.set_target_speed (linear.speed()); + result = linear.interpolate (0, NUM_SAMPLES, input, output); + CPPUNIT_ASSERT_EQUAL ((framecnt_t)(NUM_SAMPLES * linear.speed()), result); + for (int i = 0; i < NUM_SAMPLES; i += INTERVAL) { + CPPUNIT_ASSERT_EQUAL (1.0f, output[i]); + } + +// cout << "\nSpeed: 0.5"; + linear.reset(); + linear.set_speed (0.5); + linear.set_target_speed (linear.speed()); + result = linear.interpolate (0, NUM_SAMPLES, input, output); + CPPUNIT_ASSERT_EQUAL ((framecnt_t)(NUM_SAMPLES * linear.speed()), result); + for (int i = 0; i < NUM_SAMPLES; i += (INTERVAL / linear.speed() +0.5)) { + CPPUNIT_ASSERT_EQUAL (1.0f, output[i]); + } + +// cout << "\nSpeed: 0.2"; + linear.reset(); + linear.set_speed (0.2); + linear.set_target_speed (linear.speed()); + result = linear.interpolate (0, NUM_SAMPLES, input, output); + CPPUNIT_ASSERT_EQUAL ((framecnt_t)(NUM_SAMPLES * linear.speed()), result); + +// cout << "\nSpeed: 0.02"; + linear.reset(); + linear.set_speed (0.02); + linear.set_target_speed (linear.speed()); + result = linear.interpolate (0, NUM_SAMPLES, input, output); + CPPUNIT_ASSERT_EQUAL ((framecnt_t)(NUM_SAMPLES * linear.speed()), result); + + /* This one fails due too error accumulation + cout << "\nSpeed: 0.002"; + linear.reset(); + linear.set_speed (0.002); + linear.set_target_speed (linear.speed()); + result = linear.interpolate (0, NUM_SAMPLES, input, output); + linear.speed(); + CPPUNIT_ASSERT_EQUAL ((framecnt_t)(NUM_SAMPLES * linear.speed()), result); + */ + +// cout << "\nSpeed: 2.0"; + linear.reset(); + linear.set_speed (2.0); + linear.set_target_speed (linear.speed()); + result = linear.interpolate (0, NUM_SAMPLES / 2, input, output); + CPPUNIT_ASSERT_EQUAL ((framecnt_t)(NUM_SAMPLES / 2 * linear.speed()), result); + for (int i = 0; i < NUM_SAMPLES / 2; i += (INTERVAL / linear.speed() +0.5)) { + CPPUNIT_ASSERT_EQUAL (1.0f, output[i]); + } + +// cout << "\nSpeed: 10.0"; + linear.set_speed (10.0); + linear.set_target_speed (linear.speed()); + result = linear.interpolate (0, NUM_SAMPLES / 10, input, output); + CPPUNIT_ASSERT_EQUAL ((framecnt_t)(NUM_SAMPLES / 10 * linear.speed()), result); + for (int i = 0; i < NUM_SAMPLES / 10; i += (INTERVAL / linear.speed() +0.5)) { + CPPUNIT_ASSERT_EQUAL (1.0f, output[i]); + } + /* + for (int i=0; i < NUM_SAMPLES; ++i) { + cout << i << " " << output[i] << endl; + } + */ +} + +void +InterpolationTest::cubicInterpolationTest () +{ + framecnt_t result = 0; +// cout << "\nCubic Interpolation Test\n"; + +// cout << "\nSpeed: 1/3"; + for (int i = 0; 3*i < NUM_SAMPLES - 1024;) { + cubic.set_speed (double(1.0)/double(3.0)); + cubic.set_target_speed (double(1.0)/double(3.0)); + result = cubic.interpolate (0, 1024, input + i, output + i*3); + i += result; + } + +// cout << "\nSpeed: 1.0"; + cubic.reset(); + cubic.set_speed (1.0); + cubic.set_target_speed (cubic.speed()); + result = cubic.interpolate (0, NUM_SAMPLES, input, output); + CPPUNIT_ASSERT_EQUAL ((framecnt_t)(NUM_SAMPLES * cubic.speed()), result); + for (int i = 0; i < NUM_SAMPLES; i += INTERVAL) { + CPPUNIT_ASSERT_EQUAL (1.0f, output[i]); + } + +// cout << "\nSpeed: 0.5"; + cubic.reset(); + cubic.set_speed (0.5); + cubic.set_target_speed (cubic.speed()); + result = cubic.interpolate (0, NUM_SAMPLES, input, output); + CPPUNIT_ASSERT_EQUAL ((framecnt_t)(NUM_SAMPLES * cubic.speed()), result); + for (int i = 0; i < NUM_SAMPLES; i += (INTERVAL / cubic.speed() +0.5)) { + CPPUNIT_ASSERT_EQUAL (1.0f, output[i]); + } + +// cout << "\nSpeed: 0.2"; + cubic.reset(); + cubic.set_speed (0.2); + cubic.set_target_speed (cubic.speed()); + result = cubic.interpolate (0, NUM_SAMPLES, input, output); + CPPUNIT_ASSERT_EQUAL ((framecnt_t)(NUM_SAMPLES * cubic.speed()), result); + +// cout << "\nSpeed: 0.02"; + cubic.reset(); + cubic.set_speed (0.02); + cubic.set_target_speed (cubic.speed()); + result = cubic.interpolate (0, NUM_SAMPLES, input, output); + CPPUNIT_ASSERT_EQUAL ((framecnt_t)(NUM_SAMPLES * cubic.speed()), result); + + /* This one fails due too error accumulation + cout << "\nSpeed: 0.002"; + cubic.reset(); + cubic.set_speed (0.002); + cubic.set_target_speed (cubic.speed()); + result = cubic.interpolate (0, NUM_SAMPLES, input, output); + cubic.speed(); + CPPUNIT_ASSERT_EQUAL ((framecnt_t)(NUM_SAMPLES * cubic.speed()), result); + */ + +// cout << "\nSpeed: 2.0"; + cubic.reset(); + cubic.set_speed (2.0); + cubic.set_target_speed (cubic.speed()); + result = cubic.interpolate (0, NUM_SAMPLES / 2, input, output); + CPPUNIT_ASSERT_EQUAL ((framecnt_t)(NUM_SAMPLES / 2 * cubic.speed()), result); + for (int i = 0; i < NUM_SAMPLES / 2; i += (INTERVAL / cubic.speed() +0.5)) { + CPPUNIT_ASSERT_EQUAL (1.0f, output[i]); + } + +// cout << "\nSpeed: 10.0"; + cubic.set_speed (10.0); + cubic.set_target_speed (cubic.speed()); + result = cubic.interpolate (0, NUM_SAMPLES / 10, input, output); + CPPUNIT_ASSERT_EQUAL ((framecnt_t)(NUM_SAMPLES / 10 * cubic.speed()), result); + for (int i = 0; i < NUM_SAMPLES / 10; i += (INTERVAL / cubic.speed() +0.5)) { + CPPUNIT_ASSERT_EQUAL (1.0f, output[i]); + } +} diff --git a/libs/ardour/test/interpolation_test.cpp b/libs/ardour/test/interpolation_test.cpp deleted file mode 100644 index 0bbb697b85..0000000000 --- a/libs/ardour/test/interpolation_test.cpp +++ /dev/null @@ -1,168 +0,0 @@ -#include -#include "interpolation_test.h" - -CPPUNIT_TEST_SUITE_REGISTRATION(InterpolationTest); - -using namespace std; -using namespace ARDOUR; - -void -InterpolationTest::linearInterpolationTest () -{ - framecnt_t result = 0; -// cout << "\nLinear Interpolation Test\n"; - -// cout << "\nSpeed: 1/3"; - for (int i = 0; 3*i < NUM_SAMPLES - 1024;) { - linear.set_speed (double(1.0)/double(3.0)); - linear.set_target_speed (double(1.0)/double(3.0)); - result = linear.interpolate (0, 1024, input + i, output + i*3); - i += result; - } - -// cout << "\nSpeed: 1.0"; - linear.reset(); - linear.set_speed (1.0); - linear.set_target_speed (linear.speed()); - result = linear.interpolate (0, NUM_SAMPLES, input, output); - CPPUNIT_ASSERT_EQUAL ((framecnt_t)(NUM_SAMPLES * linear.speed()), result); - for (int i = 0; i < NUM_SAMPLES; i += INTERVAL) { - CPPUNIT_ASSERT_EQUAL (1.0f, output[i]); - } - -// cout << "\nSpeed: 0.5"; - linear.reset(); - linear.set_speed (0.5); - linear.set_target_speed (linear.speed()); - result = linear.interpolate (0, NUM_SAMPLES, input, output); - CPPUNIT_ASSERT_EQUAL ((framecnt_t)(NUM_SAMPLES * linear.speed()), result); - for (int i = 0; i < NUM_SAMPLES; i += (INTERVAL / linear.speed() +0.5)) { - CPPUNIT_ASSERT_EQUAL (1.0f, output[i]); - } - -// cout << "\nSpeed: 0.2"; - linear.reset(); - linear.set_speed (0.2); - linear.set_target_speed (linear.speed()); - result = linear.interpolate (0, NUM_SAMPLES, input, output); - CPPUNIT_ASSERT_EQUAL ((framecnt_t)(NUM_SAMPLES * linear.speed()), result); - -// cout << "\nSpeed: 0.02"; - linear.reset(); - linear.set_speed (0.02); - linear.set_target_speed (linear.speed()); - result = linear.interpolate (0, NUM_SAMPLES, input, output); - CPPUNIT_ASSERT_EQUAL ((framecnt_t)(NUM_SAMPLES * linear.speed()), result); - - /* This one fails due too error accumulation - cout << "\nSpeed: 0.002"; - linear.reset(); - linear.set_speed (0.002); - linear.set_target_speed (linear.speed()); - result = linear.interpolate (0, NUM_SAMPLES, input, output); - linear.speed(); - CPPUNIT_ASSERT_EQUAL ((framecnt_t)(NUM_SAMPLES * linear.speed()), result); - */ - -// cout << "\nSpeed: 2.0"; - linear.reset(); - linear.set_speed (2.0); - linear.set_target_speed (linear.speed()); - result = linear.interpolate (0, NUM_SAMPLES / 2, input, output); - CPPUNIT_ASSERT_EQUAL ((framecnt_t)(NUM_SAMPLES / 2 * linear.speed()), result); - for (int i = 0; i < NUM_SAMPLES / 2; i += (INTERVAL / linear.speed() +0.5)) { - CPPUNIT_ASSERT_EQUAL (1.0f, output[i]); - } - -// cout << "\nSpeed: 10.0"; - linear.set_speed (10.0); - linear.set_target_speed (linear.speed()); - result = linear.interpolate (0, NUM_SAMPLES / 10, input, output); - CPPUNIT_ASSERT_EQUAL ((framecnt_t)(NUM_SAMPLES / 10 * linear.speed()), result); - for (int i = 0; i < NUM_SAMPLES / 10; i += (INTERVAL / linear.speed() +0.5)) { - CPPUNIT_ASSERT_EQUAL (1.0f, output[i]); - } - /* - for (int i=0; i < NUM_SAMPLES; ++i) { - cout << i << " " << output[i] << endl; - } - */ -} - -void -InterpolationTest::cubicInterpolationTest () -{ - framecnt_t result = 0; -// cout << "\nCubic Interpolation Test\n"; - -// cout << "\nSpeed: 1/3"; - for (int i = 0; 3*i < NUM_SAMPLES - 1024;) { - cubic.set_speed (double(1.0)/double(3.0)); - cubic.set_target_speed (double(1.0)/double(3.0)); - result = cubic.interpolate (0, 1024, input + i, output + i*3); - i += result; - } - -// cout << "\nSpeed: 1.0"; - cubic.reset(); - cubic.set_speed (1.0); - cubic.set_target_speed (cubic.speed()); - result = cubic.interpolate (0, NUM_SAMPLES, input, output); - CPPUNIT_ASSERT_EQUAL ((framecnt_t)(NUM_SAMPLES * cubic.speed()), result); - for (int i = 0; i < NUM_SAMPLES; i += INTERVAL) { - CPPUNIT_ASSERT_EQUAL (1.0f, output[i]); - } - -// cout << "\nSpeed: 0.5"; - cubic.reset(); - cubic.set_speed (0.5); - cubic.set_target_speed (cubic.speed()); - result = cubic.interpolate (0, NUM_SAMPLES, input, output); - CPPUNIT_ASSERT_EQUAL ((framecnt_t)(NUM_SAMPLES * cubic.speed()), result); - for (int i = 0; i < NUM_SAMPLES; i += (INTERVAL / cubic.speed() +0.5)) { - CPPUNIT_ASSERT_EQUAL (1.0f, output[i]); - } - -// cout << "\nSpeed: 0.2"; - cubic.reset(); - cubic.set_speed (0.2); - cubic.set_target_speed (cubic.speed()); - result = cubic.interpolate (0, NUM_SAMPLES, input, output); - CPPUNIT_ASSERT_EQUAL ((framecnt_t)(NUM_SAMPLES * cubic.speed()), result); - -// cout << "\nSpeed: 0.02"; - cubic.reset(); - cubic.set_speed (0.02); - cubic.set_target_speed (cubic.speed()); - result = cubic.interpolate (0, NUM_SAMPLES, input, output); - CPPUNIT_ASSERT_EQUAL ((framecnt_t)(NUM_SAMPLES * cubic.speed()), result); - - /* This one fails due too error accumulation - cout << "\nSpeed: 0.002"; - cubic.reset(); - cubic.set_speed (0.002); - cubic.set_target_speed (cubic.speed()); - result = cubic.interpolate (0, NUM_SAMPLES, input, output); - cubic.speed(); - CPPUNIT_ASSERT_EQUAL ((framecnt_t)(NUM_SAMPLES * cubic.speed()), result); - */ - -// cout << "\nSpeed: 2.0"; - cubic.reset(); - cubic.set_speed (2.0); - cubic.set_target_speed (cubic.speed()); - result = cubic.interpolate (0, NUM_SAMPLES / 2, input, output); - CPPUNIT_ASSERT_EQUAL ((framecnt_t)(NUM_SAMPLES / 2 * cubic.speed()), result); - for (int i = 0; i < NUM_SAMPLES / 2; i += (INTERVAL / cubic.speed() +0.5)) { - CPPUNIT_ASSERT_EQUAL (1.0f, output[i]); - } - -// cout << "\nSpeed: 10.0"; - cubic.set_speed (10.0); - cubic.set_target_speed (cubic.speed()); - result = cubic.interpolate (0, NUM_SAMPLES / 10, input, output); - CPPUNIT_ASSERT_EQUAL ((framecnt_t)(NUM_SAMPLES / 10 * cubic.speed()), result); - for (int i = 0; i < NUM_SAMPLES / 10; i += (INTERVAL / cubic.speed() +0.5)) { - CPPUNIT_ASSERT_EQUAL (1.0f, output[i]); - } -} diff --git a/libs/ardour/test/mantis_3356.cc b/libs/ardour/test/mantis_3356.cc deleted file mode 100644 index 2a68fca352..0000000000 --- a/libs/ardour/test/mantis_3356.cc +++ /dev/null @@ -1,69 +0,0 @@ -#include -#include "midi++/manager.h" -#include "pbd/textreceiver.h" -#include "ardour/session.h" -#include "ardour/audioengine.h" -#include "ardour/smf_source.h" -#include "ardour/midi_model.h" -#include "test/mantis_3356.h" - -CPPUNIT_TEST_SUITE_REGISTRATION (Mantis3356Test); - -using namespace std; -using namespace ARDOUR; -using namespace PBD; - -TextReceiver text_receiver ("test"); - -void -Mantis3356Test::test () -{ - init (false, true); - SessionEvent::create_per_thread_pool ("test", 512); - - text_receiver.listen_to (error); - text_receiver.listen_to (info); - text_receiver.listen_to (fatal); - text_receiver.listen_to (warning); - - AudioEngine engine ("test", ""); - MIDI::Manager::create (engine.jack ()); - CPPUNIT_ASSERT (engine.start () == 0); - - Session session (engine, "../libs/ardour/test/data/mantis_3356", "mantis_3356"); - engine.set_session (&session); - - Session::SourceMap sources = session.get_sources (); - - boost::shared_ptr source = boost::dynamic_pointer_cast (sources[ID ("87")]); - CPPUNIT_ASSERT (source); - - boost::shared_ptr model = source->model (); - CPPUNIT_ASSERT (model); - - stringstream result; - - for (MidiModel::const_iterator i = model->begin(); i != model->end(); ++i) { - result << *i << "\n"; - } - - ifstream ref ("../libs/ardour/test/data/mantis_3356.ref"); - - while (1) { - string a; - string b; - - getline (ref, a); - getline (result, b); - - CPPUNIT_ASSERT (a == b); - - if (result.eof() && ref.eof()) { - break; - } - - CPPUNIT_ASSERT (!result.eof ()); - CPPUNIT_ASSERT (!ref.eof ()); - } - -} diff --git a/libs/ardour/test/mantis_3356.h b/libs/ardour/test/mantis_3356.h deleted file mode 100644 index cda9712f90..0000000000 --- a/libs/ardour/test/mantis_3356.h +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include - -/** Test for Mantis bug #3356 */ -class Mantis3356Test : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE (Mantis3356Test); - CPPUNIT_TEST (test); - CPPUNIT_TEST_SUITE_END (); - -public: - void test (); -}; diff --git a/libs/ardour/test/midi_clock_slave_test.cc b/libs/ardour/test/midi_clock_slave_test.cc new file mode 100644 index 0000000000..dcb159cb2c --- /dev/null +++ b/libs/ardour/test/midi_clock_slave_test.cc @@ -0,0 +1,45 @@ +#include +#include "midi_clock_slave_test.h" + +using namespace std; +using namespace ARDOUR; + +CPPUNIT_TEST_SUITE_REGISTRATION( MIDIClock_SlaveTest ); + +void +MIDIClock_SlaveTest::testStepResponse () +{ + double speed = 1.0; + framepos_t position = 0; + + MIDI::Parser* parser = 0; + + TestSlaveSessionProxy *sess = (TestSlaveSessionProxy *) session; + framecnt_t period_size = 4096; + sess->set_period_size (period_size); + + bandwidth = 1.0 / 60.0; + + framepos_t start_time = 1000000; + start (*parser, start_time); + + update_midi_clock (*parser, start_time); + + for (framecnt_t i = 1; i<= 100 * period_size; i++) { + // simulate jitter + framecnt_t input_delta = framecnt_t (one_ppqn_in_frames + 0.1 * (double(random()) / double (RAND_MAX)) * one_ppqn_in_frames); + + if (i % input_delta == 0) { + update_midi_clock (*parser, start_time + i); + } + + if (i % period_size == 0) { + sess->next_period (); + speed_and_position (speed, position); + sess->request_transport_speed (speed); + } + } + +} + + diff --git a/libs/ardour/test/midi_clock_slave_test.cpp b/libs/ardour/test/midi_clock_slave_test.cpp deleted file mode 100644 index dcb159cb2c..0000000000 --- a/libs/ardour/test/midi_clock_slave_test.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include -#include "midi_clock_slave_test.h" - -using namespace std; -using namespace ARDOUR; - -CPPUNIT_TEST_SUITE_REGISTRATION( MIDIClock_SlaveTest ); - -void -MIDIClock_SlaveTest::testStepResponse () -{ - double speed = 1.0; - framepos_t position = 0; - - MIDI::Parser* parser = 0; - - TestSlaveSessionProxy *sess = (TestSlaveSessionProxy *) session; - framecnt_t period_size = 4096; - sess->set_period_size (period_size); - - bandwidth = 1.0 / 60.0; - - framepos_t start_time = 1000000; - start (*parser, start_time); - - update_midi_clock (*parser, start_time); - - for (framecnt_t i = 1; i<= 100 * period_size; i++) { - // simulate jitter - framecnt_t input_delta = framecnt_t (one_ppqn_in_frames + 0.1 * (double(random()) / double (RAND_MAX)) * one_ppqn_in_frames); - - if (i % input_delta == 0) { - update_midi_clock (*parser, start_time + i); - } - - if (i % period_size == 0) { - sess->next_period (); - speed_and_position (speed, position); - sess->request_transport_speed (speed); - } - } - -} - - diff --git a/libs/ardour/test/resampled_source.cc b/libs/ardour/test/resampled_source.cc deleted file mode 100644 index bb8cd76f56..0000000000 --- a/libs/ardour/test/resampled_source.cc +++ /dev/null @@ -1,31 +0,0 @@ -#include "ardour/resampled_source.h" -#include "ardour/sndfileimportable.h" -#include "resampled_source.h" - -CPPUNIT_TEST_SUITE_REGISTRATION (ResampledSourceTest); - -using namespace ARDOUR; - -void -ResampledSourceTest::seekTest () -{ - boost::shared_ptr s (new SndFileImportableSource ("../libs/ardour/test/data/test.wav")); - ResampledImportableSource r (s, 48000, SrcBest); - - /* Make sure that seek (0) has the desired effect, ie that - given the same input you get the same output after seek (0) - as you got when the Source was newly created. - */ - - Sample A[64]; - r.read (A, 64); - - r.seek (0); - - Sample B[64]; - r.read (B, 64); - - for (int i = 0; i < 64; ++i) { - CPPUNIT_ASSERT (A[i] == B[i]); - } -} diff --git a/libs/ardour/test/resampled_source.h b/libs/ardour/test/resampled_source.h deleted file mode 100644 index c836968987..0000000000 --- a/libs/ardour/test/resampled_source.h +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include - -class ResampledSourceTest : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE (ResampledSourceTest); - CPPUNIT_TEST (seekTest); - CPPUNIT_TEST_SUITE_END (); - -public: - void seekTest (); -}; diff --git a/libs/ardour/test/resampled_source_test.cc b/libs/ardour/test/resampled_source_test.cc new file mode 100644 index 0000000000..983c0d88d2 --- /dev/null +++ b/libs/ardour/test/resampled_source_test.cc @@ -0,0 +1,31 @@ +#include "ardour/resampled_source.h" +#include "ardour/sndfileimportable.h" +#include "resampled_source_test.h" + +CPPUNIT_TEST_SUITE_REGISTRATION (ResampledSourceTest); + +using namespace ARDOUR; + +void +ResampledSourceTest::seekTest () +{ + boost::shared_ptr s (new SndFileImportableSource ("../libs/ardour/test/data/test.wav")); + ResampledImportableSource r (s, 48000, SrcBest); + + /* Make sure that seek (0) has the desired effect, ie that + given the same input you get the same output after seek (0) + as you got when the Source was newly created. + */ + + Sample A[64]; + r.read (A, 64); + + r.seek (0); + + Sample B[64]; + r.read (B, 64); + + for (int i = 0; i < 64; ++i) { + CPPUNIT_ASSERT (A[i] == B[i]); + } +} diff --git a/libs/ardour/test/resampled_source_test.h b/libs/ardour/test/resampled_source_test.h new file mode 100644 index 0000000000..c836968987 --- /dev/null +++ b/libs/ardour/test/resampled_source_test.h @@ -0,0 +1,12 @@ +#include +#include + +class ResampledSourceTest : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE (ResampledSourceTest); + CPPUNIT_TEST (seekTest); + CPPUNIT_TEST_SUITE_END (); + +public: + void seekTest (); +}; diff --git a/libs/ardour/test/testrunner.cc b/libs/ardour/test/testrunner.cc new file mode 100644 index 0000000000..ebbd50543e --- /dev/null +++ b/libs/ardour/test/testrunner.cc @@ -0,0 +1,30 @@ +#include +#include +#include +#include +#include +#include +#include "ardour/ardour.h" + +int +main() +{ + ARDOUR::init (false, false); + + CppUnit::TestResult testresult; + + CppUnit::TestResultCollector collectedresults; + testresult.addListener (&collectedresults); + + CppUnit::BriefTestProgressListener progress; + testresult.addListener (&progress); + + CppUnit::TestRunner testrunner; + testrunner.addTest (CppUnit::TestFactoryRegistry::getRegistry ().makeTest ()); + testrunner.run (testresult); + + CppUnit::CompilerOutputter compileroutputter (&collectedresults, std::cerr); + compileroutputter.write (); + + return collectedresults.wasSuccessful () ? 0 : 1; +} diff --git a/libs/ardour/test/testrunner.cpp b/libs/ardour/test/testrunner.cpp deleted file mode 100644 index ebbd50543e..0000000000 --- a/libs/ardour/test/testrunner.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include "ardour/ardour.h" - -int -main() -{ - ARDOUR::init (false, false); - - CppUnit::TestResult testresult; - - CppUnit::TestResultCollector collectedresults; - testresult.addListener (&collectedresults); - - CppUnit::BriefTestProgressListener progress; - testresult.addListener (&progress); - - CppUnit::TestRunner testrunner; - testrunner.addTest (CppUnit::TestFactoryRegistry::getRegistry ().makeTest ()); - testrunner.run (testresult); - - CppUnit::CompilerOutputter compileroutputter (&collectedresults, std::cerr); - compileroutputter.write (); - - return collectedresults.wasSuccessful () ? 0 : 1; -} diff --git a/libs/ardour/wscript b/libs/ardour/wscript index dfdb4a47ca..2b9151c385 100644 --- a/libs/ardour/wscript +++ b/libs/ardour/wscript @@ -423,13 +423,17 @@ def build(bld): testobj = bld(features = 'cxx cxxprogram') testobj.source = ''' test/dummy_lxvst.cc - test/bbt_test.cpp - test/interpolation_test.cpp - test/midi_clock_slave_test.cpp - test/resampled_source.cc - test/mantis_3356.cc - test/testrunner.cpp + test/bbt_test.cc + test/interpolation_test.cc + test/midi_clock_slave_test.cc + test/resampled_source_test.cc + test/framewalk_to_beats_test.cc + test/testrunner.cc '''.split() + +# Tests that don't work +# test/mantis_3356_test.cc + testobj.includes = obj.includes + ['test', '../pbd'] testobj.uselib = ['CPPUNIT','SIGCPP','JACK','GLIBMM','GTHREAD', 'SAMPLERATE','XML','LRDF','COREAUDIO'] -- cgit v1.2.3