summaryrefslogtreecommitdiffstats
path: root/tests/QtCore/qstring_test.py
blob: fbaa6d44098aedeb75d0612b043cbf2378a02dc6 (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
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''Test cases for QString'''

import unittest
import ctypes
import sys

from PySide.QtCore import *

class QStringConstructor(unittest.TestCase):
    '''Test case for QString constructors'''

    def testQStringDefault(self):
        obj = QObject()
        obj.setObjectName('foo')
        self.assertEqual(obj.objectName(), u'foo')
        obj.setObjectName(u'áâãà')
        self.assertEqual(obj.objectName(), u'áâãà')
        obj.setObjectName(None)
        self.assertEqual(obj.objectName(), u'')

class QStringImplicitConvertion(unittest.TestCase):
    '''Implicit conversions for QString'''

    def testQByteArray(self):
        '''QString implicitly conversion: QByteArray'''
        obj = QObject()
        obj.setObjectName(QByteArray('foobar'))
        self.assertEqual(obj.objectName(), u'foobar')


if __name__ == '__main__':
    unittest.main()