changeset 1:5fa902852779 default tip

add unit tests for timedelta function
author Dirk Olmes <dirk@xanthippe.ping.de>
date Sat, 10 Jan 2009 04:09:22 +0100
parents 78a59d65bfcc
children
files timedelta_tests.py
diffstat 1 files changed, 50 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/timedelta_tests.py	Sat Jan 10 04:09:22 2009 +0100
@@ -0,0 +1,50 @@
+
+import unittest
+from timedelta import timedelta
+from datetime import time
+
+class TimeDeltaTests(unittest.TestCase):
+    def testDeltaWrongArgumentOrder(self):
+        t1 = time(microsecond=4)
+        t2 = time(microsecond=5)
+        expected = time(microsecond=1)
+        self.assert_(expected == timedelta(t2, t1))
+
+    def testDeltaMicroseconds(self):
+        t1 = time(microsecond=4)
+        t2 = time(microsecond=5)
+        expected = time(microsecond=1)
+        self.assert_(expected == timedelta(t1, t2))
+    
+    def testDeltaSeconds(self):
+        t1 = time(second=4)
+        t2 = time(second=5)
+        expected = time(second=1)
+        self.assert_(expected == timedelta(t1, t2))
+    
+    def testDeltaMinutes(self):
+        t1 = time(minute=4)
+        t2 = time(minute=5)
+        expected = time(minute=1)
+        self.assert_(expected == timedelta(t1, t2))
+    
+    def testDeltaHours(self):
+        t1 = time(hour=4)
+        t2 = time(hour=5)
+        expected = time(hour=1)
+        self.assert_(expected == timedelta(t1, t2))
+    
+    def testDeltaMixed(self):
+        t1 = time(11, 32, 10)
+        t2 = time(11, 35, 30)
+        expected = time(minute=3, second=20)
+        self.assert_(expected == timedelta(t1, t2))
+    
+    def testDeltaMax(self):
+        t1 = time(0, 0, 0, 0)
+        t2 = time(23, 59, 59, 999999)
+        expected = time(23, 59, 59, 999999)
+        self.assert_(expected == timedelta(t1, t2))
+
+if __name__ == "__main__":
+    unittest.main()