Пример #1
0
    def test_multiple_bytes(self):
        #                                     llllllllmmmm
        out_bits = transport.be_from_le_bits("110110101110", 12)
        #                                     mmmmllllllll
        self.assertEqual(out_bits,          b"111011011010")

        #                                     llllllllmmmmmmmm
        out_bits = transport.be_from_le_bits("1010010110010110", 16)
        #                                     mmmmmmmmllllllll
        self.assertEqual(out_bits,          b"1001011010100101")

        #                                     llllllll........m
        out_bits = transport.be_from_le_bits("11010010110010110", 17)
        #                                     m........llllllll
        self.assertEqual(out_bits,          b"01100101111010010")

        #                                     llllllll........m
        out_bits = transport.be_from_le_bits("10100101100101101", 17)
        #                                     m........llllllll
        self.assertEqual(out_bits,          b"11001011010100101")
Пример #2
0
    def test_multiple_bytes(self):
        #                                     llllllllmmmm
        out_bits = transport.be_from_le_bits("110110101110", 12)
        #                                     mmmmllllllll
        self.assertEqual(out_bits, "111011011010")

        #                                     llllllllmmmmmmmm
        out_bits = transport.be_from_le_bits("1010010110010110", 16)
        #                                     mmmmmmmmllllllll
        self.assertEqual(out_bits, "1001011010100101")

        #                                     llllllll........m
        out_bits = transport.be_from_le_bits("11010010110010110", 17)
        #                                     m........llllllll
        self.assertEqual(out_bits, "01100101111010010")

        #                                     llllllll........m
        out_bits = transport.be_from_le_bits("10100101100101101", 17)
        #                                     m........llllllll
        self.assertEqual(out_bits, "11001011010100101")
Пример #3
0
 def test_single_byte(self):
     for bits in ("10010110", "10100101", "00000000"):
         out_bits = transport.be_from_le_bits(bits, 8)
         self.assertEqual(out_bits, bits)
Пример #4
0
 def test_partial_byte(self):
     for bits in ("0", "1", "100", "001", "1001", "01001", "001001",
                  "1001001"):
         out_bits = transport.be_from_le_bits(bits, len(bits))
         self.assertEqual(out_bits, bits)
Пример #5
0
 def test_single_byte(self):
     for bits in ("10010110", "10100101", "00000000"):
         out_bits = transport.be_from_le_bits(bits, 8)
         self.assertEqual(out_bits, bits)
Пример #6
0
 def test_partial_byte(self):
     for bits in ("0", "1", "100", "001", "1001", "01001", "001001",
                  "1001001"):
         out_bits = transport.be_from_le_bits(bits, len(bits))
         self.assertEqual(out_bits, bits)