diff options
author | John Glover <j@johnglover.net> | 2013-02-16 15:22:46 +0000 |
---|---|---|
committer | John Glover <j@johnglover.net> | 2013-02-16 15:22:46 +0000 |
commit | d91fc3a5b7b9d7a4ca85882b029fefe2c8daa156 (patch) | |
tree | 0a615b89f3268d11762477ed991cff586738d458 /tests | |
parent | 2b9cec80434f0bef506633deff97d289b483c97d (diff) | |
download | simpl-d91fc3a5b7b9d7a4ca85882b029fefe2c8daa156.tar.gz simpl-d91fc3a5b7b9d7a4ca85882b029fefe2c8daa156.tar.bz2 simpl-d91fc3a5b7b9d7a4ca85882b029fefe2c8daa156.zip |
[mq] Add C++ implementation of TWM
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_peak_detection.cpp | 22 | ||||
-rw-r--r-- | tests/test_peak_detection.h | 13 | ||||
-rw-r--r-- | tests/tests.cpp | 1 |
3 files changed, 36 insertions, 0 deletions
diff --git a/tests/test_peak_detection.cpp b/tests/test_peak_detection.cpp index 3cb9c1a..e0eba9e 100644 --- a/tests/test_peak_detection.cpp +++ b/tests/test_peak_detection.cpp @@ -72,6 +72,28 @@ void TestMQPeakDetection::test_find_peaks_change_hop_frame_size() { // --------------------------------------------------------------------------- +// TestTWM +// --------------------------------------------------------------------------- +void TestTWM::test_basic() { + int num_peaks = 100; + int base_freq = 110; + Peaks peaks; + + for(int i = 0; i < num_peaks; i++) { + Peak* p = new Peak(); + p->amplitude = 0.4; + p->frequency = base_freq * (i + 1); + peaks.push_back(p); + } + + CPPUNIT_ASSERT_DOUBLES_EQUAL(base_freq, twm(peaks), PRECISION); + + for(int i = 0; i < num_peaks; i++) { + delete peaks[i]; + } +} + +// --------------------------------------------------------------------------- // TestLorisPeakDetection // --------------------------------------------------------------------------- void TestLorisPeakDetection::setUp() { diff --git a/tests/test_peak_detection.h b/tests/test_peak_detection.h index 5b36f19..2b574cb 100644 --- a/tests/test_peak_detection.h +++ b/tests/test_peak_detection.h @@ -37,6 +37,19 @@ protected: // --------------------------------------------------------------------------- +// TestTWM +// --------------------------------------------------------------------------- +class TestTWM : public CPPUNIT_NS::TestCase { + CPPUNIT_TEST_SUITE(TestTWM); + CPPUNIT_TEST(test_basic); + CPPUNIT_TEST_SUITE_END(); + +protected: + void test_basic(); +}; + + +// --------------------------------------------------------------------------- // TestLorisPeakDetection // --------------------------------------------------------------------------- class TestLorisPeakDetection : public CPPUNIT_NS::TestCase { diff --git a/tests/tests.cpp b/tests/tests.cpp index 133c873..d185923 100644 --- a/tests/tests.cpp +++ b/tests/tests.cpp @@ -10,6 +10,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(simpl::TestPeak); CPPUNIT_TEST_SUITE_REGISTRATION(simpl::TestFrame); CPPUNIT_TEST_SUITE_REGISTRATION(simpl::TestMQPeakDetection); +CPPUNIT_TEST_SUITE_REGISTRATION(simpl::TestTWM); CPPUNIT_TEST_SUITE_REGISTRATION(simpl::TestLorisPeakDetection); CPPUNIT_TEST_SUITE_REGISTRATION(simpl::TestMQPartialTracking); CPPUNIT_TEST_SUITE_REGISTRATION(simpl::TestSMSPartialTracking); |