-
-
Notifications
You must be signed in to change notification settings - Fork 399
/
Copy pathtest_util_astrcmp.py
62 lines (48 loc) · 2 KB
/
test_util_astrcmp.py
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
# -*- coding: utf-8 -*-
#
# Picard, the next-generation MusicBrainz tagger
#
# Copyright (C) 2017 Lukáš Lalinský
# Copyright (C) 2017 Sophist-UK
# Copyright (C) 2017-2018 Wieland Hoffmann
# Copyright (C) 2018, 2020-2022, 2024 Laurent Monin
# Copyright (C) 2018-2019, 2021 Philipp Wolfer
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import unittest
from test.picardtestcase import PicardTestCase
from picard.util.astrcmp import astrcmp_py
try:
from picard.util.astrcmp import astrcmp_c
except ImportError:
astrcmp_c = None
class AstrcmpBase:
func = None
def test_astrcmp(self):
astrcmp = self.__class__.func
self.assertAlmostEqual(0.0, astrcmp("", ""))
self.assertAlmostEqual(0.0, astrcmp("a", ""))
self.assertAlmostEqual(0.0, astrcmp("", "a"))
self.assertAlmostEqual(1.0, astrcmp("a", "a"))
self.assertAlmostEqual(0.0, astrcmp("a", "b"))
self.assertAlmostEqual(0.0, astrcmp("ab", "ba"))
self.assertAlmostEqual(0.7083333333333333, astrcmp("The Great Gig in the Sky", "Great Gig In The sky"))
class AstrcmpCTest(AstrcmpBase, PicardTestCase):
func = astrcmp_c
@unittest.skipIf(astrcmp_c is None, "The _astrcmp C extension module has not been compiled")
def test_astrcmp(self):
super().test_astrcmp()
class AstrcmpPyTest(AstrcmpBase, PicardTestCase):
func = astrcmp_py