diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-07-06 21:21:35 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-07-06 21:21:35 +0100 |
| commit | c23fb4a459e445df91f5b8ea8ceaed48bb5c277f (patch) | |
| tree | df9be6c46b2fe9c77c4af828ecdf3c87cc33c92e | |
| parent | 6d661042104f54b7ce6b18b73a3371fff9a33792 (diff) | |
Add very simple test of dcp::SoundFrame.
| -rw-r--r-- | test/sound_frame_test.cc | 55 | ||||
| -rw-r--r-- | test/test.h | 2 | ||||
| -rw-r--r-- | test/wscript | 1 |
3 files changed, 58 insertions, 0 deletions
diff --git a/test/sound_frame_test.cc b/test/sound_frame_test.cc new file mode 100644 index 00000000..6ded1977 --- /dev/null +++ b/test/sound_frame_test.cc @@ -0,0 +1,55 @@ +/* + Copyright (C) 2015 Carl Hetherington <cth@carlh.net> + + This program 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. + + This program 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 more 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., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include <boost/test/unit_test.hpp> +#include "test.h" +#include "sound_frame.h" +#include <sndfile.h> + +BOOST_AUTO_TEST_CASE (sound_frame_test) +{ + int const frame_length = 2000; + int const channels = 6; + + dcp::SoundFrame frame ( + private_test / "TONEPLATES-SMPTE-PLAINTEXT_TST_F_XX-XX_ITL-TD_51-XX_2K_WOE_20111001_WOE_OV/pcm_95734608-5d47-4d3f-bf5f-9e9186b66afa_.mxf", + 42, + 0 + ); + + boost::filesystem::path ref_file = private_test / "frame.wav"; + SF_INFO info; + info.format = 0; + SNDFILE* sndfile = sf_open (ref_file.string().c_str(), SFM_READ, &info); + + int ref_data[frame_length * channels]; + int const read = sf_readf_int (sndfile, ref_data, frame_length); + BOOST_REQUIRE_EQUAL (read, frame_length); + + uint8_t const * p = frame.data (); + for (int i = 0; i < (frame_length * channels); ++i) { + int x = ref_data[i] >> 8; + if (x < 0) { + x = (1 << 24) + x; + } + int const y = p[0] | (p[1] << 8) | (p[2] << 16); + BOOST_REQUIRE_EQUAL (x, y); + p += 3; + } +} diff --git a/test/test.h b/test/test.h index 62a4c942..d9860687 100644 --- a/test/test.h +++ b/test/test.h @@ -17,6 +17,8 @@ */ +#include <boost/filesystem.hpp> + namespace xmlpp { class Element; } diff --git a/test/wscript b/test/wscript index 51c2d8fd..0fae810c 100644 --- a/test/wscript +++ b/test/wscript @@ -48,6 +48,7 @@ def build(bld): rgb_xyz_test.cc round_trip_test.cc smpte_load_font_test.cc + sound_frame_test.cc test.cc text_test.cc util_test.cc |
