Exemple #1
0
 def test_parser(self):
     self.assertEqual(expand("D2FE28"), "110100101111111000101000")
     self.assertEqual(
         expand("38006F45291200"),
         "00111000000000000110111101000101001010010001001000000000")
     self.assertEqual(
         expand("EE00D40C823060"),
         "11101110000000001101010000001100100000100011000001100000")
Exemple #2
0
    def test_sample_one(self):
        bin_code = expand("8A004A801A8002F478")
        packets = read_packets(bin_code)
        self.assertEqual(len(packets), 1)
        self.assertNotEqual(packets[0].packet_type, PacketType.LITERAL)
        self.assertEqual(packets[0].packet_version, 4)
        self.assertEqual(len(packets[0].packets), 1)
        self.assertNotEqual(packets[0].packets[0].packet_type,
                            PacketType.LITERAL)
        self.assertEqual(packets[0].packets[0].packet_version, 1)
        self.assertEqual(len(packets[0].packets[0].packets), 1)
        self.assertNotEqual(packets[0].packets[0].packets[0].packet_type,
                            PacketType.LITERAL)
        self.assertEqual(packets[0].packets[0].packets[0].packet_version, 5)
        self.assertEqual(
            packets[0].packets[0].packets[0].packets[0].packet_type,
            PacketType.LITERAL)
        self.assertEqual(
            packets[0].packets[0].packets[0].packets[0].packet_version, 6)

        self.assertEqual(check_sum(packets[0]), 16)
Exemple #3
0
 def test_sum(self):
     bin_code = expand("C200B40A82")
     packets = read_packets(bin_code)
     self.assertEqual(len(packets), 1)
     self.assertEqual(get_value(packets[0]), 3)
Exemple #4
0
 def test_literal(self):
     bin_code = expand("D2FE28")
     packets = read_packets(bin_code)
     self.assertEqual(len(packets), 1)
     self.assertEqual(get_value(packets[0]), 2021)
Exemple #5
0
 def test_sample_three(self):
     bin_code = expand("C0015000016115A2E0802F182340")
     packets = read_packets(bin_code)
     self.assertEqual(len(packets), 1)
     self.assertEqual(check_sum(packets[0]), 23)
Exemple #6
0
 def test_sample_two(self):
     bin_code = expand("620080001611562C8802118E34")
     packets = read_packets(bin_code)
     self.assertEqual(len(packets), 1)
     self.assertEqual(check_sum(packets[0]), 12)