ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/test/py_tests/test_cnt.py
Revision: 1.2
Committed: Thu Mar 10 01:49:56 2016 UTC (8 years, 2 months ago) by schorsch
Content type: text/x-python
Branch: MAIN
Changes since 1.1: +10 -4 lines
Log Message:
SCons build system learns about platform architecture

File Contents

# User Rev Content
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 schorsch 1.2 _bindir = None
12    
13 schorsch 1.1 class CntTestCase(unittest.TestCase):
14     def setUp(self):
15 schorsch 1.2 if _bindir:
16     self.oldpath = os.environ['PATH']
17     os.environ['PATH'] = _bindir
18 schorsch 1.1
19     def tearDown(self):
20 schorsch 1.2 if _bindir:
21     os.environ['PATH'] = self.oldpath
22 schorsch 1.1
23     def test_1(self):
24     cmd = 'cnt 5'
25     res0 = os.popen(cmd).read()
26     res = map(string.strip,string.split(res0, '\n'))
27     exp = [0, 1, 2, 3, 4, '']
28     try: lcompare.lcompare(res, exp)
29     except lcompare.error, e: self.fail(str(e))
30    
31     def test_2(self):
32     cmd = 'cnt 3 2'
33     res0 = os.popen(cmd).read()
34     res = map(string.split,string.split(res0, '\n'))
35     exp = [[0,0], [0,1], [1,0], [1,1], [2,0], [2,1], []]
36     try: lcompare.llcompare(res, exp)
37     except lcompare.error, e: self.fail(str(e))
38    
39     def test_3(self):
40     cmd = 'cnt 3 2 3'
41     res0 = os.popen(cmd).read()
42     res = map(string.split,string.split(res0, '\n'))
43     exp = [[0,0,0],[0,0,1],[0,0,2],
44     [0,1,0],[0,1,1],[0,1,2],
45     [1,0,0],[1,0,1],[1,0,2],
46     [1,1,0],[1,1,1],[1,1,2],
47     [2,0,0],[2,0,1],[2,0,2],
48     [2,1,0],[2,1,1],[2,1,2],
49     []]
50     try: lcompare.llcompare(res, exp)
51     except lcompare.error, e: self.fail(str(e))
52    
53    
54 schorsch 1.2 def main(bindir=None):
55     global _bindir
56     _bindir=bindir
57 schorsch 1.1 support.run_case(CntTestCase)
58    
59     if __name__ == '__main__':
60     main()
61    
62     # vi: set ts=4 sw=4 :