Align validator identity and span domain checks
This commit is contained in:
@@ -139,6 +139,30 @@ func TestPreviewProposalForSegmentAllowsEmptyCorrectedTextWhenSegmentRemainsNonE
|
||||
}
|
||||
}
|
||||
|
||||
func TestPreviewProposalForSegmentWhitespaceSpan(t *testing.T) {
|
||||
proposal := CorrectionProposal{TargetSegmentID: 8, OriginalText: " ", CorrectedText: " ", Confidence: 0.9}
|
||||
unique := PreviewProposalForSegment(&schema.Segment{ID: 8, Text: "hello world"}, proposal, ReplacementPolicyRequireUnique)
|
||||
if !unique.Applicable || unique.CorrectedSegmentText != "hello world" || unique.ReplacementCount != 1 {
|
||||
t.Fatalf("unexpected spacing preview: %+v", unique)
|
||||
}
|
||||
segment := &schema.Segment{ID: 8, Text: "a b c"}
|
||||
ambiguous := PreviewProposalForSegment(segment, proposal, ReplacementPolicyRequireUnique)
|
||||
if ambiguous.Applicable || ambiguous.SkipReason != SkipReasonAmbiguousOriginal {
|
||||
t.Fatalf("expected ambiguity under require_unique: %+v", ambiguous)
|
||||
}
|
||||
all := PreviewProposalForSegment(segment, proposal, ReplacementPolicyReplaceAll)
|
||||
if !all.Applicable || all.CorrectedSegmentText != "a b c" || all.ReplacementCount != 2 {
|
||||
t.Fatalf("expected replace_all to correct both spans: %+v", all)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPreviewProposalForSegmentRejectsEmptyOriginalText(t *testing.T) {
|
||||
preview := PreviewProposalForSegment(&schema.Segment{ID: 8, Text: "hello"}, CorrectionProposal{TargetSegmentID: 8, OriginalText: "", CorrectedText: "x", Confidence: 0.9}, ReplacementPolicyRequireUnique)
|
||||
if preview.Applicable || preview.SkipReason != SkipReasonInvalidProposal {
|
||||
t.Fatalf("expected invalid empty original: %+v", preview)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPreviewProposalForSegmentRejectsEmptyResultingSegment(t *testing.T) {
|
||||
segment := &schema.Segment{ID: 8, Text: "uh"}
|
||||
proposal := CorrectionProposal{
|
||||
|
||||
Reference in New Issue
Block a user