feat: add EntryWarnings and VocabularyBuilder

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-01 15:11:48 +02:00
co-authored by Claude Sonnet 5.5
parent 93bf59e090
commit fe24292279
4 changed files with 165 additions and 0 deletions
@@ -0,0 +1,19 @@
import Testing
@testable import SstData
struct VocabularyBuilderTests {
@Test func termsComeFirstThenCorrectionTargetsWithoutDuplicates() {
let entries = [pair("cloud code", "Claude Code"), term("Anthropic"), term("anthropic"), pair("versel", "Vercel"), term("Supabase")]
#expect(VocabularyBuilder.build(from: entries) == ["Anthropic", "Supabase", "Claude Code", "Vercel"])
}
@Test func listIsCapped() {
let entries = (1...40).map { term("Woord\($0)") }
#expect(VocabularyBuilder.build(from: entries).count == 24)
#expect(VocabularyBuilder.build(from: entries, maxTerms: 5).count == 5)
}
@Test func emptyDictionaryGivesNoVocabulary() {
#expect(VocabularyBuilder.build(from: []).isEmpty)
}
}