Added hash functions for QLine, QPoint, QRect and QSize classes.

Tests where also added.

Reviewed by Luciano Wolf <luciano.wolf@openbossa.org>
Reviewed by Renato Araújo <renato.filho@openbossa.org>
This commit is contained in:
Marcelo Lira 2010-09-27 19:03:30 -03:00
commit 4787f1eb0f
2 changed files with 63 additions and 4 deletions

View file

@ -1,6 +1,7 @@
#!/usr/bin/python
import unittest
from PySide.QtCore import QDate, QDateTime, QTime, QUrl
from PySide.QtCore import QLine, QPoint, QRect, QSize
class HashTest(unittest.TestCase):
def testInsert(self):
@ -20,6 +21,34 @@ class HashTest(unittest.TestCase):
self.assertEqual(myHash[qtime], "QTime")
self.assertEqual(myHash[qurl], "QUrl")
def testQPointHash(self):
p1 = QPoint(12, 34)
p2 = QPoint(12, 34)
self.assertFalse(p1 is p2)
self.assertEqual(p1, p2)
self.assertEqual(hash(p1), hash(p2))
def testQSizeHash(self):
s1 = QSize(12, 34)
s2 = QSize(12, 34)
self.assertFalse(s1 is s2)
self.assertEqual(s1, s2)
self.assertEqual(hash(s1), hash(s2))
def testQRectHash(self):
r1 = QRect(12, 34, 56, 78)
r2 = QRect(12, 34, 56, 78)
self.assertFalse(r1 is r2)
self.assertEqual(r1, r2)
self.assertEqual(hash(r1), hash(r2))
def testQLineHash(self):
l1 = QLine(12, 34, 56, 78)
l2 = QLine(12, 34, 56, 78)
self.assertFalse(l1 is l2)
self.assertEqual(l1, l2)
self.assertEqual(hash(l1), hash(l2))
if __name__ == '__main__':
unittest.main()