meta_test.go 941 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package common
  2. import (
  3. "reflect"
  4. "testing"
  5. )
  6. func TestParseFilenameMeta(t *testing.T) {
  7. tests := []struct {
  8. name string
  9. wantMeta AudioMeta
  10. }{
  11. {
  12. name: "test1",
  13. wantMeta: &filenameMeta{title: "test1"},
  14. },
  15. {
  16. name: "周杰伦 - 晴天.flac",
  17. wantMeta: &filenameMeta{artists: []string{"周杰伦"}, title: "晴天"},
  18. },
  19. {
  20. name: "Alan Walker _ Iselin Solheim - Sing Me to Sleep.flac",
  21. wantMeta: &filenameMeta{artists: []string{"Alan Walker", "Iselin Solheim"}, title: "Sing Me to Sleep"},
  22. },
  23. {
  24. name: "Christopher,Madcon - Limousine.flac",
  25. wantMeta: &filenameMeta{artists: []string{"Christopher", "Madcon"}, title: "Limousine"},
  26. },
  27. }
  28. for _, tt := range tests {
  29. t.Run(tt.name, func(t *testing.T) {
  30. if gotMeta := ParseFilenameMeta(tt.name); !reflect.DeepEqual(gotMeta, tt.wantMeta) {
  31. t.Errorf("ParseFilenameMeta() = %v, want %v", gotMeta, tt.wantMeta)
  32. }
  33. })
  34. }
  35. }