diff options
author | Sakari Bergen <sakari.bergen@beatwaves.net> | 2010-03-15 19:11:48 +0000 |
---|---|---|
committer | Sakari Bergen <sakari.bergen@beatwaves.net> | 2010-03-15 19:11:48 +0000 |
commit | 830911f6f9451d83a58043b3f9084d3caa164b7b (patch) | |
tree | f4ca4e3d86b51d66e7cecfb6b370cc4eb553e2d7 /libs/audiographer/tests | |
parent | 44f4b84551d36ef4103d09452768f5ba53e0002c (diff) |
Fix export, which has been broken since the boost::signals2 changes. Also update Audiographer, bacause of its incomplete sndfile handling. Audiographer is equal to revision 74
git-svn-id: svn://localhost/ardour2/branches/3.0@6760 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/audiographer/tests')
-rw-r--r-- | libs/audiographer/tests/general/chunker_test.cc (renamed from libs/audiographer/tests/chunker_test.cc) | 40 | ||||
-rw-r--r-- | libs/audiographer/tests/general/deinterleaver_test.cc (renamed from libs/audiographer/tests/deinterleaver_test.cc) | 24 | ||||
-rw-r--r-- | libs/audiographer/tests/general/interleaver_deinterleaver_test.cc (renamed from libs/audiographer/tests/interleaver_deinterleaver_test.cc) | 19 | ||||
-rw-r--r-- | libs/audiographer/tests/general/interleaver_test.cc (renamed from libs/audiographer/tests/interleaver_test.cc) | 36 | ||||
-rw-r--r-- | libs/audiographer/tests/general/normalizer_test.cc (renamed from libs/audiographer/tests/normalizer_test.cc) | 6 | ||||
-rw-r--r-- | libs/audiographer/tests/general/peak_reader_test.cc (renamed from libs/audiographer/tests/peak_reader_test.cc) | 5 | ||||
-rw-r--r-- | libs/audiographer/tests/general/sample_format_converter_test.cc (renamed from libs/audiographer/tests/sample_format_converter_test.cc) | 11 | ||||
-rw-r--r-- | libs/audiographer/tests/general/silence_trimmer_test.cc (renamed from libs/audiographer/tests/silence_trimmer_test.cc) | 36 | ||||
-rw-r--r-- | libs/audiographer/tests/general/sr_converter_test.cc (renamed from libs/audiographer/tests/sr_converter_test.cc) | 5 | ||||
-rw-r--r-- | libs/audiographer/tests/general/threader_test.cc (renamed from libs/audiographer/tests/threader_test.cc) | 5 | ||||
-rw-r--r-- | libs/audiographer/tests/sndfile/tmp_file_test.cc | 47 | ||||
-rw-r--r-- | libs/audiographer/tests/sndfile_writer_test.cc | 42 | ||||
-rw-r--r-- | libs/audiographer/tests/type_utils_test.cc | 112 | ||||
-rw-r--r-- | libs/audiographer/tests/utils/identity_vertex_test.cc (renamed from libs/audiographer/tests/identity_vertex_test.cc) | 5 |
14 files changed, 262 insertions, 131 deletions
diff --git a/libs/audiographer/tests/chunker_test.cc b/libs/audiographer/tests/general/chunker_test.cc index ab0c04d7f9..c667360601 100644 --- a/libs/audiographer/tests/chunker_test.cc +++ b/libs/audiographer/tests/general/chunker_test.cc @@ -1,5 +1,6 @@ -#include "utils.h" -#include "audiographer/chunker.h" +#include "tests/utils.h" + +#include "audiographer/general/chunker.h" #include <cassert> @@ -7,9 +8,12 @@ using namespace AudioGrapher; class ChunkerTest : public CppUnit::TestFixture { + // TODO: Test EndOfInput handling + CPPUNIT_TEST_SUITE (ChunkerTest); CPPUNIT_TEST (testSynchronousProcess); CPPUNIT_TEST (testAsynchronousProcess); + CPPUNIT_TEST (testChoppingProcess); CPPUNIT_TEST_SUITE_END (); public: @@ -99,6 +103,38 @@ class ChunkerTest : public CppUnit::TestFixture CPPUNIT_ASSERT (TestUtils::array_equals (random_data, &sink->get_array()[frames / 2], frames)); CPPUNIT_ASSERT (TestUtils::array_equals (random_data, &sink->get_array()[ 3 * frames / 2], frames / 2)); } + + void testChoppingProcess() + { + sink.reset (new AppendingVectorSink<float>()); + + assert (frames % 2 == 0); + chunker.reset (new Chunker<float>(frames / 4)); + + chunker->add_output (sink); + nframes_t frames_output = 0; + + ProcessContext<float> const half_context (random_data, frames / 2, 1); + ProcessContext<float> const context (random_data, frames, 1); + + // 0.5 + chunker->process (half_context); + frames_output = sink->get_data().size(); + CPPUNIT_ASSERT_EQUAL ((nframes_t) frames / 2, frames_output); + + // 1.5 + chunker->process (context); + frames_output = sink->get_data().size(); + CPPUNIT_ASSERT_EQUAL ((nframes_t) frames / 2 * 3, frames_output); + + // 2.5 + chunker->process (context); + frames_output = sink->get_data().size(); + CPPUNIT_ASSERT_EQUAL (frames / 2 * 5, frames_output); + CPPUNIT_ASSERT (TestUtils::array_equals (random_data, sink->get_array(), frames / 2)); + CPPUNIT_ASSERT (TestUtils::array_equals (random_data, &sink->get_array()[frames / 2], frames)); + CPPUNIT_ASSERT (TestUtils::array_equals (random_data, &sink->get_array()[ 3 * frames / 2], frames / 2)); + } private: boost::shared_ptr<Chunker<float> > chunker; diff --git a/libs/audiographer/tests/deinterleaver_test.cc b/libs/audiographer/tests/general/deinterleaver_test.cc index b0adbc0444..3d644a3cf1 100644 --- a/libs/audiographer/tests/deinterleaver_test.cc +++ b/libs/audiographer/tests/general/deinterleaver_test.cc @@ -1,5 +1,6 @@ -#include "utils.h" -#include "audiographer/deinterleaver.h" +#include "tests/utils.h" + +#include "audiographer/general/deinterleaver.h" using namespace AudioGrapher; @@ -48,19 +49,16 @@ class DeInterleaverTest : public CppUnit::TestFixture { deinterleaver->init (channels, frames_per_channel); - ProcessContext<float> c (random_data, 0, channels); + ProcessContext<float> c (random_data, 2 * total_frames, channels); // Too many, frames % channels == 0 - c.frames() = total_frames + channels; - CPPUNIT_ASSERT_THROW (deinterleaver->process (c), Exception); + CPPUNIT_ASSERT_THROW (deinterleaver->process (c.beginning (total_frames + channels)), Exception); // Too many, frames % channels != 0 - c.frames() = total_frames + 1; - CPPUNIT_ASSERT_THROW (deinterleaver->process (c), Exception); + CPPUNIT_ASSERT_THROW (deinterleaver->process (c.beginning (total_frames + 1)), Exception); // Too few, frames % channels != 0 - c.frames() = total_frames - 1; - CPPUNIT_ASSERT_THROW (deinterleaver->process (c), Exception); + CPPUNIT_ASSERT_THROW (deinterleaver->process (c.beginning (total_frames - 1)), Exception); } void assert_outputs (nframes_t expected_frames) @@ -92,8 +90,7 @@ class DeInterleaverTest : public CppUnit::TestFixture // Now with less frames nframes_t const less_frames = frames_per_channel / 4; - c.frames() = less_frames * channels; - deinterleaver->process (c); + deinterleaver->process (c.beginning (less_frames * channels)); assert_outputs (less_frames); } @@ -106,11 +103,10 @@ class DeInterleaverTest : public CppUnit::TestFixture deinterleaver->output (2)->add_output (sink_c); // Input zero frames - ProcessContext<float> c (random_data, 0, channels); - deinterleaver->process (c); + ProcessContext<float> c (random_data, total_frames, channels); + deinterleaver->process (c.beginning (0)); // ...and now test regular input - c.frames() = total_frames; deinterleaver->process (c); assert_outputs (frames_per_channel); } diff --git a/libs/audiographer/tests/interleaver_deinterleaver_test.cc b/libs/audiographer/tests/general/interleaver_deinterleaver_test.cc index 5655253e62..908abafdf2 100644 --- a/libs/audiographer/tests/interleaver_deinterleaver_test.cc +++ b/libs/audiographer/tests/general/interleaver_deinterleaver_test.cc @@ -1,6 +1,7 @@ -#include "utils.h" -#include "audiographer/interleaver.h" -#include "audiographer/deinterleaver.h" +#include "tests/utils.h" + +#include "audiographer/general/interleaver.h" +#include "audiographer/general/deinterleaver.h" using namespace AudioGrapher; @@ -55,8 +56,7 @@ class InterleaverDeInterleaverTest : public CppUnit::TestFixture // And a second round... nframes_t less_frames = (frames_per_channel / 10) * channels; - c.frames() = less_frames; - deinterleaver->process (c); + deinterleaver->process (c.beginning (less_frames)); CPPUNIT_ASSERT (TestUtils::array_equals (random_data_a, sink_a->get_array(), less_frames)); } @@ -86,12 +86,9 @@ class InterleaverDeInterleaverTest : public CppUnit::TestFixture // And a second round... nframes_t less_frames = frames_per_channel / 5; - c_a.frames() = less_frames; - c_b.frames() = less_frames; - c_c.frames() = less_frames; - interleaver->input (0)->process (c_a); - interleaver->input (1)->process (c_b); - interleaver->input (2)->process (c_c); + interleaver->input (0)->process (c_a.beginning (less_frames)); + interleaver->input (1)->process (c_b.beginning (less_frames)); + interleaver->input (2)->process (c_c.beginning (less_frames)); CPPUNIT_ASSERT (TestUtils::array_equals (random_data_a, sink_a->get_array(), less_frames)); CPPUNIT_ASSERT (TestUtils::array_equals (random_data_b, sink_b->get_array(), less_frames)); diff --git a/libs/audiographer/tests/interleaver_test.cc b/libs/audiographer/tests/general/interleaver_test.cc index abe385699d..1512d054fc 100644 --- a/libs/audiographer/tests/interleaver_test.cc +++ b/libs/audiographer/tests/general/interleaver_test.cc @@ -1,5 +1,6 @@ -#include "utils.h" -#include "audiographer/interleaver.h" +#include "tests/utils.h" + +#include "audiographer/general/interleaver.h" using namespace AudioGrapher; @@ -50,16 +51,13 @@ class InterleaverTest : public CppUnit::TestFixture ProcessContext<float> c (random_data, frames + 1, 1); CPPUNIT_ASSERT_THROW (interleaver->input (0)->process (c), Exception); - c.frames() = frames; - interleaver->input (0)->process (c); - interleaver->input (1)->process (c); - c.frames() = frames -1; - CPPUNIT_ASSERT_THROW (interleaver->input (2)->process (c), Exception); + interleaver->input (0)->process (c.beginning (frames)); + interleaver->input (1)->process (c.beginning (frames)); + CPPUNIT_ASSERT_THROW (interleaver->input (2)->process (c.beginning (frames - 1)), Exception); - interleaver->input (0)->process (c); - interleaver->input (1)->process (c); - c.frames() = frames; - CPPUNIT_ASSERT_THROW (interleaver->input (2)->process (c), Exception); + interleaver->input (0)->process (c.beginning (frames - 1)); + interleaver->input (1)->process (c.beginning (frames - 1)); + CPPUNIT_ASSERT_THROW (interleaver->input (2)->process (c.beginning (frames)), Exception); } void testOutputSize() @@ -76,10 +74,9 @@ class InterleaverTest : public CppUnit::TestFixture CPPUNIT_ASSERT_EQUAL (expected_frames, generated_frames); nframes_t less_frames = frames / 2; - c.frames() = less_frames; - interleaver->input (0)->process (c); - interleaver->input (1)->process (c); - interleaver->input (2)->process (c); + interleaver->input (0)->process (c.beginning (less_frames)); + interleaver->input (1)->process (c.beginning (less_frames)); + interleaver->input (2)->process (c.beginning (less_frames)); expected_frames = less_frames * channels; generated_frames = sink->get_data().size(); @@ -91,15 +88,14 @@ class InterleaverTest : public CppUnit::TestFixture interleaver->add_output (sink); // input zero frames to all inputs - ProcessContext<float> c (random_data, 0, 1); - interleaver->input (0)->process (c); - interleaver->input (1)->process (c); - interleaver->input (2)->process (c); + ProcessContext<float> c (random_data, frames, 1); + interleaver->input (0)->process (c.beginning (0)); + interleaver->input (1)->process (c.beginning (0)); + interleaver->input (2)->process (c.beginning (0)); // NOTE zero input is allowed to be a NOP // ...now test regular input - c.frames() = frames; interleaver->input (0)->process (c); interleaver->input (1)->process (c); interleaver->input (2)->process (c); diff --git a/libs/audiographer/tests/normalizer_test.cc b/libs/audiographer/tests/general/normalizer_test.cc index 711e0018ca..b08fd73a0e 100644 --- a/libs/audiographer/tests/normalizer_test.cc +++ b/libs/audiographer/tests/general/normalizer_test.cc @@ -1,7 +1,7 @@ -#include "utils.h" +#include "tests/utils.h" -#include "audiographer/normalizer.h" -#include "audiographer/peak_reader.h" +#include "audiographer/general/normalizer.h" +#include "audiographer/general/peak_reader.h" using namespace AudioGrapher; diff --git a/libs/audiographer/tests/peak_reader_test.cc b/libs/audiographer/tests/general/peak_reader_test.cc index dce03b6caf..53b7a15174 100644 --- a/libs/audiographer/tests/peak_reader_test.cc +++ b/libs/audiographer/tests/general/peak_reader_test.cc @@ -1,5 +1,6 @@ -#include "utils.h" -#include "audiographer/peak_reader.h" +#include "tests/utils.h" + +#include "audiographer/general/peak_reader.h" using namespace AudioGrapher; diff --git a/libs/audiographer/tests/sample_format_converter_test.cc b/libs/audiographer/tests/general/sample_format_converter_test.cc index f723f7af53..1456528ebf 100644 --- a/libs/audiographer/tests/sample_format_converter_test.cc +++ b/libs/audiographer/tests/general/sample_format_converter_test.cc @@ -1,5 +1,6 @@ -#include "utils.h" -#include "audiographer/sample_format_converter.h" +#include "tests/utils.h" + +#include "audiographer/general/sample_format_converter.h" using namespace AudioGrapher; @@ -192,10 +193,10 @@ class SampleFormatConverterTest : public CppUnit::TestFixture ProcessContext<float> pc(random_data, 4, 1); CPPUNIT_ASSERT_THROW (converter->process (pc), Exception); - pc.frames() = frames - (frames % 3); - converter->process (pc); + nframes_t new_frame_count = frames - (frames % 3); + converter->process (ProcessContext<float> (pc.data(), new_frame_count, 3)); frames_output = sink->get_data().size(); - CPPUNIT_ASSERT_EQUAL (pc.frames(), frames_output); + CPPUNIT_ASSERT_EQUAL (new_frame_count, frames_output); CPPUNIT_ASSERT (TestUtils::array_filled(sink->get_array(), pc.frames())); } diff --git a/libs/audiographer/tests/silence_trimmer_test.cc b/libs/audiographer/tests/general/silence_trimmer_test.cc index 16234bec37..add24d026a 100644 --- a/libs/audiographer/tests/silence_trimmer_test.cc +++ b/libs/audiographer/tests/general/silence_trimmer_test.cc @@ -1,6 +1,6 @@ -#include "utils.h" +#include "tests/utils.h" -#include "audiographer/silence_trimmer.h" +#include "audiographer/general/silence_trimmer.h" using namespace AudioGrapher; @@ -29,7 +29,7 @@ class SilenceTrimmerTest : public CppUnit::TestFixture half_random_data = TestUtils::init_random_data(frames); memset(half_random_data, 0, (frames / 2) * sizeof(float)); - trimmer.reset (new SilenceTrimmer<float>()); + trimmer.reset (new SilenceTrimmer<float> (frames / 2)); sink.reset (new AppendingVectorSink<float>()); trimmer->set_trim_beginning (true); @@ -41,14 +41,11 @@ class SilenceTrimmerTest : public CppUnit::TestFixture delete [] random_data; delete [] zero_data; delete [] half_random_data; - - AudioGrapher::Utils::free_resources(); } void testFullBuffers() { trimmer->add_output (sink); - AudioGrapher::Utils::init_zeros<float>(frames / 2); { ProcessContext<float> c (zero_data, frames, 1); @@ -93,7 +90,9 @@ class SilenceTrimmerTest : public CppUnit::TestFixture void testPartialBuffers() { trimmer->add_output (sink); - AudioGrapher::Utils::init_zeros<float>(frames / 4); + trimmer->reset (frames / 4); + trimmer->set_trim_beginning (true); + trimmer->set_trim_end (true); { ProcessContext<float> c (half_random_data, frames, 1); @@ -121,31 +120,14 @@ class SilenceTrimmerTest : public CppUnit::TestFixture void testExceptions() { - // TODO more tests here - - trimmer->add_output (sink); - - { - ProcessContext<float> c (random_data, frames, 1); - trimmer->process (c); - } - { - ProcessContext<float> c (zero_data, frames, 1); - trimmer->process (c); - } - - { - // Zeros not inited, so this should throw - ProcessContext<float> c (random_data, frames, 1); - CPPUNIT_ASSERT_THROW (trimmer->process (c), Exception); + CPPUNIT_ASSERT_THROW (trimmer->reset (0), Exception); } } void testAddSilenceBeginning() { trimmer->add_output (sink); - AudioGrapher::Utils::init_zeros<float>(frames / 2); nframes_t silence = frames / 2; trimmer->add_silence_to_beginning (silence); @@ -162,7 +144,6 @@ class SilenceTrimmerTest : public CppUnit::TestFixture void testAddSilenceEnd() { trimmer->add_output (sink); - AudioGrapher::Utils::init_zeros<float>(frames / 2); nframes_t silence = frames / 3; trimmer->add_silence_to_end (silence); @@ -178,6 +159,9 @@ class SilenceTrimmerTest : public CppUnit::TestFixture trimmer->process (c); } + nframes_t frames_processed = sink->get_data().size(); + nframes_t total_frames = 2 * frames + silence; + CPPUNIT_ASSERT_EQUAL (total_frames, frames_processed); CPPUNIT_ASSERT (TestUtils::array_equals (sink->get_array(), random_data, frames)); CPPUNIT_ASSERT (TestUtils::array_equals (&sink->get_array()[frames], random_data, frames)); CPPUNIT_ASSERT (TestUtils::array_equals (&sink->get_array()[frames * 2], zero_data, silence)); diff --git a/libs/audiographer/tests/sr_converter_test.cc b/libs/audiographer/tests/general/sr_converter_test.cc index e7b49a1b71..68e21d3558 100644 --- a/libs/audiographer/tests/sr_converter_test.cc +++ b/libs/audiographer/tests/general/sr_converter_test.cc @@ -1,5 +1,6 @@ -#include "utils.h" -#include "audiographer/sr_converter.h" +#include "tests/utils.h" + +#include "audiographer/general/sr_converter.h" using namespace AudioGrapher; diff --git a/libs/audiographer/tests/threader_test.cc b/libs/audiographer/tests/general/threader_test.cc index ac5588d79c..c599d87953 100644 --- a/libs/audiographer/tests/threader_test.cc +++ b/libs/audiographer/tests/general/threader_test.cc @@ -1,5 +1,6 @@ -#include "utils.h" -#include "audiographer/threader.h" +#include "tests/utils.h" + +#include "audiographer/general/threader.h" using namespace AudioGrapher; diff --git a/libs/audiographer/tests/sndfile/tmp_file_test.cc b/libs/audiographer/tests/sndfile/tmp_file_test.cc new file mode 100644 index 0000000000..d2d1b3581e --- /dev/null +++ b/libs/audiographer/tests/sndfile/tmp_file_test.cc @@ -0,0 +1,47 @@ +#include "tests/utils.h" +#include "audiographer/sndfile/tmp_file.h" + +using namespace AudioGrapher; + +class TmpFileTest : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE (TmpFileTest); + CPPUNIT_TEST (testProcess); + CPPUNIT_TEST_SUITE_END (); + + public: + void setUp() + { + frames = 128; + random_data = TestUtils::init_random_data(frames); + } + + void tearDown() + { + delete [] random_data; + } + + void testProcess() + { + uint channels = 2; + file.reset (new TmpFile<float>(SF_FORMAT_WAV | SF_FORMAT_FLOAT, channels, 44100)); + AllocatingProcessContext<float> c (random_data, frames, channels); + c.set_flag (ProcessContext<float>::EndOfInput); + file->process (c); + + TypeUtils<float>::zero_fill (c.data (), c.frames()); + + file->seek (0, SEEK_SET); + file->read (c); + CPPUNIT_ASSERT (TestUtils::array_equals (random_data, c.data(), c.frames())); + } + + private: + boost::shared_ptr<TmpFile<float> > file; + + float * random_data; + nframes_t frames; +}; + +CPPUNIT_TEST_SUITE_REGISTRATION (TmpFileTest); + diff --git a/libs/audiographer/tests/sndfile_writer_test.cc b/libs/audiographer/tests/sndfile_writer_test.cc deleted file mode 100644 index 359d456f15..0000000000 --- a/libs/audiographer/tests/sndfile_writer_test.cc +++ /dev/null @@ -1,42 +0,0 @@ -#include "utils.h" -#include "audiographer/sndfile_writer.h" - -using namespace AudioGrapher; - -class SndfileWriterTest : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE (SndfileWriterTest); - CPPUNIT_TEST (testProcess); - CPPUNIT_TEST_SUITE_END (); - - public: - void setUp() - { - frames = 128; - random_data = TestUtils::init_random_data(frames); - } - - void tearDown() - { - delete [] random_data; - } - - void testProcess() - { - uint channels = 2; - std::string filename ("test.wav"); - writer.reset (new SndfileWriter<float>(channels, 44100, SF_FORMAT_WAV | SF_FORMAT_FLOAT, filename)); - ProcessContext<float> c (random_data, frames, channels); - c.set_flag (ProcessContext<float>::EndOfInput); - writer->process (c); - } - - private: - boost::shared_ptr<SndfileWriter<float> > writer; - - float * random_data; - nframes_t frames; -}; - -CPPUNIT_TEST_SUITE_REGISTRATION (SndfileWriterTest); - diff --git a/libs/audiographer/tests/type_utils_test.cc b/libs/audiographer/tests/type_utils_test.cc new file mode 100644 index 0000000000..af9e923d1b --- /dev/null +++ b/libs/audiographer/tests/type_utils_test.cc @@ -0,0 +1,112 @@ +#include "tests/utils.h" + +#include "audiographer/type_utils.h" + +using namespace AudioGrapher; + +class TypeUtilsTest : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE (TypeUtilsTest); + CPPUNIT_TEST (testZeroFillPod); + CPPUNIT_TEST (testZeroFillNonPod); + CPPUNIT_TEST (testCopy); + CPPUNIT_TEST (testMoveBackward); + CPPUNIT_TEST (testMoveForward); + CPPUNIT_TEST_SUITE_END (); + + public: + void setUp() + { + + } + + void tearDown() + { + + } + + void testZeroFillPod() + { + unsigned frames = 10; + float buf[frames]; + TypeUtils<float>::zero_fill (buf, frames); + float zero = 0.0; + for (unsigned i = 0; i < frames; ++i) { + CPPUNIT_ASSERT_EQUAL (zero, buf[i]); + } + } + + void testZeroFillNonPod() + { + unsigned frames = 10; + NonPodType buf[frames]; + TypeUtils<NonPodType>::zero_fill (buf, frames); + NonPodType zero; + for (unsigned i = 0; i < frames; ++i) { + CPPUNIT_ASSERT (zero == buf[i]); + } + } + + void testMoveBackward() + { + int seq[8] = { 0, 1, 2, 3, + 4, 5, 6, 7 }; + + TypeUtils<int>::move (&seq[4], &seq[2], 4); + + for (int i = 2; i < 2 + 4; ++i) { + CPPUNIT_ASSERT_EQUAL (i + 2, seq[i]); + } + } + + void testMoveForward() + { + int seq[8] = { 0, 1, 2, 3, + 4, 5, 6, 7 }; + + TypeUtils<int>::move (&seq[2], &seq[4], 4); + + for (int i = 4; i < 4 + 4; ++i) { + CPPUNIT_ASSERT_EQUAL (i - 2, seq[i]); + } + } + + void testCopy() + { + int const seq1[4] = { 1, 2, 3, 4 }; + int const seq2[4] = { 5, 6, 7, 8 }; + int seq3[8] = { 0, 0, 0, 0, + 0, 0, 0, 0 }; + + TypeUtils<int>::copy (seq1, seq3, 4); + for (int i = 0; i < 4; ++i) { + CPPUNIT_ASSERT_EQUAL (seq1[i], seq3[i]); + } + + for (int i = 4; i < 8; ++i) { + CPPUNIT_ASSERT_EQUAL (0, seq3[i]); + } + + TypeUtils<int>::copy (seq2, &seq3[4], 4); + for (int i = 0; i < 4; ++i) { + CPPUNIT_ASSERT_EQUAL (seq1[i], seq3[i]); + } + for (int i = 0; i < 4; ++i) { + CPPUNIT_ASSERT_EQUAL (seq2[i], seq3[4 + i]); + } + } + + private: + + struct NonPodType { + NonPodType() : data (42) {} + bool operator== (NonPodType const & other) const + { return data == other.data; } + int data; + }; + + +}; + +CPPUNIT_TEST_SUITE_REGISTRATION (TypeUtilsTest); + diff --git a/libs/audiographer/tests/identity_vertex_test.cc b/libs/audiographer/tests/utils/identity_vertex_test.cc index 5a3ae7c9f2..165af66a9d 100644 --- a/libs/audiographer/tests/identity_vertex_test.cc +++ b/libs/audiographer/tests/utils/identity_vertex_test.cc @@ -1,5 +1,6 @@ -#include "utils.h" -#include "audiographer/identity_vertex.h" +#include "tests/utils.h" + +#include "audiographer/utils/identity_vertex.h" using namespace AudioGrapher; |