source: utilitiespy/test/tools/atomictest.py@ 1323

Last change on this file since 1323 was 1306, checked in by wouter, 13 days ago

#407 added AtomicBoolean, bump 1.1.3

File size: 986 bytes
Line 
1from unittest.case import TestCase
2from tudelft.utilities.tools.atomic import AtomicBoolean
3
4class atomicTest(TestCase):
5 def testSimple(self):
6 a=AtomicBoolean(True)
7 self.assertEqual(True,a.get())
8 self.assertEqual(False,a.compareAndSet(False,False))
9 self.assertEqual(False,a.compareAndSet(False,True))
10 self.assertEqual(True,a.get())
11 self.assertEqual(True,a.compareAndSet(True,True))
12 self.assertEqual(True,a.get())
13 self.assertEqual(True,a.compareAndSet(True,False))
14 self.assertEqual(False,a.get())
15 self.assertEqual(True,a.compareAndSet(False,False))
16 self.assertEqual(False,a.get())
17 self.assertEqual(True,a.compareAndSet(False,True))
18 self.assertEqual(True,a.get())
19
20 # FIXME it would be nice to stress test the AtomicBoolnan for thread safety.
21 # I think we need to slow down AtomicBoolean processing for that,
22 # and tthat would pollute the AtomicBoolean code...
Note: See TracBrowser for help on using the repository browser.