17 lines
494 B
Python
17 lines
494 B
Python
import pytest
|
|
|
|
from app.engine.source_extraction import chunk_with_offsets
|
|
|
|
|
|
def test_chunk_offsets_and_overlap_are_exact():
|
|
text = "가" * 1200
|
|
chunks = list(chunk_with_offsets(text, size=500, stride=250))
|
|
assert chunks[0] == (0, 500, text[0:500])
|
|
assert chunks[1] == (250, 750, text[250:750])
|
|
assert chunks[-1][1] == len(text)
|
|
|
|
|
|
def test_chunk_parameters_must_be_positive():
|
|
with pytest.raises(ValueError):
|
|
list(chunk_with_offsets("본문", size=0, stride=1))
|