[Checkins] SVN: BTrees/branches/pure_python/ Overlooked.

Tres Seaver cvs-admin at zope.org
Sun Nov 11 20:51:49 UTC 2012


Log message for revision 128235:
  Overlooked.

Changed:
  _U  BTrees/branches/pure_python/
  A   BTrees/branches/pure_python/BTrees/tests/test_utils.py

-=-
Added: BTrees/branches/pure_python/BTrees/tests/test_utils.py
===================================================================
--- BTrees/branches/pure_python/BTrees/tests/test_utils.py	                        (rev 0)
+++ BTrees/branches/pure_python/BTrees/tests/test_utils.py	2012-11-11 20:51:49 UTC (rev 128235)
@@ -0,0 +1,82 @@
+##############################################################################
+#
+# Copyright (c) 2001-2012 Zope Foundation 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
+#
+##############################################################################
+import unittest
+
+
+class Test_non_negative(unittest.TestCase):
+
+    def _callFUT(self, int_val):
+        from BTrees.utils import non_negative
+        return non_negative(int_val)
+
+    def test_w_big_negative(self):
+        import sys
+        self.assertEqual(self._callFUT(-sys.maxint), 1)
+
+    def test_w_negative(self):
+        import sys
+        self.assertEqual(self._callFUT(-1), sys.maxint)
+
+    def test_w_zero(self):
+        self.assertEqual(self._callFUT(0), 0)
+
+    def test_w_positive(self):
+        self.assertEqual(self._callFUT(1), 1)
+
+    def test_w_big_positive(self):
+        import sys
+        self.assertEqual(self._callFUT(sys.maxint), sys.maxint)
+
+
+class Test_oid_repr(unittest.TestCase):
+
+    def _callFUT(self, oid):
+        from BTrees.utils import oid_repr
+        return oid_repr(oid)
+
+    def test_w_non_strings(self):
+        self.assertEqual(self._callFUT(None), repr(None))
+        self.assertEqual(self._callFUT(()), repr(()))
+        self.assertEqual(self._callFUT([]), repr([]))
+        self.assertEqual(self._callFUT({}), repr({}))
+        self.assertEqual(self._callFUT(0), repr(0))
+
+    def test_w_short_strings(self):
+        for length in range(8):
+            faux = 'x' * length
+            self.assertEqual(self._callFUT(faux), repr(faux))
+
+    def test_w_long_strings(self):
+        for length in range(9, 1024):
+            faux = 'x' * length
+            self.assertEqual(self._callFUT(faux), repr(faux))
+
+    def test_w_zero(self):
+        self.assertEqual(self._callFUT('\0\0\0\0\0\0\0\0'), '0x00')
+
+    def test_w_one(self):
+        self.assertEqual(self._callFUT('\0\0\0\0\0\0\0\1'), '0x01')
+
+    def test_w_even_length(self):
+        self.assertEqual(self._callFUT('\0\0\0\0\0\0\xAB\xC4'), '0xabc4')
+
+    def test_w_odd_length(self):
+        self.assertEqual(self._callFUT('\0\0\0\0\0\0\x0D\xEF'), '0x0def')
+
+
+def test_suite():
+    return unittest.TestSuite((
+        unittest.makeSuite(Test_non_negative),
+        unittest.makeSuite(Test_oid_repr),
+    ))



More information about the checkins mailing list