package normalize import "testing" func TestName(t *testing.T) { cases := []struct{ in, want string }{ {"The Method to Love", "the-method-to-love"}, {"Prophecy At 1420 MHz", "prophecy-at-1420-mhz"}, {"Don't Stop", "dont-stop"}, {"Don\u2019t Stop", "dont-stop"}, {"Caf\u00e9 M\u00fcnster", "cafe-munster"}, {"MIXED Case TiTlE", "mixed-case-title"}, {" leading and trailing ", "leading-and-trailing"}, {"trailing dots...", "trailing-dots"}, {"\u591c\u660e\u3051", ""}, {"\u2605\u2605\u2605\u2605\u2605", ""}, {"", ""}, {"---", ""}, {"1", "1"}, // Symbols that every filesystem accepts are kept, so a title stays // readable instead of collapsing into a run of dashes. {"Track (feat. Someone) [Remix]", "track-(feat-someone)-[remix]"}, {"Bj\u00f6rk & Sigur R\u00f3s", "bjork-&-sigur-ros"}, {"while(1<2), Part 1", "while(1_2)-part-1"}, // A symbol that is illegal somewhere becomes an underscore inside a // word, so the two characters it sat between stay separated rather than // turning into two words. {"a 200 { t.Errorf("truncated name is %d bytes, want <= 200", len(got)) } if ext := got[len(got)-5:]; ext != ".flac" { t.Errorf("extension not preserved: %q", got) } if s, cut := Truncate("short.flac", 200); cut || s != "short.flac" { t.Errorf("short name should be untouched, got %q cut=%v", s, cut) } }