import unittest

from linemode.drivers.star import StarPrinter


class TestStarPrinter(unittest.TestCase):
    def test_hello(self):
        printer = StarPrinter(None)

        program = printer.compile([
            ('select-bold'),
            ('write', "Hello World"),
            ('cancel-bold'),
        ])

        self.assertEqual(program, b'\x1b\x45Hello World\x1b\x46')

    def test_detect_charset(self):
        printer = StarPrinter(None)

        program = printer.compile([
            ('write', "ぐけげこごさざしじすずせぜそぞた"),
        ])

        self.assertEqual(
            program,
            b'\x1b\x1d\x74' + b'\x02' +
            "ぐけげこごさざしじすずせぜそぞた".encode('euc_jp')
        )

import unittest

from linemode.drivers.star import StarPrinter


class TestStarPrinter(unittest.TestCase):
    def test_hello(self):
        printer = StarPrinter(None)

        program = printer.compile([
            ('select-bold'),
            ('write', "Hello World"),
            ('cancel-bold'),
        ])

        self.assertEqual(program, b'\x1b\x45Hello World\x1b\x46')

    def test_detect_charset(self):
        printer = StarPrinter(None)

        # print some japanese (supported)
        program = printer.compile([
            ('write', "ぐけげこごさざしじすずせぜそぞた"),
        ])

        self.assertEqual(
            program,
            b'\x1b\x1d\x74' + b'\x02' +
            "ぐけげこごさざしじすずせぜそぞた".encode('euc_jp')
        )

    def test_fail_to_detect_charset(self):
        printer = StarPrinter(None)

        # print some samaritan (not supported)
        program = printer.compile([
            ('write', "ࠀࠁࠂࠃࠄࠅࠆࠇࠈࠉࠊࠋࠌࠍࠎ"),
        ])

        self.assertEqual(
            program,
            b"???????????????"
        )

add test for unsupported characters