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