merge with master
[ardour.git] / libs / ardour / test / resampled_source_test.cc
1 // this is included first to avoid Searchpath definition on windows
2 #include "test_common.h"
3
4 #include "pbd/file_utils.h"
5 #include "ardour/resampled_source.h"
6 #include "ardour/sndfileimportable.h"
7 #include "resampled_source_test.h"
8
9
10 CPPUNIT_TEST_SUITE_REGISTRATION (ResampledSourceTest);
11
12 using namespace std;
13 using namespace ARDOUR;
14 using namespace PBD;
15
16 void
17 ResampledSourceTest::seekTest ()
18 {
19         std::string test_file_path;
20         const string test_filename = "test.wav";
21
22         CPPUNIT_ASSERT (find_file_in_search_path (test_search_path (), test_filename, test_file_path));
23
24         boost::shared_ptr<SndFileImportableSource> s (new SndFileImportableSource (test_file_path));
25         ResampledImportableSource r (s, 48000, SrcBest);
26
27         /* Make sure that seek (0) has the desired effect, ie that
28            given the same input you get the same output after seek (0)
29            as you got when the Source was newly created.
30         */
31
32         Sample A[64];
33         r.read (A, 64);
34
35         r.seek (0);
36
37         Sample B[64];
38         r.read (B, 64);
39
40         for (int i = 0; i < 64; ++i) {
41                 CPPUNIT_ASSERT (A[i] == B[i]);
42         }
43 }