-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcopyname_test.go
58 lines (51 loc) · 1.05 KB
/
copyname_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
package main
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestIsCopyName(t *testing.T) {
assert := require.New(t)
positive := [][]string{
{
"foo.bar",
"Copy of foo.bar",
"foo copy.bar",
"foo (1).bar",
"foo(1).bar",
" foo .bar ",
},
{
"foo",
"Copy of foo",
"foo-01",
},
}
negative := []string{
"foo.bar",
"foo",
".bar",
"foo.",
"foo.abc",
"Copy of foo.xyz",
"bar.foo",
"f_o.bar",
"aa-1234.bar",
"aa-1234q.bar",
"aa-.bar",
"aa-foo-bar.bar",
}
for _, c := range positive {
for i, x := range c {
for j := i + 1; j < len(c); j++ {
assert.True(isCopyName(x, c[j]), "%s and %s should be copy names", x, c[j])
assert.True(isCopyName(c[j], x), "%s and %s should be copy names", c[j], x)
}
}
}
for i, x := range negative {
for j := i + 1; j < len(negative); j++ {
assert.False(isCopyName(x, negative[j]), "%s and %s should not be copy names", x, negative[j])
assert.False(isCopyName(negative[j], x), "%s and %s should not be copy names", negative[j], x)
}
}
}