-
Notifications
You must be signed in to change notification settings - Fork 2
/
args_windows_test.go
58 lines (47 loc) · 986 Bytes
/
args_windows_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 (
"os"
"reflect"
"sort"
"testing"
)
func TestExpandArgs(t *testing.T) {
args := os.Args
defer func() {
os.Args = args
}()
os.Args = []string{"foo", "*_test.go"}
expandArgs()
given := os.Args
expect := []string{"foo", "args_windows_test.go", "grep_test.go"}
sort.Strings(given)
sort.Strings(expect)
if !reflect.DeepEqual(given, expect) {
t.Fatalf("Should be %v but %v", expect, os.Args)
}
}
func TestExpandArgsDashDash(t *testing.T) {
args := os.Args
defer func() {
os.Args = args
}()
os.Args = []string{"foo", "--", "*_test.go"}
expandArgs()
expect := []string{"foo", "*_test.go"}
if os.Args[0] != "foo" || os.Args[1] != "*_test.go" {
t.Fatalf("Should be %v but %v", expect, os.Args)
}
}
func TestExpandArgsAll(t *testing.T) {
args := os.Args
defer func() {
os.Args = args
}()
os.Args = []string{"foo", "*"}
expandArgs()
for _, v := range os.Args {
if v[0] == '.' {
t.Fatalf("Should not exists %v", v)
}
}
}