import unittest from tudelft.utilities.tools.enum import enumValues, enumToString,enum from tudelft.utilities.tools.calc import truncate class CalcTest(unittest.TestCase): def testNumbers(self): self.assertEqual(0, truncate(0,8)) self.assertEqual(2, truncate(2,8)) self.assertEqual(127, truncate(127,8)) self.assertEqual(-128, truncate(128,8)) self.assertEqual(-1, truncate(255,8)) self.assertEqual(-1, truncate(-1,8)) self.assertEqual(112, truncate(112,8)) self.assertEqual(-127, truncate(-127,8)) self.assertEqual(-128, truncate(-128,8)) self.assertEqual(127, truncate(-129,8)) self.assertEqual(32000, truncate(32000,16)) self.assertEqual(32767, truncate(32767,16)) self.assertEqual(-1, truncate(65535,16)) self.assertEqual(-1, truncate(-1,16))