def test_bit_sum_one_char(self): self.assertEquals(fut.bit_sum(chr(0x00)), 0) self.assertEquals(fut.bit_sum(chr(0x03)), 2) self.assertEquals(fut.bit_sum(chr(0x11)), 2) self.assertEquals(fut.bit_sum(chr(0xFF)), 8) self.assertEquals(fut.bit_sum(chr(0xA5)), 4) # Test same char twice to force use of dictionary self.assertEquals(fut.bit_sum(chr(0xA5)), 4) self.assertEquals(fut.bit_sum('A'), 2) self.assertEquals(fut.bit_sum('A'), 2) self.assertEquals(fut.bit_sum('z'), 5)
def test_bit_sum_one_char(self): self.assertEquals(fut.bit_sum(chr(0x00)), 0) self.assertEquals(fut.bit_sum(chr(0x03)), 2) self.assertEquals(fut.bit_sum(chr(0x11)), 2) self.assertEquals(fut.bit_sum(chr(0xFF)), 8) self.assertEquals(fut.bit_sum(chr(0xA5)), 4) # Test same char twice to force use of dictionary self.assertEquals(fut.bit_sum(chr(0xA5)), 4) self.assertEquals(fut.bit_sum('A'), 2) self.assertEquals(fut.bit_sum('A'), 2) self.assertEquals(fut.bit_sum('z'), 5)
def test_bit_sum_many_chars(self): self.assertEquals(fut.bit_sum('ABC'), 7) self.assertEquals(fut.bit_sum('Hello, World'), 46) self.assertEquals(fut.bit_sum('0123456789'), 35)
def test_bit_sum_many_chars(self): self.assertEquals(fut.bit_sum('ABC'), 7) self.assertEquals(fut.bit_sum('Hello, World'), 46) self.assertEquals(fut.bit_sum('0123456789'), 35)
def filter_data(self, packet): self.bit_sum += fut.bit_sum(packet.data) self.byte_count += packet.data_length self.send_on(packet)