def test_create_atom_long(self): ''' Test ``bbc.create_atom()`` with gaps that can be encoded in two bytes after the header. ''' self.assertEqual(bbc.create_atom(0b10000000, False, 0, BitArray()), BitArray(bin='11100000' '10000000' '10000000')) self.assertEqual(bbc.create_atom(all_bits(15), False, 0, BitArray()), BitArray(bin='11100000' '11111111' '11111111'))
def test_create_atom_lits(self): ''' Test ``bbc.create_atom()`` with literal bytes. ''' lits = BitArray(bin='110101100010110101011100') self.assertEqual(bbc.create_atom(0b000, False, 3, lits), '0b00000011' + lits) lits = lits[bits_per_byte:] self.assertEqual(bbc.create_atom(0b1111, False, 2, lits), '0b1110001000001111' + lits) lits = lits[bits_per_byte:] self.assertEqual(bbc.create_atom(all_bits(15), False, 1, lits), '0b111000011111111111111111' + lits)
def test_create_atom_dirty(self): ''' Test ``bbc.create_atom()`` with offset bytes. ''' self.assertEqual(bbc.create_atom(0b000, True, 0b0000, BitArray()), BitArray(bin='00010000')) self.assertEqual(bbc.create_atom(0b001, True, 0b0001, BitArray()), BitArray(bin='00110001')) self.assertEqual(bbc.create_atom(0b111, True, 0b1000, BitArray()), BitArray(bin='11111000' '00000111')) self.assertEqual(bbc.create_atom(0b10000000, True, 0b1010, BitArray()), BitArray(bin='11111010' '10000000' '10000000'))
def test_create_atom_mid(self): ''' Test ``bbc.create_atom()`` with gaps that can be encoded in one byte after the header. ''' self.assertEqual(bbc.create_atom(0b111, False, 0, BitArray()), BitArray(bin='11100000' '00000111')) self.assertEqual(bbc.create_atom(0b1000, False, 0, BitArray()), BitArray(bin='11100000' '00001000')) self.assertEqual(bbc.create_atom(0b1001, False, 0, BitArray()), BitArray(bin='11100000' '00001001')) self.assertEqual(bbc.create_atom(0b1111111, False, 0, BitArray()), BitArray(bin='11100000' '01111111'))
def test_create_atom_short(self): ''' Test ``bbc.create_atom()`` with gaps that can be encoded in the header. ''' self.assertEqual(bbc.create_atom(0b000, False, 0, BitArray()), BitArray(bin='00000000')) self.assertEqual(bbc.create_atom(0b001, False, 0, BitArray()), BitArray(bin='00100000')) self.assertEqual(bbc.create_atom(0b010, False, 0, BitArray()), BitArray(bin='01000000')) self.assertEqual(bbc.create_atom(0b011, False, 0, BitArray()), BitArray(bin='01100000')) self.assertEqual(bbc.create_atom(0b100, False, 0, BitArray()), BitArray(bin='10000000')) self.assertEqual(bbc.create_atom(0b101, False, 0, BitArray()), BitArray(bin='10100000')) self.assertEqual(bbc.create_atom(0b110, False, 0, BitArray()), BitArray(bin='11000000'))