* add waf option to enable compilation of unit tests
authorHans Baier <hansfbaier@googlemail.com>
Fri, 29 Jan 2010 05:17:44 +0000 (05:17 +0000)
committerHans Baier <hansfbaier@googlemail.com>
Fri, 29 Jan 2010 05:17:44 +0000 (05:17 +0000)
* libs/ardour: make filenames of unit tests compy with the convention

git-svn-id: svn://localhost/ardour2/branches/3.0@6583 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/run-tests.sh
libs/ardour/test/BBTTest.cpp [deleted file]
libs/ardour/test/BBTTest.hpp [deleted file]
libs/ardour/test/InterpolationTest.cpp [deleted file]
libs/ardour/test/InterpolationTest.h [deleted file]
libs/ardour/test/bbt_test.cpp [new file with mode: 0644]
libs/ardour/test/bbt_test.h [new file with mode: 0644]
libs/ardour/test/interpolation_test.cpp [new file with mode: 0644]
libs/ardour/test/interpolation_test.h [new file with mode: 0644]
libs/ardour/wscript
wscript

index 9bcaca6f5ccadd1864157003d86261d5eb5e112d..3fc79920fdd3999b1faef0a0410c60c1d840bf5b 100755 (executable)
@@ -10,7 +10,8 @@ cd ../../build/default
 
 libs='libs'
 
-export LD_LIBRARY_PATH=$libs/vamp-sdk:$libs/surfaces:$libs/surfaces/control_protocol:$libs/ardour:$libs/midi++2:$libs/pbd:$libs/rubberband:$libs/soundtouch:$libs/gtkmm2ext:$libs/sigc++2:$libs/glibmm2:$libs/gtkmm2/atk:$libs/gtkmm2/pango:$libs/gtkmm2/gdk:$libs/gtkmm2/gtk:$libs/libgnomecanvasmm:$libs/libsndfile:$libs/appleutility:$libs/cairomm:$libs/taglib:$libs/evoral:$libs/evoral/src/libsmf:$LD_LIBRARY_PATH
+export LD_LIBRARY_PATH=$libs/audiographer:$libs/vamp-sdk:$libs/surfaces:$libs/surfaces/control_protocol:$libs/ardour:$libs/midi++2:$libs/pbd:$libs/rubberband:$libs/soundtouch:$libs/gtkmm2ext:$libs/sigc++2:$libs/glibmm2:$libs/gtkmm2/atk:$libs/gtkmm2/pango:$libs/gtkmm2/gdk:$libs/gtkmm2/gtk:$libs/libgnomecanvasmm:$libs/libsndfile:$libs/appleutility:$libs/cairomm:$libs/taglib:$libs/evoral:$libs/evoral/src/libsmf:$LD_LIBRARY_PATH
 
