forked from taurusxin/ncmdump-go
动机:解决苹果系统发布包缺少执行权限和特殊文件误处理问题。 改动:校验发布包权限,支持两类芯片架构并改进文件识别。 影响:苹果系统可直接运行发布包,其他平台构建与使用方式兼容。 验证:运行 go test ./...、go vet ./... 和完整发布构建,结果通过。 关联:无
28 lines
807 B
Go
28 lines
807 B
Go
package main
|
|
|
|
import "testing"
|
|
|
|
func TestIsNCMFile(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
path string
|
|
want bool
|
|
}{
|
|
{name: "lowercase", path: "/Users/test/Music/song.ncm", want: true},
|
|
{name: "uppercase", path: "/Users/test/Music/song.NCM", want: true},
|
|
{name: "unicode path", path: "/Users/test/音乐/歌曲.ncm", want: true},
|
|
{name: "macOS AppleDouble file", path: "/Users/test/Music/._song.ncm", want: false},
|
|
{name: "short name", path: "a", want: false},
|
|
{name: "extension only", path: ".ncm", want: true},
|
|
{name: "different extension", path: "song.flac", want: false},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := isNCMFile(tt.path); got != tt.want {
|
|
t.Fatalf("isNCMFile(%q) = %v, want %v", tt.path, got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|