Skip to content

Commit 1ccae00

Browse files
feat: add missing edge cases for remove_non_alphanumeric (#242)
* 🧪 Add missing edge cases for remove_non_alphanumeric Co-authored-by: n24q02m <135627235+n24q02m@users.noreply.github.com> * 🧪 Add missing edge cases for remove_non_alphanumeric Co-authored-by: n24q02m <135627235+n24q02m@users.noreply.github.com> --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
1 parent bc775ff commit 1ccae00

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

tests/test_utils.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,3 +293,18 @@ def test_numbers_are_kept(self) -> None:
293293
def test_multiple_consecutive_punctuation(self) -> None:
294294
"""Multiple punctuations each get replaced with a space."""
295295
assert remove_non_alphanumeric("hello... world!!!") == "hello world "
296+
297+
def test_only_non_alphanumeric(self) -> None:
298+
"""Strings with only non-alphanumeric characters should become spaces."""
299+
assert remove_non_alphanumeric("!@#$%^&*()") == " "
300+
301+
def test_whitespace_preservation(self) -> None:
302+
"""Newlines, tabs, and other whitespace should be preserved (\\s)."""
303+
assert remove_non_alphanumeric("hello\nworld\t123") == "hello\nworld\t123"
304+
305+
def test_math_and_currency_symbols(self) -> None:
306+
"""Math and currency symbols should be removed."""
307+
assert (
308+
remove_non_alphanumeric("price: $100 + €50 = £150 ± ∞")
309+
== "price 100 50 150 "
310+
)

0 commit comments

Comments
 (0)