aboutsummaryrefslogtreecommitdiffstats
path: root/tests/QtCore/qstring_test.py
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.lima@openbossa.org>2010-06-03 15:34:17 -0300
committerHugo Parente Lima <hugo.lima@openbossa.org>2010-06-10 14:57:41 -0300
commite39bfefde9edda662f51eeaf9a482f209c7f1217 (patch)
treea4add52f8ca3460fcaed99c6d9c7fc810f341a49 /tests/QtCore/qstring_test.py
parent24a944590663582df72aefd1929ec19ba3c6414f (diff)
Remove wrapper for classes: QString, QStringRef, QLatin1String, QStringMatcher, QChar and QLatin1Char.
Diffstat (limited to 'tests/QtCore/qstring_test.py')
-rw-r--r--tests/QtCore/qstring_test.py176
1 files changed, 9 insertions, 167 deletions
diff --git a/tests/QtCore/qstring_test.py b/tests/QtCore/qstring_test.py
index 3f0fb4931..fbaa6d440 100644
--- a/tests/QtCore/qstring_test.py
+++ b/tests/QtCore/qstring_test.py
@@ -6,173 +6,19 @@ import unittest
import ctypes
import sys
-from PySide.QtCore import QString, QByteArray, QObject
-
-class QStringToNumber(unittest.TestCase):
- def testReturnValueTypes(self):
- obj = QString('37')
- val, ok = obj.toInt()
- self.assertEqual(type(val), int)
- self.assertEqual(type(ok), bool)
-
- def testToNumberInt(self):
- obj = QString('37')
- self.assertEqual((37, True), obj.toInt())
-
- def testToNumberLong(self):
- obj = QString('3700000')
- self.assertEqual((3700000, True), obj.toInt())
-
- def testToNumberShort(self):
- obj = QString('33')
- self.assertEqual((ctypes.c_short(33).value, True), obj.toShort())
-
- def testToNumberShortNegative(self):
- obj = QString('-4')
- self.assertEqual((ctypes.c_short(-4).value, True), obj.toShort())
-
- def testToNumberShortOverflow(self):
- obj = QString('1000000')
- self.assertEqual(False, obj.toShort()[1])
-
- def testToNumberUInt(self):
- obj = QString('33')
- self.assertEqual((ctypes.c_uint(33).value, True), obj.toUInt())
-
- def testToNumberUIntNegative(self):
- obj = QString('-4')
- self.assertEqual(False, obj.toUInt()[1])
-
- def testToNumberUIntOverflow(self):
- obj = QString('10000000000000')
- self.assertEqual(False, obj.toUInt()[1])
-
- def testToNumberULong(self):
- obj = QString('33')
- self.assertEqual((ctypes.c_ulong(33).value, True), obj.toULong())
-
- def testToNumberULongNegative(self):
- obj = QString('-4')
- self.assertEqual(False, obj.toULong()[1])
-
- def testToNumberUShort(self):
- obj = QString('33')
- self.assertEqual((ctypes.c_ushort(33).value, True), obj.toUShort())
-
- def testToNumberUShortLarge(self):
- obj = QString('128')
- self.assertEqual((ctypes.c_ushort(128).value, True), obj.toUShort())
-
- def testToNumberUShortOverflow(self):
- obj = QString('205000')
- self.assertEqual(False, obj.toUShort()[1])
-
- def testToNumberUShortNegative(self):
- obj = QString('-4')
- self.assertEqual(False, obj.toUShort()[1])
-
- def testToNumberIntUsingHex(self):
- obj = QString('2A')
- self.assertEquals((0, False), obj.toInt())
- self.assertEqual((int(str(obj), 16), True), obj.toInt(16))
-
- def testToNumberIntUsingHex(self):
- obj = QString('101010')
- self.assertEqual((int(str(obj), 2), True), obj.toInt(2))
-
- def testToNumberFloat(self):
- obj = QString('37.109')
- self.assertEqual(ctypes.c_float(37.109).value,
- obj.toFloat()[0])
-
- def testToNumberDouble(self):
- obj = QString('37.109')
- self.assertEqual(ctypes.c_double(37.109).value,
- obj.toDouble()[0])
-
- def testToULongLong(self):
- obj = QString('37109')
- self.assertEqual(ctypes.c_ulong(37109).value,
- obj.toULongLong()[0])
+from PySide.QtCore import *
class QStringConstructor(unittest.TestCase):
'''Test case for QString constructors'''
def testQStringDefault(self):
- #QString()
- obj1 = QString()
- obj2 = QString()
-
- self.assertEqual(obj1, obj2)
-
- def testNullQString(self):
- s = QString(None)
- self.assertTrue(s.isNull())
-
- def testQStringFromPy(self):
- #QString(const char*)
- sample = 'a new string'
- obj1 = QString(sample)
- obj2 = QString(sample)
- self.assertEqual(obj1, obj2)
-
- def testQStringFromUnicode(self):
- sample = u'áâãà'
- obj1 = QString(sample)
- obj2 = QString(sample)
- self.assertEqual(obj1, obj2)
- self.assertEqual(obj1, sample)
- self.assertEqual(obj2, sample)
-
- def testQStringFromByteArray(self):
- # QByteArray(const char *) must be working
- sample = QByteArray('foo')
- obj1 = QString(sample)
- obj2 = QString(sample)
- self.assertEqual(obj1, obj2)
-
- def testQStringArg(self):
- a = QString("%1 %2 %3").arg(1).arg("two").arg(3.14)
- self.assertEquals("1 two 3.14", str(a))
-
- def testQStringArgNegative(self):
- a = QString("%1").arg(-20)
- self.assertEquals("-20", str(a))
-
-
-class QStringComparison(unittest.TestCase):
- '''Test case for comparison to python strings'''
-
- def testComparePyString(self):
- #Compare QStrings and Python strings.
- py = ''
- qstr = QString()
- self.assertEqual(py, qstr)
-
- py = 'The quick brown fox jumps over the lazy dog'
- qstr = QString(py)
- self.assertEqual(py, qstr)
-
-class QStringRange(unittest.TestCase):
- '''Test case for ranges in python strings'''
-
- def testSimpleRange(self):
- #Test open start and open end intervals
- py = 'The quick brown fox jumps over the lazy dog'
- qstr = QString(py)
- self.assertEqual(py[5:], qstr[5:])
- self.assertEqual(py[:7], qstr[:7])
-
-class QStringIndexOf(unittest.TestCase):
- def testEmpty(self):
- string = QString()
- self.assertEqual(string.indexOf(QString("aaa")), -1)
- self.assertEqual(string.indexOf(QString()), 0)
-
- def testString(self):
- string = QString("the quick brown fox")
- self.assertEqual(string.indexOf("quick", 0), 4)
-
+ 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'''
@@ -181,12 +27,8 @@ class QStringImplicitConvertion(unittest.TestCase):
'''QString implicitly conversion: QByteArray'''
obj = QObject()
obj.setObjectName(QByteArray('foobar'))
- self.assertEqual(obj.objectName(), QString('foobar'))
+ self.assertEqual(obj.objectName(), u'foobar')
-class QStringHash(unittest.TestCase):
- def testHash(self):
- self.assertEqual(hash("key"), hash(QString("key")))
- self.assertEqual(hash(u"aéióu"), hash(QString(u"aéióu")))
if __name__ == '__main__':
unittest.main()