Back to index

radiance  4R0+20100331
test_cnt.py
Go to the documentation of this file.
00001 
00002 
00003 import os
00004 import math
00005 import string
00006 import unittest
00007 
00008 from unit_tools import support
00009 from unit_tools import lcompare
00010 
00011 class CntTestCase(unittest.TestCase):
00012        def setUp(self):
00013               self.oldpath = os.environ['PATH']
00014               os.environ['PATH'] = os.path.abspath(support.BINDIR)
00015 
00016        def tearDown(self):
00017               os.environ['PATH'] = self.oldpath
00018 
00019        def test_1(self):
00020               cmd = 'cnt 5'
00021               res0 = os.popen(cmd).read()
00022               res = map(string.strip,string.split(res0, '\n'))
00023               exp = [0, 1, 2, 3, 4, '']
00024               try: lcompare.lcompare(res, exp)
00025               except lcompare.error, e: self.fail(str(e))
00026 
00027        def test_2(self):
00028               cmd = 'cnt 3 2'
00029               res0 = os.popen(cmd).read()
00030               res = map(string.split,string.split(res0, '\n'))
00031               exp = [[0,0], [0,1], [1,0], [1,1], [2,0], [2,1], []]
00032               try: lcompare.llcompare(res, exp)
00033               except lcompare.error, e: self.fail(str(e))
00034 
00035        def test_3(self):
00036               cmd = 'cnt 3 2 3'
00037               res0 = os.popen(cmd).read()
00038               res = map(string.split,string.split(res0, '\n'))
00039               exp = [[0,0,0],[0,0,1],[0,0,2],
00040                      [0,1,0],[0,1,1],[0,1,2],
00041                      [1,0,0],[1,0,1],[1,0,2],
00042                      [1,1,0],[1,1,1],[1,1,2],
00043                      [2,0,0],[2,0,1],[2,0,2],
00044                      [2,1,0],[2,1,1],[2,1,2],
00045                      []]
00046               try: lcompare.llcompare(res, exp)
00047               except lcompare.error, e: self.fail(str(e))
00048 
00049 
00050 def main():
00051        support.run_case(CntTestCase)
00052 
00053 if __name__ == '__main__':
00054        main()
00055 
00056 # vi: set ts=4 sw=4 :