pybank r100 - trunk



Author: marklee
Date: Tue Mar 31 23:35:08 2009
New Revision: 100
URL: http://svn.gnome.org/viewvc/pybank?rev=100&view=rev

Log:
	* everything_unittest.py: Add limit tests to the integer-related unit
	tests.


Modified:
   trunk/ChangeLog
   trunk/everything_unittest.py

Modified: trunk/everything_unittest.py
==============================================================================
--- trunk/everything_unittest.py	(original)
+++ trunk/everything_unittest.py	Tue Mar 31 23:35:08 2009
@@ -33,6 +33,21 @@
 import GLib
 import Everything
 
+INT8_MIN = -128
+INT16_MIN = -32768
+INT32_MIN = -2147483648
+INT64_MIN = -9223372036854775808L
+
+INT8_MAX = 127
+INT16_MAX = 32767
+INT32_MAX = 2147483647
+INT64_MAX = 9223372036854775807L
+
+UINT8_MAX = 255
+UINT16_MAX = 65535
+UINT32_MAX = 4294967295
+UINT64_MAX = 18446744073709551615L
+
 class SignalHandler:
     def __init__(self):
         self.counter = 0
@@ -44,7 +59,6 @@
         self.some_object = signal_obj
         self.obj.disconnect(self.h_id)
 
-# TODO test number type limits
 class TestGIEverything(unittest.TestCase):
 
     def testBoolean(self):
@@ -60,21 +74,29 @@
     def testInt8(self):
         self.assertEqual(3, Everything.test_int8(3))
         self.assertEqual(-3, Everything.test_int8(-3))
+        self.assertEqual(INT8_MIN, Everything.test_int8(INT8_MIN))
+        self.assertEqual(INT8_MAX, Everything.test_int8(INT8_MAX))
         self.assertRaises(TypeError, Everything.test_int, 'a')
 
     def testInt16(self):
         self.assertEqual(3, Everything.test_int16(3))
         self.assertEqual(-3, Everything.test_int16(-3))
+        self.assertEqual(INT16_MIN, Everything.test_int16(INT16_MIN))
+        self.assertEqual(INT16_MAX, Everything.test_int16(INT16_MAX))
         self.assertRaises(TypeError, Everything.test_int, 'a')
 
     def testInt32(self):
         self.assertEqual(3, Everything.test_int32(3))
         self.assertEqual(-3, Everything.test_int32(-3))
+        self.assertEqual(INT32_MIN, Everything.test_int32(INT32_MIN))
+        self.assertEqual(INT32_MAX, Everything.test_int32(INT32_MAX))
         self.assertRaises(TypeError, Everything.test_int, 'a')
 
     def testInt64(self):
         self.assertEqual(3, Everything.test_int64(3))
         self.assertEqual(-3, Everything.test_int64(-3))
+        self.assertEqual(INT64_MIN, Everything.test_int64(INT64_MIN))
+        self.assertEqual(INT64_MAX, Everything.test_int64(INT64_MAX))
         self.assertRaises(TypeError, Everything.test_int, 'a')
 
     def testUInt(self):
@@ -83,18 +105,22 @@
 
     def testUInt8(self):
         self.assertEqual(3, Everything.test_uint8(3))
+        self.assertEqual(UINT8_MAX, Everything.test_uint8(UINT8_MAX))
         self.assertRaises(TypeError, Everything.test_uint8, -3)
 
     def testUInt16(self):
         self.assertEqual(3, Everything.test_uint16(3))
+        self.assertEqual(UINT16_MAX, Everything.test_uint16(UINT16_MAX))
         self.assertRaises(TypeError, Everything.test_uint16, -3)
 
     def testUInt32(self):
         self.assertEqual(3, Everything.test_uint32(3))
+        self.assertEqual(UINT32_MAX, Everything.test_uint32(UINT32_MAX))
         self.assertRaises(TypeError, Everything.test_uint32, -3)
 
     def testUInt64(self):
         self.assertEqual(3, Everything.test_uint64(3))
+        self.assertEqual(UINT64_MAX, Everything.test_uint64(UINT64_MAX))
         self.assertRaises(TypeError, Everything.test_uint64, -3)
 
     def testLong(self):



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]