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