# -*- coding: utf-8 -*-

from __future__ import unicode_literals
import codecs
from unittest import TestCase

from box.util.rotunicode import RotUnicode


class RotUnicodeTest(TestCase):

    codecs.register(RotUnicode.search_function)

    def test_encoder_is_searchable_by_name(self):
        encoder = codecs.getencoder('rotunicode')
        self.assertIsNotNone(encoder)

    def test_decoder_is_searchable_by_name(self):
        decoder = codecs.getdecoder('rotunicode')
        self.assertIsNotNone(decoder)

    def test_encoding_zero_length_byte_string_returns_zero_length_unicode_string(self):
        self.assertEqual(
            '',
            b''.encode('rotunicode'),
        )

    def test_decoding_zero_length_byte_string_returns_zero_length_unicode_string(self):
        self.assertEqual(
            '',
            b''.decode('rotunicode'),
        )

    def test_encoding_zero_length_unicode_string_returns_zero_length_unicode_string(self):
        self.assertEqual(
            '',
            ''.encode('rotunicode'),
        )

    def test_decoding_zero_length_unicode_string_returns_zero_length_unicode_string(self):
        self.assertEqual(
            '',
            ''.decode('rotunicode'),
        )

    def test_encoding_byte_string_returns_encoded_unicode_string(self):
        self.assertEqual(
            'Ĥȅľľő Ŵőŕľď!',
            b'Hello World!'.encode('rotunicode'),
        )

    def test_decoding_byte_string_returns_decoded_unicode_string(self):
        self.assertEqual(
            'Hello World!',
            b'Ĥȅľľő Ŵőŕľď!'.decode('rotunicode'),
        )

    def test_encoding_unicode_string_returns_encoded_unicode_string(self):
        self.assertEqual(
            'Ĥȅľľő Ŵőŕľď!',
            'Hello World!'.encode('rotunicode'),
        )

    def test_decoding_unicode_string_returns_decoded_unicode_string(self):
        self.assertEqual(
            'Hello World!',
            'Ĥȅľľő Ŵőŕľď!'.decode('rotunicode'),
        )

@@ -1959,28 +1959,964 @@
 de('rotunicode'),%0A        )%0A
+%0A    def test_encoding_byte_string_with_unsupported_chars_returns_unicode_string_with_unsupported_chars_unchanged(self):%0A        self.assertEqual(%0A            '%E0%A4%B9%E0%A5%87%E0%A4%B2%E0%A5%8B %C5%B4%C5%91%C5%95%C4%BE%C4%8F!',%0A            b'%E0%A4%B9%E0%A5%87%E0%A4%B2%E0%A5%8B World!'.encode('rotunicode'),%0A        )%0A%0A    def test_encoding_unicode_string_with_unsupported_chars_returns_unicode_string_with_unsupported_chars_unchanged(self):%0A        self.assertEqual(%0A            '%E0%A4%B9%E0%A5%87%E0%A4%B2%E0%A5%8B %C5%B4%C5%91%C5%95%C4%BE%C4%8F!',%0A            '%E0%A4%B9%E0%A5%87%E0%A4%B2%E0%A5%8B World!'.encode('rotunicode'),%0A        )%0A%0A    def test_decoding_byte_string_with_unsupported_chars_returns_unicode_string_with_unsupported_chars_unchanged(self):%0A        self.assertEqual(%0A            '%E0%A4%B9%E0%A5%87%E0%A4%B2%E0%A5%8B World!',%0A            b'%E0%A4%B9%E0%A5%87%E0%A4%B2%E0%A5%8B %C5%B4%C5%91%C5%95%C4%BE%C4%8F!'.decode('rotunicode'),%0A        )%0A%0A    def test_decoding_unicode_string_with_unsupported_chars_returns_unicode_string_with_unsupported_chars_unchanged(self):%0A        self.assertEqual(%0A            '%E0%A4%B9%E0%A5%87%E0%A4%B2%E0%A5%8B World!',%0A            '%E0%A4%B9%E0%A5%87%E0%A4%B2%E0%A5%8B %C5%B4%C5%91%C5%95%C4%BE%C4%8F!'.decode('rotunicode'),%0A        )%0A

Add more tests.