更新
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package mailx
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestFileBaseName(t *testing.T) {
|
||||
cases := []struct{ in, want string }{
|
||||
{"dir/file.txt", "file.txt"},
|
||||
{`dir\file.txt`, "file.txt"},
|
||||
{"/a/b/c.txt", "c.txt"},
|
||||
{"file.txt", "file.txt"},
|
||||
{"", "attachment"},
|
||||
{"/", "attachment"},
|
||||
{".", "attachment"},
|
||||
}
|
||||
for _, c := range cases {
|
||||
if got := fileBaseName(c.in); got != c.want {
|
||||
t.Errorf("fileBaseName(%q) = %q, want %q", c.in, got, c.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user