| 1 |
schorsch |
1.1 |
|
| 2 |
|
|
|
| 3 |
|
|
import os
|
| 4 |
|
|
import math
|
| 5 |
|
|
import string
|
| 6 |
|
|
import unittest
|
| 7 |
|
|
|
| 8 |
|
|
from unit_tools import support
|
| 9 |
|
|
from unit_tools import lcompare
|
| 10 |
|
|
|
| 11 |
|
|
class CntTestCase(unittest.TestCase):
|
| 12 |
|
|
def setUp(self):
|
| 13 |
|
|
self.oldpath = os.environ['PATH']
|
| 14 |
|
|
os.environ['PATH'] = os.path.abspath(support.BINDIR)
|
| 15 |
|
|
|
| 16 |
|
|
def tearDown(self):
|
| 17 |
|
|
os.environ['PATH'] = self.oldpath
|
| 18 |
|
|
|
| 19 |
|
|
def test_1(self):
|
| 20 |
|
|
cmd = 'cnt 5'
|
| 21 |
|
|
res0 = os.popen(cmd).read()
|
| 22 |
|
|
res = map(string.strip,string.split(res0, '\n'))
|
| 23 |
|
|
exp = [0, 1, 2, 3, 4, '']
|
| 24 |
|
|
try: lcompare.lcompare(res, exp)
|
| 25 |
|
|
except lcompare.error, e: self.fail(str(e))
|
| 26 |
|
|
|
| 27 |
|
|
def test_2(self):
|
| 28 |
|
|
cmd = 'cnt 3 2'
|
| 29 |
|
|
res0 = os.popen(cmd).read()
|
| 30 |
|
|
res = map(string.split,string.split(res0, '\n'))
|
| 31 |
|
|
exp = [[0,0], [0,1], [1,0], [1,1], [2,0], [2,1], []]
|
| 32 |
|
|
try: lcompare.llcompare(res, exp)
|
| 33 |
|
|
except lcompare.error, e: self.fail(str(e))
|
| 34 |
|
|
|
| 35 |
|
|
def test_3(self):
|
| 36 |
|
|
cmd = 'cnt 3 2 3'
|
| 37 |
|
|
res0 = os.popen(cmd).read()
|
| 38 |
|
|
res = map(string.split,string.split(res0, '\n'))
|
| 39 |
|
|
exp = [[0,0,0],[0,0,1],[0,0,2],
|
| 40 |
|
|
[0,1,0],[0,1,1],[0,1,2],
|
| 41 |
|
|
[1,0,0],[1,0,1],[1,0,2],
|
| 42 |
|
|
[1,1,0],[1,1,1],[1,1,2],
|
| 43 |
|
|
[2,0,0],[2,0,1],[2,0,2],
|
| 44 |
|
|
[2,1,0],[2,1,1],[2,1,2],
|
| 45 |
|
|
[]]
|
| 46 |
|
|
try: lcompare.llcompare(res, exp)
|
| 47 |
|
|
except lcompare.error, e: self.fail(str(e))
|
| 48 |
|
|
|
| 49 |
|
|
|
| 50 |
|
|
def main():
|
| 51 |
|
|
support.run_case(CntTestCase)
|
| 52 |
|
|
|
| 53 |
|
|
if __name__ == '__main__':
|
| 54 |
|
|
main()
|
| 55 |
|
|
|
| 56 |
|
|
# vi: set ts=4 sw=4 :
|