| 1 | /*************************************************************************** |
| 2 | copyright : (C) 2012 by Tsuda Kageyu |
| 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 "infotag.h" |
| 30 | #include <cppunit/extensions/HelperMacros.h> |
| 31 | #include "utils.h" |
| 32 | |
| 33 | using namespace std; |
| 34 | using namespace TagLib; |
| 35 | |
| 36 | class TestInfoTag : public CppUnit::TestFixture |
| 37 | { |
| 38 | CPPUNIT_TEST_SUITE(TestInfoTag); |
| 39 | CPPUNIT_TEST(testTitle); |
| 40 | CPPUNIT_TEST(testNumericFields); |
| 41 | CPPUNIT_TEST_SUITE_END(); |
| 42 | |
| 43 | public: |
| 44 | void testTitle() |
| 45 | { |
| 46 | RIFF::Info::Tag tag; |
| 47 | |
| 48 | CPPUNIT_ASSERT_EQUAL(String(""), tag.title()); |
| 49 | tag.setTitle("Test title 1"); |
| 50 | tag.setFieldText("TEST", "Dummy Text"); |
| 51 | |
| 52 | CPPUNIT_ASSERT_EQUAL(String("Test title 1"), tag.title()); |
| 53 | |
| 54 | RIFF::Info::FieldListMap map = tag.fieldListMap(); |
| 55 | CPPUNIT_ASSERT_EQUAL(String("Test title 1"), map["INAM"]); |
| 56 | CPPUNIT_ASSERT_EQUAL(String("Dummy Text"), map["TEST"]); |
| 57 | } |
| 58 | |
| 59 | void testNumericFields() |
| 60 | { |
| 61 | RIFF::Info::Tag tag; |
| 62 | |
| 63 | CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(0), tag.track()); |
| 64 | tag.setTrack(1234); |
| 65 | CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(1234), tag.track()); |
| 66 | CPPUNIT_ASSERT_EQUAL(String("1234"), tag.fieldText("IPRT")); |
| 67 | |
| 68 | CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(0), tag.year()); |
| 69 | tag.setYear(1234); |
| 70 | CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(1234), tag.year()); |
| 71 | CPPUNIT_ASSERT_EQUAL(String("1234"), tag.fieldText("ICRD")); |
| 72 | } |
| 73 | }; |
| 74 | |
| 75 | CPPUNIT_TEST_SUITE_REGISTRATION(TestInfoTag); |