package library import "testing" // The shapes measured on the operator's library (milestone 498's body). func TestClassifyDuplicateGroup(t *testing.T) { m := func(album, title string) ClassifyMember { return ClassifyMember{AlbumID: album, Title: title, ArtistName: "Gorillaz"} } cases := []struct { name string tier string members []ClassifyMember want DuplicateClass }{ {"Humanz: one album, one song twice", "exact", []ClassifyMember{m("humanz", "Saturnz Barz"), m("humanz", "Saturnz Barz (Official Video)")}, ClassSameRelease}, {"one album, video upload title with artist prefix", "acoustic", []ClassifyMember{m("humanz", "Andromeda"), m("humanz", "Gorillaz - Andromeda (Official Audio)")}, ClassSameRelease}, {"one album, identical bytes under different titles", "exact", []ClassifyMember{m("www", "WWW"), m("www", "WWW (instrumental)")}, ClassSameRelease}, {"one album, acoustic match, different recordings named", "acoustic", []ClassifyMember{m("www", "WWW"), m("www", "WWW (instrumental)")}, ClassReview}, {"Big Me: the single and the album", "exact", []ClassifyMember{m("single", "Big Me"), m("album", "Big Me")}, ClassCrossRelease}, {"remaster and featuring credits are one song", "acoustic", []ClassifyMember{m("a", "Feel Good Inc. (2017 Remaster)"), m("b", "Feel Good Inc feat. De La Soul")}, ClassCrossRelease}, {"Nervosa / Anorexia: identical bytes, different songs", "exact", []ClassifyMember{m("a", "Nervosa"), m("b", "Anorexia")}, ClassMismatch}, {"studio and live across albums", "acoustic", []ClassifyMember{m("studio", "Charger"), m("live", "Charger (live)")}, ClassReview}, {"a lone copy", "exact", []ClassifyMember{m("a", "Song")}, ClassReview}, } for _, tc := range cases { if got := ClassifyDuplicateGroup(tc.tier, tc.members); got != tc.want { t.Errorf("%s: got %s, want %s", tc.name, got, tc.want) } } } func TestMatchTitleKey(t *testing.T) { cases := []struct{ title, artist, want string }{ {"Saturnz Barz (Official Video)", "Gorillaz", "saturnzbarz"}, {"Gorillaz - Saturnz Barz", "Gorillaz", "saturnzbarz"}, {"Doin' It Right (Music Video) ft. Panda Bear", "Daft Punk", "doinitright"}, {"Song [feat. X]", "", "song"}, {"Song - Remastered 2009", "", "song"}, {"Rock & Roll", "", "rockandroll"}, // What names a different recording stays. {"Song (live)", "", "songlive"}, {"Song (demo)", "", "songdemo"}, {"Song (Remix)", "", "songremix"}, // A title that is nothing but a marker keeps its words rather than vanishing. {"(Official Video)", "", "officialvideo"}, } for _, tc := range cases { if got := MatchTitleKey(tc.title, tc.artist); got != tc.want { t.Errorf("MatchTitleKey(%q, %q) = %q, want %q", tc.title, tc.artist, got, tc.want) } } } // The release check keeps every word: a box set's demo is its own song. func TestReleaseTitleKey(t *testing.T) { if ReleaseTitleKey("Song (demo)") == ReleaseTitleKey("Song") { t.Error("ReleaseTitleKey collapsed a demo into the song") } if ReleaseTitleKey("Hallelujah Money") != ReleaseTitleKey("hallelujah money!") { t.Error("ReleaseTitleKey kept case or punctuation") } }