bit4sat/utils/paths_test.go

36 lines
569 B
Go
Raw Normal View History

2019-03-21 17:44:40 +00:00
package utils
import "testing"
type CleanName struct {
name string
ext string
}
func TestCleanFileName(t *testing.T) {
tests := map[string]CleanName{
"noext": CleanName{"noext", ""},
"with.ext": CleanName{"with", ".ext"},
"path/with.ext": CleanName{"with", ".ext"},
"path/noext": CleanName{"noext", ""},
}
for name, expected := range tests {
t.Run(name, func(t *testing.T) {
resName, resExt := CleanFileName(name)
if resName != expected.name {
t.Fail()
}
if resExt != expected.ext {
t.Fail()
}
})
}
}