source: utilitiespy/test/tools/calctest.py@ 1293

Last change on this file since 1293 was 1255, checked in by wouter, 4 weeks ago

#386 added Keys() class that replaces dict.keys() function

File size: 818 bytes
RevLine 
[1206]1import unittest
2
3from tudelft.utilities.tools.enum import enumValues, enumToString,enum
[1207]4from tudelft.utilities.tools.calc import truncate
[1206]5
6class CalcTest(unittest.TestCase):
7
8 def testNumbers(self):
[1207]9 self.assertEqual(0, truncate(0,8))
10 self.assertEqual(2, truncate(2,8))
11 self.assertEqual(127, truncate(127,8))
12 self.assertEqual(-128, truncate(128,8))
13 self.assertEqual(-1, truncate(255,8))
14 self.assertEqual(-1, truncate(-1,8))
15 self.assertEqual(112, truncate(112,8))
16 self.assertEqual(-127, truncate(-127,8))
17 self.assertEqual(-128, truncate(-128,8))
18 self.assertEqual(127, truncate(-129,8))
19
20 self.assertEqual(32000, truncate(32000,16))
21 self.assertEqual(32767, truncate(32767,16))
22 self.assertEqual(-1, truncate(65535,16))
23 self.assertEqual(-1, truncate(-1,16))
[1255]24
Note: See TracBrowser for help on using the repository browser.