blob: a40724b0ee5dcf646f301274b9ba16a24babfc97 (
plain)
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
|
'''Test cases for QChar'''
import unittest
from PySide.QtCore import QString, QChar, QTextStream, QLatin1Char
class EqualTest(unittest.TestCase):
'''Tests for '__equal__'''
def testEqualQChar(self):
'''QChar == QChar'''
self.assertEqual(QChar('a'), QChar('a'))
def testEqualPyString(self):
'''QChar == Python string'''
self.assertEqual(QChar('a'), 'a')
class ImplicitConvQLatin1Char(unittest.TestCase):
'''Tests for implicit conversion from QLatin1Char to QChar'''
def testQLatin1CharToChar(self):
'''QLatin1Char implicitly convertible to QChar'''
stream = QTextStream()
stream.setPadChar(QLatin1Char('-'))
self.assertEqual(QChar('-'), stream.padChar())
class QCharCtorBigNumber(unittest.TestCase):
'''QChar constructors receiving ints'''
def testInt(self):
'''QChar(int)'''
codepoint = 512
qchar = QChar(codepoint)
reference = unichr(codepoint)
self.assertEqual(qchar.unicode(), codepoint)
class QCharCtorString(unittest.TestCase):
'''QChar constructor receiving strings'''
def testBasic(self):
'''QChar(char)'''
reference = 'a'
qchar = QChar(reference)
self.assertEqual(ord(reference), ord(qchar.toAscii()))
def testError(self):
'''QChar(char)'''
reference = 'aaaaaa'
self.assertRaises(TypeError, QChar, reference)
if __name__ == '__main__':
unittest.main()
|