"""Tests for CharacterRemover.remove_control_characters."""

from __future__ import annotations

from remove_control_chars import CharacterRemover


class TestRemoveControlCharacters:
    """Tests for CharacterRemover.remove_control_characters."""

    def test_empty_string(self) -> None:
        """Empty string returns empty string."""
        remover = CharacterRemover()
        assert "" == remover.remove_control_characters("")

    def test_none_input(self) -> None:
        """None input returns empty string."""
        remover = CharacterRemover()
        assert "" == remover.remove_control_characters(None)

    def test_no_control_chars(self) -> None:
        """String without control chars is unchanged."""
        remover = CharacterRemover()
        assert "hello world" == remover.remove_control_characters(
            "hello world"
        )

    def test_null_byte(self) -> None:
        """Null byte is removed."""
        remover = CharacterRemover()
        assert "ab" == remover.remove_control_characters("a\x00b")

    def test_newline_and_tab(self) -> None:
        """Newline and tab are removed."""
        remover = CharacterRemover()
        assert "ab" == remover.remove_control_characters("a\n\tb")

    def test_delete_char(self) -> None:
        """DEL character (0x7F) is removed."""
        remover = CharacterRemover()
        assert "ab" == remover.remove_control_characters("a\x7fb")

    def test_mixed_control_chars(self) -> None:
        """Multiple control characters removed at once."""
        remover = CharacterRemover()
        result = remover.remove_control_characters(
            "\x01hello\x02 \x03world\x7f"
        )
        assert "hello world" == result

    def test_only_control_chars(self) -> None:
        """String of only control chars returns empty."""
        remover = CharacterRemover()
        assert "" == remover.remove_control_characters(
            "\x00\x01\x02\x1f\x7f"
        )

    def test_printable_preserved(self) -> None:
        """Printable ASCII and unicode are preserved."""
        remover = CharacterRemover()
        text = "Hello, World! 123 @#$ café"
        assert text == remover.remove_control_characters(text)
