Пример #1
0
def test_build_operator_packet_by_length():
    stream = parse_input_data(TEST_INPUT_OPERATOR_1)
    packet = PacketFactory.build(stream)
    assert isinstance(packet, OperatorPacket)
    assert len(packet.subpackets) == 2
    assert packet.subpackets[0].value == 10
    assert packet.subpackets[1].value == 20
Пример #2
0
def test_version_sum_4():
    stream = parse_input_data(TEST_INPUT_SUM_4)
    packet = PacketFactory.build(stream)
    total = packet.version_sum()
    assert total == 31
Пример #3
0
def test_build_literal_packet():
    stream = parse_input_data(TEST_INPUT_LITERAL)
    packet = PacketFactory.build(stream)
    assert isinstance(packet, LiteralPacket)
    assert packet.value == 2021