[Zodb-checkins] SVN: ZODB/trunk/src/BTrees/tests/testLength.py
merge revision 86558 from the 3.8 branch:
Fred L. Drake, Jr.
fdrake at gmail.com
Fri May 9 01:35:00 EDT 2008
Log message for revision 86560:
merge revision 86558 from the 3.8 branch:
there are no tests for BTrees.Length; add tests that show that the Length
object will properly switch to longs when over/underflowing 32-bit values
Changed:
A ZODB/trunk/src/BTrees/tests/testLength.py
-=-
Copied: ZODB/trunk/src/BTrees/tests/testLength.py (from rev 86558, ZODB/branches/3.8/src/BTrees/tests/testLength.py)
===================================================================
--- ZODB/trunk/src/BTrees/tests/testLength.py (rev 0)
+++ ZODB/trunk/src/BTrees/tests/testLength.py 2008-05-09 05:34:59 UTC (rev 86560)
@@ -0,0 +1,46 @@
+##############################################################################
+#
+# Copyright (c) 2008 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE
+#
+##############################################################################
+"""\
+Test for BTrees.Length module.
+
+"""
+__docformat__ = "reStructuredText"
+
+import BTrees.Length
+import sys
+import unittest
+
+
+class LengthTestCase(unittest.TestCase):
+
+ def test_length_overflows_to_long(self):
+ length = BTrees.Length.Length(sys.maxint)
+ self.assertEqual(length(), sys.maxint)
+ self.assert_(type(length()) is int)
+ length.change(+1)
+ self.assertEqual(length(), sys.maxint + 1)
+ self.assert_(type(length()) is long)
+
+ def test_length_underflows_to_long(self):
+ minint = (-sys.maxint) - 1
+ length = BTrees.Length.Length(minint)
+ self.assertEqual(length(), minint)
+ self.assert_(type(length()) is int)
+ length.change(-1)
+ self.assertEqual(length(), minint - 1)
+ self.assert_(type(length()) is long)
+
+
+def test_suite():
+ return unittest.makeSuite(LengthTestCase)
More information about the Zodb-checkins
mailing list