2 Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <boost/test/unit_test.hpp>
22 #include "sound_frame.h"
23 #include "exceptions.h"
26 BOOST_AUTO_TEST_CASE (sound_frame_test)
28 int const frame_length = 2000;
29 int const channels = 6;
31 dcp::SoundFrame frame (
32 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",
37 BOOST_REQUIRE_EQUAL (frame.size(), channels * frame_length * 3);
39 boost::filesystem::path ref_file = private_test / "data" / "frame.wav";
42 SNDFILE* sndfile = sf_open (ref_file.string().c_str(), SFM_READ, &info);
43 BOOST_REQUIRE (sndfile);
45 int ref_data[frame_length * channels];
46 int const read = sf_readf_int (sndfile, ref_data, frame_length);
47 BOOST_REQUIRE_EQUAL (read, frame_length);
49 uint8_t const * p = frame.data ();
50 for (int i = 0; i < (frame_length * channels); ++i) {
51 int x = ref_data[i] >> 8;
55 int const y = p[0] | (p[1] << 8) | (p[2] << 16);
56 BOOST_REQUIRE_EQUAL (x, y);
61 BOOST_AUTO_TEST_CASE (sound_frame_test2)
63 BOOST_CHECK_THROW (dcp::SoundFrame ("frobozz", 42, 0), dcp::FileError);
64 BOOST_CHECK_THROW (dcp::SoundFrame (
66 "TONEPLATES-SMPTE-PLAINTEXT_TST_F_XX-XX_ITL-TD_51-XX_2K_WOE_20111001_WOE_OV/pcm_95734608-5d47-4d3f-bf5f-9e9186b66afa_.mxf",