from krrkt.engine.splitter import split_text

class TestSplitText:
    def test_single_sentence(self):
        result = split_text("Привет мир.")
        assert len(result) == 1
        assert result[0]["text"] == "Привет мир."

    def test_two_sentences(self):
        result = split_text("Первое предложение. Второе предложение.")
        assert len(result) == 2

    def test_question_and_exclamation(self):
        result = split_text("Как дела? Отлично! Спасибо.")
        assert len(result) == 3

    def test_preserves_positions(self):
        text = "Первое. Второе."
        result = split_text(text)
        for chunk in result:
            assert text[chunk["start"]:chunk["end"]] == chunk["text"]

    def test_empty_text(self):
        assert split_text("") == []

    def test_whitespace_only(self):
        assert split_text("   ") == []

    def test_no_punctuation(self):
        result = split_text("Текст без точки")
        assert len(result) == 1

    def test_newlines_split(self):
        result = split_text("Первое.\nВторое.")
        assert len(result) == 2

    def test_positions_cover_full_text(self):
        text = "Первое. Второе. Третье."
        result = split_text(text)
        assert result[0]["start"] == 0
        assert result[-1]["end"] == len(text)
