/[escript]/trunk/finley/test/python/gentest
ViewVC logotype

Annotation of /trunk/finley/test/python/gentest

Parent Directory Parent Directory | Revision Log Revision Log


Revision 589 - (hide annotations)
Fri Mar 10 06:28:35 2006 UTC (13 years, 11 months ago) by gross
File size: 4852 byte(s)
my little test generator
1 gross 589 #!/usr/bin/python
2     t_prog={}
3     t_prog["2Do1"]=""
4     t_prog["2Do2"]=""
5     t_prog["3Do1"]=""
6     t_prog["3Do2"]=""
7     t_prog["2Do1_contact"]=""
8     t_prog["2Do2_contact"]=""
9     t_prog["3Do1_contact"]=""
10     t_prog["3Do2_contact"]=""
11     intend=" "
12    
13     def makeTitle(d,o,s,coef,case,type,body="",mark=""):
14     if mark=="":
15     name="test_assemblage_%sD_order%s_neq%s_%s_%s_%s"%(d,o,s,coef,case,type)
16     else:
17     name="test_assemblage_%sD_order%s_neq%s_%s_%s_%s_%s"%(d,o,s,coef,case,type,mark)
18     key="%sDo%s"%(d,o)
19     if coef=="d_contact": key+="_contact"
20     t_prog[key]+=intend+"#"+80*"+"+"\n"+intend+"def %s(self):\n"%name
21     if body=="":
22     t_prog[key]+=2*intend+"pass\n"
23     else:
24     t_prog[key]+=body
25    
26     for s in [1,2,3,4]:
27     for d in [2,3]:
28     for type in ["strong","weak"]:
29     for o in [1,2]:
30     for case in ["const","vario"]:
31     # coefficient A:
32     if s==1:
33     for i in range(d):
34     for j in range(d):
35     makeTitle(d,o,s,"A",case,type,body="",mark="%s%s"%(i,j))
36     else:
37     for p in range(s):
38     for i in range(d):
39     for q in range(s):
40     for j in range(d):
41     makeTitle(d,o,s,"A",case,type,body="",mark="%s%s%s%s"%(p,i,q,j))
42     # coefficient B:
43     if s==1:
44     for i in range(d):
45     makeTitle(d,o,s,"B",case,type,body="",mark="%s"%(i))
46     else:
47     for p in range(s):
48     for i in range(d):
49     for q in range(s):
50     makeTitle(d,o,s,"B",case,type,body="",mark="%s%s%s"%(p,i,q))
51     if type=="strong":
52     # coefficient C:
53     if s==1:
54     for j in range(d):
55     makeTitle(d,o,s,"C",case,type,body="",mark="%s"%(j))
56     else:
57     for p in range(s):
58     for q in range(s):
59     for j in range(d):
60     makeTitle(d,o,s,"C",case,type,body="",mark="%s%s%s"%(p,q,j))
61     # coefficient D:
62     if s==1:
63     makeTitle(d,o,s,"D",case,type,body="",mark="")
64     else:
65     for p in range(s):
66     for q in range(s):
67     makeTitle(d,o,s,"D",case,type,body="",mark="%s%s"%(p,q))
68     # coefficient d:
69     if s==1:
70     makeTitle(d,o,s,"d",case,type,body="",mark="")
71     else:
72     for p in range(s):
73     for q in range(s):
74     makeTitle(d,o,s,"d_contact",case,type,body="",mark="%s%s"%(p,q))
75     # coefficient d_contact:
76     if s==1:
77     makeTitle(d,o,s,"d_contact",case,type,body="",mark="")
78     else:
79     for p in range(s):
80     for q in range(s):
81     makeTitle(d,o,s,"d_contact",case,type,body="",mark="%s%s"%(p,q))
82     #================================
83     print "import unittest"
84     print "import numarray"
85     print "from esys.escript import *"
86     print "from esys.finley import Rectangle,Brick"
87     print "class Test_assemblage_2Do1(unittest.TestCase):"
88     print t_prog["2Do1"]
89     print "class Test_assemblage_2Do2(unittest.TestCase):"
90     print t_prog["2Do2"]
91     print "class Test_assemblage_3Do1(unittest.TestCase):"
92     print t_prog["3Do1"]
93     print "class Test_assemblage_3Do2(unittest.TestCase):"
94     print t_prog["3Do2"]
95     print "class Test_assemblage_2Do1Contact(unittest.TestCase):"
96     print t_prog["2Do1_contact"]
97     print "class Test_assemblage_2Do2Contact(unittest.TestCase):"
98     print t_prog["2Do2_contact"]
99     print "class Test_assemblage_3Do1Contact(unittest.TestCase):"
100     print t_prog["3Do1_contact"]
101     print "class Test_assemblage_3Do2Contact(unittest.TestCase):"
102     print t_prog["3Do2_contact"]
103    
104     print "class Test_Finley_assemblage_2Do1(Test_assemblage_2Do1):"
105     print " RES_TOL=1.e-7"
106     print " def setUp(self):"
107     print " self.domain =Rectangle(2,2,1)"
108     print "class Test_Finley_assemblage_2Do2(Test_assemblage_2Do2):"
109     print " RES_TOL=1.e-7"
110     print " def setUp(self):"
111     print " self.domain =Rectangle(2,2,2)"
112     print "class Test_Finley_assemblage_3Do1(Test_assemblage_3Do1):"
113     print " RES_TOL=1.e-7"
114     print " def setUp(self):"
115     print " self.domain =Brick(2,2,2,1)"
116     print "class Test_Finley_assemblage_3Do2(Test_assemblage_3Do2):"
117     print " RES_TOL=1.e-7"
118     print " def setUp(self):"
119     print " self.domain =Brick(2,2,2,2)"
120     print "suite = unittest.TestSuite()"
121     print "suite.addTest(unittest.makeSuite(Test_Finley_assemblage_2Do1))"
122     print "suite.addTest(unittest.makeSuite(Test_Finley_assemblage_2Do2))"
123     print "suite.addTest(unittest.makeSuite(Test_Finley_assemblage_3Do1))"
124     print "suite.addTest(unittest.makeSuite(Test_Finley_assemblage_3Do2))"
125     print "unittest.TextTestRunner(verbosity=2).run(suite)"

  ViewVC Help
Powered by ViewVC 1.1.26