-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
62 lines (54 loc) · 1.72 KB
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package main
import (
"strings"
"testing"
)
func TestExtractDuplicate(t *testing.T) {
nameMap := make(map[string]string)
metaName := "P1020323.JPG(1).json"
nameMap[strings.ToLower(metaName)] = metaName
expectedName := "P1020323(1).JPG"
nameMap[strings.ToLower(expectedName)] = expectedName
name, err := getItemFileName(metaName, nameMap)
if err != nil {
t.Error(err)
return
}
if name != expectedName {
t.Errorf("%s != %s", name, expectedName)
}
}
func TestExtractDuplicate2(t *testing.T) {
nameMap := make(map[string]string)
metaName := "IMG_1425-ANIMATION.gif(1).json"
nameMap[strings.ToLower(metaName)] = metaName
expectedName := "IMG_1425-ANIMATION(1).gif"
nameMap[strings.ToLower(expectedName)] = expectedName
check(t, metaName, nameMap, expectedName)
}
func TestExtractSimple(t *testing.T) {
nameMap := make(map[string]string)
metaName := "IMG_20180911_155532.jpg.json"
nameMap[strings.ToLower(metaName)] = metaName
expectedName := "IMG_20180911_155532.jpg"
nameMap[strings.ToLower(expectedName)] = expectedName
check(t, metaName, nameMap, expectedName)
}
func TestExtractLong(t *testing.T) {
nameMap := make(map[string]string)
metaName := "70ECD1A6-F846-4CB7-9709-474FCB7B3E15-COLLAGE.j.json"
nameMap[strings.ToLower(metaName)] = metaName
expectedName := "70ECD1A6-F846-4CB7-9709-474FCB7B3E15-COLLAGE.jpg"
nameMap[strings.ToLower(expectedName)] = expectedName
check(t, metaName, nameMap, expectedName)
}
func check(t *testing.T, metaName string, nameMap map[string]string, expectedName string) {
name, err := getItemFileName(metaName, nameMap)
if err != nil {
t.Error(err)
return
}
if name != expectedName {
t.Errorf("%s != %s", name, expectedName)
}
}