Commit 616d4350 authored by Fred Drake's avatar Fred Drake

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
parent 486173b8
##############################################################################
#
# 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)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment