MCPcopy Create free account
hub / github.com/driangle/taskmd / TestCalculateSimilarity

Function TestCalculateSimilarity

apps/cli/internal/cli/get_test.go:430–451  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

428}
429
430func 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
453func TestLevenshtein(t *testing.T) {
454 tests := []struct {

Callers

nothing calls this directly

Calls 1

calculateSimilarityFunction · 0.85

Tested by

no test coverage detected