fix: address code review findings
- Strip standalone reissue keywords (remaster/remastered/remix/deluxe/ expanded/edition/reissue/anniversary/bonus) regardless of brackets so non-parenthesized remasters still match the plain local title above the 0.85 threshold (was falsely reported missing). - Fix TestAppRun_ScanLogsMissingReleases to verify run() performs the scan itself (capture its log output) instead of re-running ScanAll independently, which passed even if run() were a no-op. - Fix TestSimilarity misleading cases that downgraded to a <0.85 range check with dead want/epsilon fields; assert actual computed scores.
This commit is contained in:
@@ -44,34 +44,30 @@ func TestSimilarity(t *testing.T) {
|
||||
epsilon: 1e-9,
|
||||
},
|
||||
{
|
||||
name: "clearly different titles score below 0.85",
|
||||
name: "clearly different titles score low",
|
||||
a: "The Wall",
|
||||
b: "Completely Different Album",
|
||||
want: 0.0,
|
||||
epsilon: 1e-9,
|
||||
want: 0.1538,
|
||||
epsilon: 1e-3,
|
||||
},
|
||||
{
|
||||
name: "substring-ish title scores moderately",
|
||||
name: "substring-ish title scores moderately below threshold",
|
||||
a: "Dark Side of the Moon",
|
||||
b: "Dark Side of the Moon Part II",
|
||||
want: 0.0, // non-empty; value asserted only as below threshold
|
||||
epsilon: 1e-9,
|
||||
want: 0.7241,
|
||||
epsilon: 1e-3,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got := Similarity(tt.a, tt.b)
|
||||
switch {
|
||||
case tt.name == "clearly different titles score below 0.85" ||
|
||||
tt.name == "substring-ish title scores moderately":
|
||||
if got >= 0.85 {
|
||||
t.Errorf("Similarity(%q, %q) = %v, want < 0.85", tt.a, tt.b, got)
|
||||
}
|
||||
default:
|
||||
if diff := got - tt.want; diff > tt.epsilon || diff < -tt.epsilon {
|
||||
t.Errorf("Similarity(%q, %q) = %v, want %v (+/- %v)", tt.a, tt.b, got, tt.want, tt.epsilon)
|
||||
}
|
||||
if diff := got - tt.want; diff > tt.epsilon || diff < -tt.epsilon {
|
||||
t.Errorf("Similarity(%q, %q) = %v, want %v (+/- %v)", tt.a, tt.b, got, tt.want, tt.epsilon)
|
||||
}
|
||||
// Sanity: anything at/above the default threshold must be a match.
|
||||
if got >= 0.85 && !IsMatch(tt.a, tt.b, 0) {
|
||||
t.Errorf("Similarity(%q, %q) = %v >= 0.85 but IsMatch(...,0) is false", tt.a, tt.b, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user