File: test_versionnumber.cpp

package info (click to toggle)
taglib 2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 6,192 kB
  • sloc: cpp: 44,736; ansic: 137; makefile: 28
file content (84 lines) | stat: -rw-r--r-- 3,559 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/***************************************************************************
    copyright            : (C) 2020 by Kevin Andre
    email                : hyperquantum@gmail.com

    copyright            : (C) 2023 by Urs Fleisch
    email                : ufleisch@users.sourceforge.net
 ***************************************************************************/

/***************************************************************************
 *   This library is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU Lesser General Public License version   *
 *   2.1 as published by the Free Software Foundation.                     *
 *                                                                         *
 *   This library 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     *
 *   Lesser General Public License for more details.                       *
 *                                                                         *
 *   You should have received a copy of the GNU Lesser General Public      *
 *   License along with this library; if not, write to the Free Software   *
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA         *
 *   02110-1301  USA                                                       *
 *                                                                         *
 *   Alternatively, this file is available under the Mozilla Public        *
 *   License Version 1.1.  You may obtain a copy of the License at         *
 *   http://www.mozilla.org/MPL/                                           *
 ***************************************************************************/

#include "tversionnumber.h"
#include "tstring.h"
#include "taglib.h"
#include <cppunit/extensions/HelperMacros.h>

using namespace TagLib;

class TestTagLib : public CppUnit::TestFixture
{
  CPPUNIT_TEST_SUITE(TestTagLib);
  CPPUNIT_TEST(testVersionNumber);
  CPPUNIT_TEST(testRuntimeVersion);
  CPPUNIT_TEST_SUITE_END();

public:

  void testVersionNumber()
  {
    VersionNumber v210(2, 1, 0);
    VersionNumber v211(2, 1, 1);
    VersionNumber v220(2, 2, 0);
    VersionNumber v300(3, 0, 0);
    CPPUNIT_ASSERT_EQUAL(0x020100U, v210.combinedVersion());
    CPPUNIT_ASSERT_EQUAL(2U, v210.majorVersion());
    CPPUNIT_ASSERT_EQUAL(1U, v210.minorVersion());
    CPPUNIT_ASSERT_EQUAL(0U, v210.patchVersion());
    CPPUNIT_ASSERT(v210 == VersionNumber(2, 1));
    CPPUNIT_ASSERT(!(v210 == v211));
    CPPUNIT_ASSERT(v210 != v211);
    CPPUNIT_ASSERT(!(v210 != v210));
    CPPUNIT_ASSERT(v210 < v211);
    CPPUNIT_ASSERT(!(v220 < v210));
    CPPUNIT_ASSERT(v220 > v211);
    CPPUNIT_ASSERT(!(v210 > v211));
    CPPUNIT_ASSERT(v210 <= v210);
    CPPUNIT_ASSERT(v210 <= v300);
    CPPUNIT_ASSERT(!(v300 <= v220));
    CPPUNIT_ASSERT(v210 >= v210);
    CPPUNIT_ASSERT(v220 >= v210);
    CPPUNIT_ASSERT(!(v210 >= v300));
    CPPUNIT_ASSERT_EQUAL(String("2.1.0"), v210.toString());
  }

  void testRuntimeVersion()
  {
    CPPUNIT_ASSERT(runtimeVersion() >= VersionNumber(
      TAGLIB_MAJOR_VERSION, TAGLIB_MINOR_VERSION));
    CPPUNIT_ASSERT(runtimeVersion() >= VersionNumber(
      TAGLIB_MAJOR_VERSION, TAGLIB_MINOR_VERSION, TAGLIB_PATCH_VERSION));
    CPPUNIT_ASSERT(runtimeVersion() == VersionNumber(
      TAGLIB_MAJOR_VERSION, TAGLIB_MINOR_VERSION, TAGLIB_PATCH_VERSION));
  }

};

CPPUNIT_TEST_SUITE_REGISTRATION(TestTagLib);