Salome HOME
Porting to Python 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
27 import testMesh as TM
28
29
30 verbose = False
31
32
33 class TestCase(unittest.TestCase):
34
35     def test_010(self):
36         self.assertEqual(TM.okToSys([]), TM.KOSYS)
37         self.assertEqual(TM.okToSys([[]]), TM.KOSYS)
38
39         res = TM.OK + " blah blah 0"
40         self.assertEqual(TM.okToSys([[res]]), TM.OKSYS)
41         self.assertEqual(TM.okToSys(res), TM.OKSYS)
42         res = [res]
43         self.assertEqual(TM.okToSys(res), TM.OKSYS)
44         res.append(TM.OK + " blah blah 1")
45         self.assertEqual(TM.okToSys(res), TM.OKSYS)
46         res.append([TM.OK + " blah blah 2"])
47         self.assertEqual(TM.okToSys(res), TM.OKSYS)
48         res.append([TM.KO + " blah blah 3"])
49         self.assertEqual(TM.okToSys(res), TM.KOSYS)
50         self.assertEqual(TM.okToSys([]), TM.KOSYS)
51         res = [[[res]], [TM.OK + " blah blah 4"], []]
52         self.assertEqual(TM.okToSys(res), TM.KOSYS)
53
54     def test_030(self):
55         a = TM.XXVert(1, 1, 1)
56         b = TM.XXVert(2, 2, 2)
57         c = TM.XXVert(1., 1., 1., 3, 4)
58         self.assertEqual(a == c, True)
59
60         from argparse import Namespace
61         args = Namespace(withColor=True, withIndex=True)
62         self.assertEqual(a.compare(c, args, withAll=True), False)
63         self.assertEqual(a.compare(c, args, withAll=False), True)
64
65         args = Namespace(withColor=False, withIndex=False)
66         self.assertEqual(a.compare(c, args, withAll=True), True)
67
68         self.assertEqual(a == b, False)
69         self.assertEqual(a.dist(b), 3 ** .5)
70
71         self.assertEqual(str(c), '(1.0 1.0 1.0 (3 4))')
72         self.assertEqual(c.__repr__(), 'XXVert(1.0000 1.0000 1.0000 (3 4))')
73
74
75 if __name__ == '__main__':
76     verbose = False
77     unittest.main()
78     pass