示例#1
0
 def test_load(self):
     s = String()
     s.name = 'x'
     o = Object()
     buf = b'\x00\x00\x00\x02ef'
     self.assertEqual(6, s.load(o, buf))
     self.assertEqual('ef', o.x)
示例#2
0
 def test_store(self):
     s = String()
     s.name = 'x'
     o = Object()
     o.x = 'abc'
     buf = s.store(o)
     self.assertEqual(b'\x00\x00\x00\x03abc', buf)
示例#3
0
 def test_load(self):
     s = String()
     s.name = 'x'
     o = Object()
     buf = b'\x00\x00\x00\x02ef'
     self.assertEqual(6, s.load(o, buf))
     self.assertEqual('ef', o.x)
示例#4
0
 def test_store(self):
     s = String()
     s.name = 'x'
     o = Object()
     o.x = 'abc'
     buf = s.store(o)
     self.assertEqual(b'\x00\x00\x00\x03abc', buf)
示例#5
0
 def test_type(self):
     s = String()
     s.name = 'x'
     with self.assertRaises(TypeError):
         s.type_check(123)
示例#6
0
 def test_type(self):
     s = String()
     s.name = 'x'
     with self.assertRaises(TypeError):
         s.type_check(123)