from evalkit.metrics._text import format_context, normalize_text


class TestNormalizeText:
    def test_lowercases(self):
        assert normalize_text("HELLO") == "hello"

    def test_strips_whitespace(self):
        assert normalize_text("  hello  ") == "hello"

    def test_removes_punctuation(self):
        assert normalize_text("hello, world!") == "hello world"

    def test_collapses_spaces(self):
        assert normalize_text("hello   world") == "hello world"

    def test_unicode_normalization(self):
        assert normalize_text("\u00e9") == normalize_text("e\u0301")


class TestFormatContext:
    def test_empty(self):
        assert format_context([]) == ""

    def test_single_chunk(self):
        assert format_context(["chunk1"]) == "[1] chunk1"

    def test_multiple_chunks(self):
        result = format_context(["a", "b", "c"])
        assert result == "[1] a\n[2] b\n[3] c"
