[Python-checkins] python/dist/src/Lib/test test_deque.py,1.4,1.5
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Sat Feb 7 23:05:28 EST 2004
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15559/Lib/test
Modified Files:
test_deque.py
Log Message:
Make deque.rotate() smarter. Beef-up related tests.
Index: test_deque.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_deque.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** test_deque.py 7 Feb 2004 21:12:59 -0000 1.4
--- test_deque.py 8 Feb 2004 04:05:26 -0000 1.5
***************
*** 42,55 ****
def test_rotate(self):
! s = 'abcde'
d = deque(s)
! d.rotate(2)
! self.assertEqual(''.join(d), 'deabc')
! d.rotate(3)
! self.assertEqual(''.join(d), s)
! d.rotate(-3)
! self.assertEqual(''.join(d), 'deabc')
! d.rotate(-15)
! self.assertEqual(''.join(d), 'deabc')
def test_len(self):
--- 42,89 ----
def test_rotate(self):
! s = tuple('abcde')
! n = len(s)
!
d = deque(s)
! d.rotate(1) # verify rot(1)
! self.assertEqual(''.join(d), 'eabcd')
!
! d = deque(s)
! d.rotate(-1) # verify rot(-1)
! self.assertEqual(''.join(d), 'bcdea')
! d.rotate() # check default to 1
! self.assertEqual(tuple(d), s)
!
! for i in xrange(n*3):
! d = deque(s)
! e = deque(d)
! d.rotate(i) # check vs. rot(1) n times
! for j in xrange(i):
! e.rotate(1)
! self.assertEqual(tuple(d), tuple(e))
! d.rotate(-i) # check that it works in reverse
! self.assertEqual(tuple(d), s)
! e.rotate(n-i) # check that it wraps forward
! self.assertEqual(tuple(e), s)
!
! for i in xrange(n*3):
! d = deque(s)
! e = deque(d)
! d.rotate(-i)
! for j in xrange(i):
! e.rotate(-1) # check vs. rot(-1) n times
! self.assertEqual(tuple(d), tuple(e))
! d.rotate(i) # check that it works in reverse
! self.assertEqual(tuple(d), s)
! e.rotate(i-n) # check that it wraps backaround
! self.assertEqual(tuple(e), s)
!
! d = deque(s)
! e = deque(s)
! e.rotate(BIG+17) # verify on long series of rotates
! dr = d.rotate
! for i in xrange(BIG+17):
! dr()
! self.assertEqual(tuple(d), tuple(e))
def test_len(self):
More information about the Python-checkins
mailing list