Fixes type system templates for methods with bool* as parameter.
Template functions like "fix_bool*" were converting the bool "ok" value to various types except bool, and "fix_bool*,arg" was using the wrong C++ argument. Tests were also added. Reviewed by Hugo Parente <hugo.lima@openbossa.org>
This commit is contained in:
parent
85048bbd6c
commit
7729b390d0
2 changed files with 20 additions and 5 deletions
|
|
@ -9,10 +9,25 @@ import sys
|
|||
from PySide.QtCore import QString, QByteArray
|
||||
|
||||
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, obj.toInt()[0])
|
||||
|
||||
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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue