Debian Codegraph @

tests/test_versionnumber.cpp

raw symbols SCIP
1 /***************************************************************************
2 copyright : (C) 2020 by Kevin Andre
3 email : [email protected]
4
5 copyright : (C) 2023 by Urs Fleisch
6 email : [email protected]
7 ***************************************************************************/
8
9 /***************************************************************************
10 * This library is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU Lesser General Public License version *
12 * 2.1 as published by the Free Software Foundation. *
13 * *
14 * This library is distributed in the hope that it will be useful, but *
15 * WITHOUT ANY WARRANTY; without even the implied warranty of *
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
17 * Lesser General Public License for more details. *
18 * *
19 * You should have received a copy of the GNU Lesser General Public *
20 * License along with this library; if not, write to the Free Software *
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
22 * 02110-1301 USA *
23 * *
24 * Alternatively, this file is available under the Mozilla Public *
25 * License Version 1.1. You may obtain a copy of the License at *
26 * http://www.mozilla.org/MPL/ *
27 ***************************************************************************/
28
29 #include "tversionnumber.h"
30 #include "tstring.h"
31 #include "taglib.h"
32 #include <cppunit/extensions/HelperMacros.h>
33
34 using namespace TagLib;
35
36 class TestTagLib : public CppUnit::TestFixture
37 {
38 CPPUNIT_TEST_SUITE(TestTagLib);
39 CPPUNIT_TEST(testVersionNumber);
40 CPPUNIT_TEST(testRuntimeVersion);
41 CPPUNIT_TEST_SUITE_END();
42
43 public:
44
45 void testVersionNumber()
46 {
47 VersionNumber v210(2, 1, 0);
48 VersionNumber v211(2, 1, 1);
49 VersionNumber v220(2, 2, 0);
50 VersionNumber v300(3, 0, 0);
51 CPPUNIT_ASSERT_EQUAL(0x020100U, v210.combinedVersion());
52 CPPUNIT_ASSERT_EQUAL(2U, v210.majorVersion());
53 CPPUNIT_ASSERT_EQUAL(1U, v210.minorVersion());
54 CPPUNIT_ASSERT_EQUAL(0U, v210.patchVersion());
55 CPPUNIT_ASSERT(v210 == VersionNumber(2, 1));
56 CPPUNIT_ASSERT(!(v210 == v211));
57 CPPUNIT_ASSERT(v210 != v211);
58 CPPUNIT_ASSERT(!(v210 != v210));
59 CPPUNIT_ASSERT(v210 < v211);
60 CPPUNIT_ASSERT(!(v220 < v210));
61 CPPUNIT_ASSERT(v220 > v211);
62 CPPUNIT_ASSERT(!(v210 > v211));
63 CPPUNIT_ASSERT(v210 <= v210);
64 CPPUNIT_ASSERT(v210 <= v300);
65 CPPUNIT_ASSERT(!(v300 <= v220));
66 CPPUNIT_ASSERT(v210 >= v210);
67 CPPUNIT_ASSERT(v220 >= v210);
68 CPPUNIT_ASSERT(!(v210 >= v300));
69 CPPUNIT_ASSERT_EQUAL(String("2.1.0"), v210.toString());
70 }
71
72 void testRuntimeVersion()
73 {
74 CPPUNIT_ASSERT(runtimeVersion() >= VersionNumber(
75 TAGLIB_MAJOR_VERSION, TAGLIB_MINOR_VERSION));
76 CPPUNIT_ASSERT(runtimeVersion() >= VersionNumber(
77 TAGLIB_MAJOR_VERSION, TAGLIB_MINOR_VERSION, TAGLIB_PATCH_VERSION));
78 CPPUNIT_ASSERT(runtimeVersion() == VersionNumber(
79 TAGLIB_MAJOR_VERSION, TAGLIB_MINOR_VERSION, TAGLIB_PATCH_VERSION));
80 }
81
82 };
83
84 CPPUNIT_TEST_SUITE_REGISTRATION(TestTagLib);