fix merge conflicts with master
[ardour.git] / libs / audiographer / tests / sndfile / tmp_file_test.cc
1 #include "tests/utils.h"
2 #include "audiographer/sndfile/tmp_file.h"
3
4 using namespace AudioGrapher;
5
6 class TmpFileTest : public CppUnit::TestFixture
7 {
8   CPPUNIT_TEST_SUITE (TmpFileTest);
9   CPPUNIT_TEST (testProcess);
10   CPPUNIT_TEST_SUITE_END ();
11
12   public:
13         void setUp()
14         {
15                 frames = 128;
16                 random_data = TestUtils::init_random_data(frames);
17         }
18
19         void tearDown()
20         {
21                 delete [] random_data;
22         }
23
24         void testProcess()
25         {
26                 uint32_t channels = 2;
27                 file.reset (new TmpFile<float>(SF_FORMAT_WAV | SF_FORMAT_FLOAT, channels, 44100));
28                 AllocatingProcessContext<float> c (random_data, frames, channels);
29                 c.set_flag (ProcessContext<float>::EndOfInput);
30                 file->process (c);
31                 
32                 TypeUtils<float>::zero_fill (c.data (), c.frames());
33                 
34                 file->seek (0, SEEK_SET);
35                 file->read (c);
36                 CPPUNIT_ASSERT (TestUtils::array_equals (random_data, c.data(), c.frames()));
37         }
38
39   private:
40         boost::shared_ptr<TmpFile<float> > file;
41
42         float * random_data;
43         framecnt_t frames;
44 };
45
46 CPPUNIT_TEST_SUITE_REGISTRATION (TmpFileTest);
47