mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-03-31 09:01:33 +02:00
87 lines
2.4 KiB
Go
87 lines
2.4 KiB
Go
package gobackend
|
|
|
|
import "testing"
|
|
|
|
func TestNormalizeLooseTitle_Separators(t *testing.T) {
|
|
got := normalizeLooseTitle("Doctor / Cops")
|
|
if got != "doctor cops" {
|
|
t.Fatalf("expected doctor cops, got %q", got)
|
|
}
|
|
|
|
got = normalizeLooseTitle("Doctor _ Cops")
|
|
if got != "doctor cops" {
|
|
t.Fatalf("expected doctor cops, got %q", got)
|
|
}
|
|
}
|
|
|
|
func TestNormalizeLooseTitle_EmojiAndSymbols(t *testing.T) {
|
|
got := normalizeLooseTitle("Music Of The Spheres 🌎✨")
|
|
if got != "music of the spheres" {
|
|
t.Fatalf("expected music of the spheres, got %q", got)
|
|
}
|
|
}
|
|
|
|
func TestTrackMatchesRequest_SongLinkBypassesArtistAndTitle(t *testing.T) {
|
|
req := DownloadRequest{
|
|
TrackName: "Ringišpil",
|
|
ArtistName: "Djordje Balasevic",
|
|
}
|
|
resolved := resolvedTrackInfo{
|
|
Title: "Completely Different Title",
|
|
ArtistName: "Totally Different Artist",
|
|
SkipNameVerification: true,
|
|
}
|
|
|
|
if !trackMatchesRequest(req, resolved, "test") {
|
|
t.Fatal("expected SongLink-resolved track to bypass artist/title verification")
|
|
}
|
|
}
|
|
|
|
func TestTrackMatchesRequest_SongLinkStillChecksDuration(t *testing.T) {
|
|
req := DownloadRequest{
|
|
TrackName: "Ringišpil",
|
|
ArtistName: "Djordje Balasevic",
|
|
DurationMS: 180000,
|
|
}
|
|
resolved := resolvedTrackInfo{
|
|
Title: "Completely Different Title",
|
|
ArtistName: "Totally Different Artist",
|
|
Duration: 240,
|
|
SkipNameVerification: true,
|
|
}
|
|
|
|
if trackMatchesRequest(req, resolved, "test") {
|
|
t.Fatal("expected SongLink-resolved track with large duration mismatch to be rejected")
|
|
}
|
|
}
|
|
|
|
func TestTitlesMatch_SeparatorVariants(t *testing.T) {
|
|
if !titlesMatch("Doctor / Cops", "Doctor _ Cops") {
|
|
t.Fatal("expected tidal titlesMatch to accept / vs _ variant")
|
|
}
|
|
}
|
|
|
|
func TestTitlesMatch_EmojiStrict(t *testing.T) {
|
|
if titlesMatch("🪐", "Higher Power") {
|
|
t.Fatal("expected emoji title not to match unrelated textual title")
|
|
}
|
|
if !titlesMatch("🪐", "🪐") {
|
|
t.Fatal("expected identical emoji titles to match")
|
|
}
|
|
}
|
|
|
|
func TestQobuzTitlesMatch_SeparatorVariants(t *testing.T) {
|
|
if !qobuzTitlesMatch("Doctor / Cops", "Doctor _ Cops") {
|
|
t.Fatal("expected qobuzTitlesMatch to accept / vs _ variant")
|
|
}
|
|
}
|
|
|
|
func TestQobuzTitlesMatch_EmojiStrict(t *testing.T) {
|
|
if qobuzTitlesMatch("🪐", "Higher Power") {
|
|
t.Fatal("expected emoji title not to match unrelated textual title")
|
|
}
|
|
if !qobuzTitlesMatch("🪐", "🪐") {
|
|
t.Fatal("expected identical emoji titles to match")
|
|
}
|
|
}
|