Salome HOME
Fix async optimizer loop with no point to evaluate.
[modules/yacs.git] / src / engine_swig / testBase64Conv.py
1 # Copyright (C) 2019  CEA/DEN, EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 import pilot
21 import unittest
22 import pickle
23 from math import sin
24
25 class TestBase64Conv(unittest.TestCase):
26     
27     def test0(self):
28         """
29         This test checks that internal method for Base64 is OK with pickled objects.
30         Reason of home made conversion :
31         old boost base64 conversion failed with (see commit b0f05b249ace88109a4a3d) string of size 124 due to incorrect output after pilot.FromBase64Swig
32         old boost base64 conversion failed with string of size 157 due to an exception thrown by boost
33         """
34         for i in range(124,624):
35             st = i*"/"
36             a = pickle.dumps(st,protocol=4) # protocol 4 is important here to generate complex
37             self.assertTrue( a == pilot.FromBase64Swig(pilot.ToBase64Swig(a) ) )
38             pass
39         pass
40
41     def test1(self):
42         l = [sin(float(i)) for i in range(1000)]
43         a = pickle.dumps(l,protocol=4)
44         self.assertTrue( a == pilot.FromBase64Swig(pilot.ToBase64Swig(a) ) )
45         pass
46     
47     pass
48
49 if __name__ == '__main__':
50     unittest.main()