-echo $LD_LIBRARY_PATH
-./libs/ardour/run-tests
+echo LD_LIBRARY_PATH = $LD_LIBRARY_PATH
+
+gdb ./libs/ardour/run-tests
diff --git a/libs/ardour/test/BBTTest.cpp b/libs/ardour/test/BBTTest.cpp
deleted file mode 100644 (file)
index 5f5f18b..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#include <cassert>
-#include "ardour/tempo.h"
-#include "BBTTest.hpp"
-
-CPPUNIT_TEST_SUITE_REGISTRATION(BBTTest);
-
-using namespace std;
-using namespace ARDOUR;
-
-void
-BBTTest::addTest ()
-{
-       TempoMap map(48000);
-
-       // Test basic operations with a flat tempo map
-       CPPUNIT_ASSERT(map.bbt_add(BBT_Time(0, 0, 0), BBT_Time(1, 2, 3)) == BBT_Time(1, 2, 3));
-       CPPUNIT_ASSERT(map.bbt_add(BBT_Time(1, 2, 3), BBT_Time(0, 0, 0)) == BBT_Time(1, 2, 3));
-}
-
-void
-BBTTest::subtractTest ()
-{
-}
diff --git a/libs/ardour/test/BBTTest.hpp b/libs/ardour/test/BBTTest.hpp
deleted file mode 100644 (file)
index b823b2a..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-#include <cassert>
-#include <sigc++/sigc++.h>
-#include <cppunit/TestFixture.h>
-#include <cppunit/extensions/HelperMacros.h>
-#include "ardour/bbt_time.h"
-
-class BBTTest : public CppUnit::TestFixture
-{
-       CPPUNIT_TEST_SUITE (BBTTest);
-       CPPUNIT_TEST (addTest);
-       CPPUNIT_TEST (subtractTest);
-       CPPUNIT_TEST_SUITE_END ();
-
-public:
-       void setUp () {
-       }
-
-       void tearDown () {
-       }
-
-       void addTest ();
-       void subtractTest ();
-
-private:
-};
diff --git a/libs/ardour/test/InterpolationTest.cpp b/libs/ardour/test/InterpolationTest.cpp
deleted file mode 100644 (file)
index 7fd8a72..0000000
+++ /dev/null
@@ -1,168 +0,0 @@
-#include <sigc++/sigc++.h>
-#include "InterpolationTest.h"
-
-CPPUNIT_TEST_SUITE_REGISTRATION(InterpolationTest);
-
-using namespace std;
-using namespace ARDOUR;
-
-void
-InterpolationTest::linearInterpolationTest ()
-{
-       nframes_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 ((uint32_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 ((uint32_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 ((uint32_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 ((uint32_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 ((nframes_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 ((uint32_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 ((uint32_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 ()
-{
-       nframes_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 ((uint32_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 ((uint32_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 ((uint32_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 ((uint32_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 ((nframes_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 ((uint32_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 ((uint32_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/InterpolationTest.h b/libs/ardour/test/InterpolationTest.h
deleted file mode 100644 (file)
index a051990..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/* Copyright(C) 2000-2008 Paul Davis
- * Author: Hans Baier
- *
- * Evoral is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or(at your option) any later
- * version.
- *
- * Evoral is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <cassert>
-#include <stdint.h>
-#include <cppunit/TestFixture.h>
-#include <cppunit/extensions/HelperMacros.h>
-
-#include "ardour/interpolation.h"
-
-class InterpolationTest : public CppUnit::TestFixture
-{
-       CPPUNIT_TEST_SUITE(InterpolationTest);
-       CPPUNIT_TEST(cubicInterpolationTest);
-       CPPUNIT_TEST(linearInterpolationTest);
-       CPPUNIT_TEST_SUITE_END();
-
-#define NUM_SAMPLES 1000000
-#define INTERVAL 100
-
-       ARDOUR::Sample input[NUM_SAMPLES];
-       ARDOUR::Sample output[NUM_SAMPLES];
-
-       ARDOUR::LinearInterpolation linear;
-       ARDOUR::CubicInterpolation  cubic;
-
-       public:
-
-       void setUp() {
-               for (int i = 0; i < NUM_SAMPLES; ++i) {
-                       if (i % INTERVAL == 0) {
-                               input[i] = 1.0f;
-                       } else {
-                               input[i] = 0.0f;
-                       }
-                       output[i] = 0.0f;
-               }
-               linear.add_channel_to (NUM_SAMPLES, NUM_SAMPLES);
-               cubic.add_channel_to (NUM_SAMPLES, NUM_SAMPLES);
-       }
-
-       void tearDown() {
-       }
-
-       void linearInterpolationTest();
-       void cubicInterpolationTest();
-};
diff --git a/libs/ardour/test/bbt_test.cpp b/libs/ardour/test/bbt_test.cpp
new file mode 100644 (file)
index 0000000..be1605a
--- /dev/null
@@ -0,0 +1,23 @@
+#include <cassert>
+#include "ardour/tempo.h"
+#include "bbt_test.h"
+
+CPPUNIT_TEST_SUITE_REGISTRATION(BBTTest);
+
+using namespace std;
+using namespace ARDOUR;
+
+void
+BBTTest::addTest ()
+{
+       TempoMap map(48000);
+
+       // Test basic operations with a flat tempo map
+       CPPUNIT_ASSERT(map.bbt_add(BBT_Time(0, 0, 0), BBT_Time(1, 2, 3)) == BBT_Time(1, 2, 3));
+       CPPUNIT_ASSERT(map.bbt_add(BBT_Time(1, 2, 3), BBT_Time(0, 0, 0)) == BBT_Time(1, 2, 3));
+}
+
+void
+BBTTest::subtractTest ()
+{
+}
diff --git a/libs/ardour/test/bbt_test.h b/libs/ardour/test/bbt_test.h
new file mode 100644 (file)
index 0000000..b823b2a
--- /dev/null
@@ -0,0 +1,25 @@
+#include <cassert>
+#include <sigc++/sigc++.h>
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include "ardour/bbt_time.h"
+
+class BBTTest : public CppUnit::TestFixture
+{
+       CPPUNIT_TEST_SUITE (BBTTest);
+       CPPUNIT_TEST (addTest);
+       CPPUNIT_TEST (subtractTest);
+       CPPUNIT_TEST_SUITE_END ();
+
+public:
+       void setUp () {
+       }
+
+       void tearDown () {
+       }
+
+       void addTest ();
+       void subtractTest ();
+
+private:
+};
diff --git a/libs/ardour/test/interpolation_test.cpp b/libs/ardour/test/interpolation_test.cpp
new file mode 100644 (file)
index 0000000..107d373
--- /dev/null
@@ -0,0 +1,168 @@
+#include <sigc++/sigc++.h>
+#include "interpolation_test.h"
+
+CPPUNIT_TEST_SUITE_REGISTRATION(InterpolationTest);
+
+using namespace std;
+using namespace ARDOUR;
+
+void
+InterpolationTest::linearInterpolationTest ()
+{
+       nframes_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 ((uint32_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 ((uint32_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 ((uint32_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 ((uint32_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 ((nframes_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 ((uint32_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 ((uint32_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 ()
+{
+       nframes_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 ((uint32_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 ((uint32_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 ((uint32_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 ((uint32_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 ((nframes_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 ((uint32_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 ((uint32_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.h b/libs/ardour/test/interpolation_test.h
new file mode 100644 (file)
index 0000000..a051990
--- /dev/null
@@ -0,0 +1,61 @@
+/* Copyright(C) 2000-2008 Paul Davis
+ * Author: Hans Baier
+ *
+ * Evoral is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or(at your option) any later
+ * version.
+ *
+ * Evoral is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <cassert>
+#include <stdint.h>
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "ardour/interpolation.h"
+
+class InterpolationTest : public CppUnit::TestFixture
+{
+       CPPUNIT_TEST_SUITE(InterpolationTest);
+       CPPUNIT_TEST(cubicInterpolationTest);
+       CPPUNIT_TEST(linearInterpolationTest);
+       CPPUNIT_TEST_SUITE_END();
+
+#define NUM_SAMPLES 1000000
+#define INTERVAL 100
+
+       ARDOUR::Sample input[NUM_SAMPLES];
+       ARDOUR::Sample output[NUM_SAMPLES];
+
+       ARDOUR::LinearInterpolation linear;
+       ARDOUR::CubicInterpolation  cubic;
+
+       public:
+
+       void setUp() {
+               for (int i = 0; i < NUM_SAMPLES; ++i) {
+                       if (i % INTERVAL == 0) {
+                               input[i] = 1.0f;
+                       } else {
+                               input[i] = 0.0f;
+                       }
+                       output[i] = 0.0f;
+               }
+               linear.add_channel_to (NUM_SAMPLES, NUM_SAMPLES);
+               cubic.add_channel_to (NUM_SAMPLES, NUM_SAMPLES);
+       }
+
+       void tearDown() {
+       }
+
+       void linearInterpolationTest();
+       void cubicInterpolationTest();
+};
index dfa05ba752ad60f64f65f17cd8552341bbf52801..a6ea97ec0dba043c6f1c8823f5a55a549a13bae4 100644 (file)
@@ -321,8 +321,8 @@ def build(bld):
                # Unit tests
                testobj              = bld.new_task_gen('cxx', 'program')
                testobj.source       = '''
-                       test/BBTTest.cpp
-                       test/InterpolationTest.cpp
+                       test/bbt_test.cpp
+                       test/interpolation_test.cpp
                        test/testrunner.cpp
                '''.split()
                testobj.includes     = obj.includes + ['../pbd/']
diff --git a/wscript b/wscript
index 80596f3f5d059a99212ede4e93caa9f731822a1e..f69cb639315a28d50bcd49fb16f5b66e75f5f4d7 100644 (file)
--- a/wscript
+++ b/wscript
@@ -343,6 +343,8 @@ def set_options(opt):
        opt.add_option('--no-nls', action='store_false', dest='nls')
        opt.add_option('--stl-debug', action='store_true', default=False, dest='stl_debug',
                        help='Build with debugging for the STL')
+       opt.add_option('--test', action='store_true', default=False, dest='build_tests', 
+                       help="Build unit tests")
        opt.add_option('--tranzport', action='store_true', default=False, dest='tranzport',
                        help='Compile with support for Frontier Designs Tranzport (if libusb is available)')
        opt.add_option('--universal', action='store_true', default=False, dest='universal',
@@ -464,6 +466,7 @@ def configure(conf):
                      okmsg = 'ok',
                      errmsg = 'too old\nPlease install boost version 1.39 or higher.')
 
+       autowaf.check_pkg(conf, 'cppunit', uselib_store='CPPUNIT', atleast_version='1.12.0', mandatory=False)
        autowaf.check_pkg(conf, 'glib-2.0', uselib_store='GLIB', atleast_version='2.2')
        autowaf.check_pkg(conf, 'gthread-2.0', uselib_store='GTHREAD', atleast_version='2.2')
        autowaf.check_pkg(conf, 'glibmm-2.4', uselib_store='GLIBMM', atleast_version='2.14.0')
@@ -479,7 +482,7 @@ def configure(conf):
 
        conf.env.append_value('CCFLAGS', '-DWAF_BUILD')
        conf.env.append_value('CXXFLAGS', '-DWAF_BUILD')
-
+       
        autowaf.print_summary(conf)
        opts = Options.options
        autowaf.display_header('Ardour Configuration')
@@ -510,6 +513,9 @@ def configure(conf):
        if opts.nls:
                conf.define ('ENABLE_NLS', 1)
        autowaf.display_msg(conf, 'Tranzport', opts.tranzport)
+       if opts.build_tests:
+               conf.env['BUILD_TESTS'] = opts.build_tests
+               autowaf.display_msg(conf, 'Unit Tests', bool(conf.env['BUILD_TESTS']) and bool (conf.env['HAVE_CPPUNIT']))
        if opts.tranzport:
                conf.define('TRANZPORT', 1)
        autowaf.display_msg(conf, 'Universal Binary', opts.universal)