(t *testing.T)
| 428 | } |
| 429 | |
| 430 | func TestCalculateSimilarity(t *testing.T) { |
| 431 | tests := []struct { |
| 432 | query string |
| 433 | target string |
| 434 | minScore float64 |
| 435 | maxScore float64 |
| 436 | }{ |
| 437 | {"auth", "Implement authentication", 0.7, 1.0}, // substring |
| 438 | {"setup", "Setup project", 0.7, 1.0}, // substring |
| 439 | {"setup project", "Setup project", 1.0, 1.0}, // exact |
| 440 | {"zzzzz", "Setup project", 0.0, 0.3}, // no relation |
| 441 | {"seutp", "Setup project", 0.3, 0.8}, // typo |
| 442 | } |
| 443 | |
| 444 | for _, tt := range tests { |
| 445 | score := calculateSimilarity(tt.query, tt.target) |
| 446 | if score < tt.minScore || score > tt.maxScore { |
| 447 | t.Errorf("calculateSimilarity(%q, %q) = %.2f, expected [%.2f, %.2f]", |
| 448 | tt.query, tt.target, score, tt.minScore, tt.maxScore) |
| 449 | } |
| 450 | } |
| 451 | } |
| 452 | |
| 453 | func TestLevenshtein(t *testing.T) { |
| 454 | tests := []struct { |
nothing calls this directly
no test coverage detected