Exemplo n.º 1
0
 def test_concat_bits_empty(self):
     # Empty both sides.
     self.assertEqual(0, bit_helpers.concat_bits(0, 0, 0, 0))
     # Empty RHS.
     self.assertEqual(3, bit_helpers.concat_bits(3, 2, 0, 0))
     # Empty LHS.
     self.assertEqual(3, bit_helpers.concat_bits(0, 0, 3, 2))
Exemplo n.º 2
0
 def test_concat_bits(self):
     x = 0b10
     y = 0b011
     self.assertEqual(0b10011, bit_helpers.concat_bits(x, 2, y, 3))
Exemplo n.º 3
0
 def concat(self, other: 'Bits') -> 'Bits':
   """Returns a value that concatenates bits in self with bits in other."""
   return Bits(
       self.bit_count + other.bit_count,
       concat_bits(self.value, self.bit_count, other.value, other.bit_count))