annotate test/testbitfun.py @ 389:2ec730e45ea1

Added check for recursive struct
author Windel Bouwman
date Fri, 16 May 2014 12:29:31 +0200
parents 3bb7dcfe5529
children
rev   line source
346
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents:
diff changeset
1
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents:
diff changeset
2
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents:
diff changeset
3 import unittest
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents:
diff changeset
4 import sys
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents:
diff changeset
5 from ppci.bitfun import rotate_left, rotate_right
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents:
diff changeset
6
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents:
diff changeset
7
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents:
diff changeset
8 class BitRotationTestCase(unittest.TestCase):
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents:
diff changeset
9 def testRightRotation(self):
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents:
diff changeset
10 self.assertEqual(0xFF000000, rotate_right(0xFF, 8))
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents:
diff changeset
11 self.assertEqual(0x0FF00000, rotate_right(0xFF, 12))
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents:
diff changeset
12
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents:
diff changeset
13 def testLeftRotation(self):
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents:
diff changeset
14 self.assertEqual(0x0000FF00, rotate_left(0xFF, 8))
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents:
diff changeset
15 self.assertEqual(0x001FE000, rotate_left(0xFF, 13))
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents:
diff changeset
16
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents:
diff changeset
17
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents:
diff changeset
18 if __name__ == '__main__':
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents:
diff changeset
19 unittest.main()
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents:
diff changeset
20 sys.exit()