source: utilitiespy/test/tools/safehashtest.py@ 1059

Last change on this file since 1059 was 1059, checked in by wouter, 5 months ago

#354 hashcode fixes. I need unordered hashcode for Set,Dict but ordered for tuple, list.

File size: 464 bytes
Line 
1import unittest
2from tudelft.utilities.tools.safehash import safehash
3
4class SafeHashTest(unittest.TestCase):
5
6 def tests(self):
7 lst=[1,2,3]
8 safehash(lst)
9 safehash({'a':1})
10 safehash( set(lst))
11 safehash({'a':set(lst)})
12
13 h1= safehash({'a':1})
14 h2= safehash({'a':2})
15 self.assertNotEqual(h1,h2)
16
17 h1= safehash({'a':1,'b':2})
18 h2= safehash({'b':2,'a':1})
19 self.assertEqual(h1,h2)
20
21
22 # you can a set in a set...
23 #safehash(set([set(lst)]))
24
25
Note: See TracBrowser for help on using the repository browser.