| 1 | /*************************************************************************** |
| 2 | copyright : (C) 2012 by Lukas Lalinsky |
| 3 | email : [email protected] |
| 4 | ***************************************************************************/ |
| 5 | |
| 6 | /*************************************************************************** |
| 7 | * This library is free software; you can redistribute it and/or modify * |
| 8 | * it under the terms of the GNU Lesser General Public License version * |
| 9 | * 2.1 as published by the Free Software Foundation. * |
| 10 | * * |
| 11 | * This library is distributed in the hope that it will be useful, but * |
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * |
| 14 | * Lesser General Public License for more details. * |
| 15 | * * |
| 16 | * You should have received a copy of the GNU Lesser General Public * |
| 17 | * License along with this library; if not, write to the Free Software * |
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * |
| 19 | * 02110-1301 USA * |
| 20 | * * |
| 21 | * Alternatively, this file is available under the Mozilla Public * |
| 22 | * License Version 1.1. You may obtain a copy of the License at * |
| 23 | * http://www.mozilla.org/MPL/ * |
| 24 | ***************************************************************************/ |
| 25 | |
| 26 | #include <string> |
| 27 | #include <cstdio> |
| 28 | |
| 29 | #include "tstringlist.h" |
| 30 | #include "tag.h" |
| 31 | #include "flacunknownmetadatablock.h" |
| 32 | #include <cppunit/extensions/HelperMacros.h> |
| 33 | #include "utils.h" |
| 34 | |
| 35 | using namespace std; |
| 36 | using namespace TagLib; |
| 37 | |
| 38 | class TestFLACUnknownMetadataBlock : public CppUnit::TestFixture |
| 39 | { |
| 40 | CPPUNIT_TEST_SUITE(TestFLACUnknownMetadataBlock); |
| 41 | CPPUNIT_TEST(testAccessors); |
| 42 | CPPUNIT_TEST_SUITE_END(); |
| 43 | |
| 44 | public: |
| 45 | |
| 46 | void testAccessors() |
| 47 | { |
| 48 | ByteVector data("abc\x01", 4); |
| 49 | FLAC::UnknownMetadataBlock block(42, data); |
| 50 | CPPUNIT_ASSERT_EQUAL(42, block.code()); |
| 51 | CPPUNIT_ASSERT_EQUAL(data, block.data()); |
| 52 | CPPUNIT_ASSERT_EQUAL(data, block.render()); |
| 53 | ByteVector data2("xxx", 3); |
| 54 | block.setCode(13); |
| 55 | block.setData(data2); |
| 56 | CPPUNIT_ASSERT_EQUAL(13, block.code()); |
| 57 | CPPUNIT_ASSERT_EQUAL(data2, block.data()); |
| 58 | CPPUNIT_ASSERT_EQUAL(data2, block.render()); |
| 59 | } |
| 60 | |
| 61 | }; |
| 62 | |
| 63 | CPPUNIT_TEST_SUITE_REGISTRATION(TestFLACUnknownMetadataBlock); |