adding test to make sure every second and third line on a blank pad is empty

cat-town
Dan Buch 15 years ago
parent dca18ca022
commit 5023469466

@ -15,4 +15,16 @@ class TestOneTimePad(unittest.TestCase):
def test_creates_pad_of_desired_length(self): def test_creates_pad_of_desired_length(self):
for width in (72, 33, 99, 111): for width in (72, 33, 99, 111):
pad = OT.create_pad(2000, width=width) pad = OT.create_pad(2000, width=width)
self.assertEqual(2000, len((''.join(pad.split())).strip('.'))) lines = [line.strip('.') for line in pad.split('\n\n\n')]
self.assertEqual(2000, len(''.join(lines)))
def test_two_out_of_every_three_lines_are_empty_on_new_pad(self):
pad = OT.create_pad(2000)
for i, line in enumerate(pad.splitlines()):
lineno = i + 3
if not lineno % 3:
self.assertTrue(bool(len(line)),
'line {0} is non-empty'.format(lineno))
else:
self.assertFalse(bool(len(line)),
'line {0} is empty'.format(lineno))

Loading…
Cancel
Save