Salome HOME
23288: [CEA 1626] Meshgems v2.3
[plugins/ghs3dprlplugin.git] / src / tools / testMeshTest.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 # %% LICENSE_SALOME_CEA_BEGIN
5 # Copyright (C) 2008-2016  CEA/DEN
6
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License, or (at your option) any later version.
11
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 # Lesser General Public License for more details.
16
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
21 # See http://www.salome-platform.org or email : webmaster.salome@opencascade.com
22 # %% LICENSE_END
23
24
25 import unittest
26 import testMesh as TM
27 from argparse import Namespace
28     
29 verbose = False
30
31 class TestCase(unittest.TestCase):
32
33   def test_010(self):
34     self.failUnlessEqual(TM.okToSys([]), TM.KOSYS)
35     self.failUnlessEqual(TM.okToSys([[]]), TM.KOSYS)
36     
37     res = TM.OK + " blah blah 0"
38     self.failUnlessEqual(TM.okToSys([[res]]), TM.OKSYS)
39     self.failUnlessEqual(TM.okToSys(res), TM.OKSYS)
40     res = [res]
41     self.failUnlessEqual(TM.okToSys(res), TM.OKSYS)
42     res.append(TM.OK + " blah blah 1")
43     self.failUnlessEqual(TM.okToSys(res), TM.OKSYS)  
44     res.append([TM.OK + " blah blah 2"])
45     self.failUnlessEqual(TM.okToSys(res), TM.OKSYS) 
46     res.append([TM.KO + " blah blah 3"])
47     self.failUnlessEqual(TM.okToSys(res), TM.KOSYS)
48     self.failUnlessEqual(TM.okToSys([]), TM.KOSYS)
49     res = [[[res]],[TM.OK + " blah blah 4"],[]]
50     self.failUnlessEqual(TM.okToSys(res), TM.KOSYS)
51
52   def test_030(self):
53     a = TM.XXVert(1, 1, 1)
54     b = TM.XXVert(2, 2, 2)
55     c = TM.XXVert(1., 1., 1., 3, 4)
56     self.failUnlessEqual(a==c, True)
57     
58     from argparse import Namespace
59     args = Namespace(withColor=True, withIndex=True)
60     self.failUnlessEqual(a.compare(c, args, withAll=True), False)
61     self.failUnlessEqual(a.compare(c, args, withAll=False), True)
62     
63     args = Namespace(withColor=False, withIndex=False)
64     self.failUnlessEqual(a.compare(c, args, withAll=True), True)
65     
66     self.failUnlessEqual(a==b, False)
67     self.failUnlessEqual(a.dist(b), 3**.5)
68     
69     self.failUnlessEqual(str(c), '(1.0 1.0 1.0 (3 4))')
70     self.failUnlessEqual(c.__repr__(), 'XXVert(1.0000 1.0000 1.0000 (3 4))')
71
72
73 if __name__ == '__main__':
74   verbose = False
75   unittest.main()
76   pass