"""Tests for DDEX utilities.""" from soundrecording_utils.ddex.utils.control_chars import remove_control_chars class TestRemoveControlChars: """Tests for remove_control_chars function.""" def test_removes_null_character(self) -> None: """Test that null characters are removed.""" result = remove_control_chars('Hello\x00World') assert result == 'HelloWorld' def test_removes_bell_character(self) -> None: """Test that bell characters are removed.""" result = remove_control_chars('Hello\x07World') assert result == 'HelloWorld' def test_removes_backspace(self) -> None: """Test that backspace characters are removed.""" result = remove_control_chars('Hello\x08World') assert result == 'HelloWorld' def test_preserves_tab(self) -> None: """Test that tab characters are preserved.""" result = remove_control_chars('Hello\tWorld') assert result == 'Hello\tWorld' def test_preserves_newline(self) -> None: """Test that newline characters are preserved.""" result = remove_control_chars('Hello\nWorld') assert result == 'Hello\nWorld' def test_preserves_carriage_return(self) -> None: """Test that carriage return characters are preserved.""" result = remove_control_chars('Hello\rWorld') assert result == 'Hello\rWorld' def test_strips_whitespace(self) -> None: """Test that leading/trailing whitespace is stripped.""" result = remove_control_chars(' Hello World ') assert result == 'Hello World' def test_handles_empty_string(self) -> None: """Test that empty strings are handled correctly.""" result = remove_control_chars('') assert result == '' def test_removes_multiple_control_chars(self) -> None: """Test removal of multiple control characters.""" result = remove_control_chars('\x00\x01\x02Hello\x03\x04\x05World\x06\x07') assert result == 'HelloWorld'