TestCollatz - #!/usr/bin/env python # # # # #

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
#!/usr/bin/env python # -------------------------------------- # projects/python/collatz/TestCollatz.py # Copyright (C) 2009 # Glenn P. Downing # -------------------------------------- # To run the tests # TestCollatz.py import unittest import Collatz from Collatz import collatz_read, collatz_eval, collatz_print # ------ # Reader # ------ class Reader (object) : def __init__ (self, s) : self.s = s def read (self) : return self.s # ------ # Writer # ------ class Writer (object) : def str (self) : return self.s def write (self, a, v) : self.s = str(a[0]) + " " self.s += str(a[1]) + " " self.s += str(v) + "\n" # ----------- # TestCollatz # ----------- class TestCollatz (unittest.TestCase) : # ---- # read # ---- def test_read (self) : r = Reader("1 10\n") a = [] b = collatz_read(r, a) self.assert_(b == True) self.assert_(a[0] == 1) self.assert_(a[1] == 10) def test_read_whitespace(self) : tests = {'tabs': "1 10\n",
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
'spaces': "1 10\n", 'leading space': " 1 10\n", 'trailing space': "1 10 \n",
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/05/2010 for the course CS 373 taught by Professor Downing,glennp during the Fall '08 term at University of Texas.

Page1 / 5

TestCollatz - #!/usr/bin/env python # # # # #

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online