Ejemplo n.º 1
0
 def test_store(self):
     sn = SignedNumber(2)
     sn.name = 'x'
     o = Object()
     o.x = 123
     buf = sn.store(o)
     self.assertEqual(b'\x00\x7b', buf)
Ejemplo n.º 2
0
 def test_type2(self):
     sn = SignedNumber(4)
     sn.name = 'x'
     self.assertEqual(2147483647, sn.max_val)
     self.assertEqual(-2147483648, sn.min_val)
     with self.assertRaises(ValueError):
         sn.type_check(2147483648)
Ejemplo n.º 3
0
 def test_load(self):
     sn = SignedNumber(8)
     sn.name = 'x'
     o = Object()
     buf = b'\xff\xff\xff\xff\xff\xff\xff\x85'
     self.assertEqual(8, sn.load(o, buf))
     self.assertEqual(-123, o.x)
Ejemplo n.º 4
0
 def test_store(self):
     sn = SignedNumber(2)
     sn.name = 'x'
     o = Object()
     o.x = 123
     buf = sn.store(o)
     self.assertEqual(b'\x00\x7b', buf)
Ejemplo n.º 5
0
 def test_load(self):
     sn = SignedNumber(8)
     sn.name = 'x'
     o = Object()
     buf = b'\xff\xff\xff\xff\xff\xff\xff\x85'
     self.assertEqual(8, sn.load(o, buf))
     self.assertEqual(-123, o.x)
Ejemplo n.º 6
0
 def test_type2(self):
     sn = SignedNumber(4)
     sn.name = 'x'
     self.assertEqual(2147483647, sn.max_val)
     self.assertEqual(-2147483648, sn.min_val)
     with self.assertRaises(ValueError):
         sn.type_check(2147483648)
Ejemplo n.º 7
0
 def test_type(self):
     sn = SignedNumber(1)
     sn.name = 'x'
     self.assertEqual(127, sn.max_val)
     self.assertEqual(-128, sn.min_val)
     with self.assertRaises(TypeError):
         sn.type_check('123')
     with self.assertRaises(ValueError):
         sn.type_check(200)
Ejemplo n.º 8
0
 def test_type(self):
     sn = SignedNumber(1)
     sn.name = 'x'
     self.assertEqual(127, sn.max_val)
     self.assertEqual(-128, sn.min_val)
     with self.assertRaises(TypeError):
         sn.type_check('123')
     with self.assertRaises(ValueError):
         sn.type_check(200)