def test_read_write_primitive(self): int_values = [-32769, -32768, -128, -127, -8, -7, 0, 7, 8, 127, 128, 32768, 32769] bit_stream = BitStream() for i in int_values: bit_stream.write_int(i) bit_stream.write_long(i) bit_stream.write_str(str(i)) bit_stream.cursor = 0 for i in int_values: self.assertEqual(bit_stream.read_int(), i) self.assertEqual(bit_stream.read_long(), i) self.assertEqual(bit_stream.read_str(), str(i))
def test_read_str(self): bit_stream = BitStream(AMAZING_WORLD[1:-1]) bit_stream.cursor = 52 # client_name result = bit_stream.read_str() self.assertEqual(result, 'AmazingWorld')
def test_read_write_datetime(self): value = dt.datetime(2020, 3, 27, 19, 30, 42) bit_stream = BitStream() bit_stream.write_dt(value) bit_stream.cursor = 0 self.assertEqual(str(bit_stream.read_dt()), str(value))