diff options
Diffstat (limited to 'tests/QtCore/qchar_test.py')
-rw-r--r-- | tests/QtCore/qchar_test.py | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/QtCore/qchar_test.py b/tests/QtCore/qchar_test.py new file mode 100644 index 000000000..a40724b0e --- /dev/null +++ b/tests/QtCore/qchar_test.py @@ -0,0 +1,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() + |