test: tokenizer cached encoding path coverage

This commit is contained in:
2026-04-05 21:53:05 +02:00
parent f7782215dc
commit eab5f26407

View File

@@ -45,3 +45,15 @@ func TestTokenizer_CodeCountsReasonably(t *testing.T) {
t.Errorf("code token count out of expected range: %d", n)
}
}
func TestTokenizer_CachedLoadReturnsSameResult(t *testing.T) {
tok := tokenizer.New("cl100k_base")
first := tok.Count("hello world")
second := tok.Count("hello world")
if first != second {
t.Errorf("cached result differs: first=%d second=%d", first, second)
}
if first <= 0 {
t.Errorf("expected positive token count, got %d", first)
}
}