Пример #1
1
    def test_processor_hexadecimal(self):
        f = ssterm.output_processor_hexadecimal()

        self.assertEqual(f(""), "")
        self.assertEqual(f("\xaa\xbb\xcc\xdd"), "aa bb cc dd ")
        self.assertEqual(f("\xee\xff\x00\x11"), "ee ff 00 11  ")
        self.assertEqual(f("\xaa\xbb\xcc\xdd"), "aa bb cc dd ")
        self.assertEqual(f("\xee\xff\x00\x11"), "ee ff 00 11" + os.linesep)
        self.assertEqual(f("\x0a\x0a\x0a\x0a"), "0a 0a 0a 0a ")

        if len(os.linesep) == 1:
            f = ssterm.output_processor_hexadecimal(interpret_newlines=True)

            self.assertEqual(f(""), "")
            self.assertEqual(f("\xaa" + os.linesep + "\xbb"), "aa " + ("%02x " % ord(os.linesep)) + os.linesep + "bb ")

        f = ssterm.output_processor_hexadecimal([ord('A'), ord('B')])

        self.assertEqual(f(""), "")
        self.assertEqual(f("\xaa\xbb\xcc\xdd"), "aa bb cc dd ")
        self.assertEqual(f("AB\xee\xff"), ssterm.Color_Codes[0] + "41" + ssterm.Color_Code_Reset + " " + ssterm.Color_Codes[1] + "42" + ssterm.Color_Code_Reset + " ee ff  ")
        self.assertEqual(f("\xee\xff\x00\x11\xee\xff\x00\x11"), "ee ff 00 11 ee ff 00 11" + os.linesep)
Пример #2
0
    def test_processor_hexadecimal(self):
        f = ssterm.output_processor_hexadecimal()

        self.assertEqual(f(b""), b"")
        self.assertEqual(f(b"\xaa\xbb\xcc\xdd"), b"aa bb cc dd ")
        self.assertEqual(f(b"\xee\xff\x00\x11"), b"ee ff 00 11  ")
        self.assertEqual(f(b"\xaa\xbb\xcc\xdd"), b"aa bb cc dd ")
        self.assertEqual(f(b"\xee\xff\x00\x11"),
                         b"ee ff 00 11" + os.linesep.encode())
        self.assertEqual(f(b"\x0a\x0a\x0a\x0a"), b"0a 0a 0a 0a ")

        if len(os.linesep.encode()) == 1:
            f = ssterm.output_processor_hexadecimal(interpret_newlines=True)

            self.assertEqual(f(b""), b"")
            self.assertEqual(
                f(b"\xaa" + os.linesep.encode() + b"\xbb"),
                b"aa " + ("%02x " % ord(os.linesep.encode())).encode() +
                os.linesep.encode() + b"bb ")

        f = ssterm.output_processor_hexadecimal(b"AB")

        self.assertEqual(f(b""), b"")
        self.assertEqual(f(b"\xaa\xbb\xcc\xdd"), b"aa bb cc dd ")
        self.assertEqual(
            f(b"AB\xee\xff"), ssterm.Color_Codes[0] + b"41" +
            ssterm.Color_Code_Reset + b" " + ssterm.Color_Codes[1] + b"42" +
            ssterm.Color_Code_Reset + b" ee ff  ")
        self.assertEqual(f(b"\xee\xff\x00\x11\xee\xff\x00\x11"),
                         b"ee ff 00 11 ee ff 00 11" + os.linesep.encode())
Пример #3
0
    def test_processor_hexadecimal(self):
        f = ssterm.output_processor_hexadecimal()

        self.assertEqual(f(b""), b"")
        self.assertEqual(f(b"\xaa\xbb\xcc\xdd"), b"aa bb cc dd ")
        self.assertEqual(f(b"\xee\xff\x00\x11"), b"ee ff 00 11  ")
        self.assertEqual(f(b"\xaa\xbb\xcc\xdd"), b"aa bb cc dd ")
        self.assertEqual(f(b"\xee\xff\x00\x11"), b"ee ff 00 11" + os.linesep.encode())
        self.assertEqual(f(b"\x0a\x0a\x0a\x0a"), b"0a 0a 0a 0a ")

        if len(os.linesep.encode()) == 1:
            f = ssterm.output_processor_hexadecimal(interpret_newlines=True)

            self.assertEqual(f(b""), b"")
            self.assertEqual(f(b"\xaa" + os.linesep.encode() + b"\xbb"), b"aa " + ("%02x " % ord(os.linesep.encode())).encode() + os.linesep.encode() + b"bb ")

        f = ssterm.output_processor_hexadecimal(b"AB")

        self.assertEqual(f(b""), b"")
        self.assertEqual(f(b"\xaa\xbb\xcc\xdd"), b"aa bb cc dd ")
        self.assertEqual(f(b"AB\xee\xff"), ssterm.Color_Codes[0] + b"41" + ssterm.Color_Code_Reset + b" " + ssterm.Color_Codes[1] + b"42" + ssterm.Color_Code_Reset + b" ee ff  ")
        self.assertEqual(f(b"\xee\xff\x00\x11\xee\xff\x00\x11"), b"ee ff 00 11 ee ff 00 11" + os.linesep.encode())