You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
877 B
Go
30 lines
877 B
Go
package question
|
|
|
|
// Tests for domain-level fuzzy answer matching threshold behavior and edge cases.
|
|
|
|
import "testing"
|
|
|
|
// TestIsAnswerMatch ensures is answer match behavior is handled correctly.
|
|
func TestIsAnswerMatch(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
expected string
|
|
provided string
|
|
wantMatch bool
|
|
}{
|
|
{name: "exact", expected: "Paris", provided: "Paris", wantMatch: true},
|
|
{name: "near_match", expected: "Leonardo da Vinci", provided: "Leonardo da vinci", wantMatch: true},
|
|
{name: "below_threshold", expected: "Jupiter", provided: "Mars", wantMatch: false},
|
|
{name: "empty", expected: "", provided: "", wantMatch: true},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got, _ := IsAnswerMatch(tt.expected, tt.provided)
|
|
if got != tt.wantMatch {
|
|
t.Fatalf("got %v want %v", got, tt.wantMatch)
|
|
}
|
|
})
|
|
}
|
|
}
|