10 func TestEncodeFilePath(t *testing.T) {
11 var tests = []struct {
16 filePath: "kitten1.jpg",
18 0x00, 0x01, // number of items in path
19 0x00, 0x00, // leading path separator
20 0x0b, // length of next path section (11)
21 0x6b, 0x69, 0x74, 0x74, 0x65, 0x6e, 0x31, 0x2e, 0x6a, 0x70, 0x67, // kitten1.jpg
25 filePath: "foo/kitten1.jpg",
27 0x00, 0x02, // number of items in path
31 0x00, 0x00, // leading path separator
32 0x0b, // length of next path section (11)
33 0x6b, 0x69, 0x74, 0x74, 0x65, 0x6e, 0x31, 0x2e, 0x6a, 0x70, 0x67, // kitten1.jpg
38 for _, test := range tests {
39 got := EncodeFilePath(test.filePath)
40 if !bytes.Equal(got, test.want) {
41 t.Errorf("field mismatch: want: %#v got: %#v", test.want, got)
46 func TestCalcTotalSize(t *testing.T) {
48 defer func() {_ = os.Chdir(cwd)}()
50 _ = os.Chdir("test/config/Files")
66 want: []byte{0x00, 0x00, 0x18, 0x00},
69 // TODO: Add more test cases.
71 for _, tt := range tests {
72 t.Run(tt.name, func(t *testing.T) {
73 got, err := CalcTotalSize(tt.args.filePath)
74 if (err != nil) != tt.wantErr {
75 t.Errorf("CalcTotalSize() error = %v, wantErr %v", err, tt.wantErr)
78 if !reflect.DeepEqual(got, tt.want) {
79 t.Errorf("CalcTotalSize() got = %v, want %v", got, tt.want)