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) } } }