-
Notifications
You must be signed in to change notification settings - Fork 1
/
argv_test.go
50 lines (45 loc) · 1.12 KB
/
argv_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
package commander
import (
"github.com/WindomZ/testify/assert"
"testing"
)
func Test_Argv_GetArg(t *testing.T) {
var argv _Argv = newArgv([]string{
"aaa",
"bbb",
"ccc",
})
assert.Equal(t, argv.GetArg(0), "bbb")
assert.Equal(t, argv.GetArg(1), "ccc")
assert.Equal(t, argv.GetArg(2), "")
}
func Test_Argv_GetArgs(t *testing.T) {
var argv _Argv = newArgv([]string{
"aaa",
"bbb",
"ccc",
})
assert.Equal(t, argv.GetArgs(), []string{"bbb", "ccc"})
assert.Equal(t, argv.GetArgs(-1), []string{"bbb", "ccc"})
assert.Equal(t, argv.GetArgs(1), []string{"ccc"})
assert.Equal(t, argv.GetArgs(2), []string{})
}
func Test_Argv_ArgsString(t *testing.T) {
var argv _Argv = newArgv([]string{
"aaa",
"bbb",
"ccc",
})
assert.Equal(t, argv.ArgsString(), "bbb ccc")
}
func Test_Argv_ArgsStringSeparator(t *testing.T) {
var argv _Argv = newArgv([]string{
"aaa",
"bbb",
"ccc",
})
assert.Equal(t, argv.ArgsStringSeparator(", "), "bbb, ccc")
assert.Equal(t, argv.ArgsStringSeparator("|"), "bbb|ccc")
assert.Equal(t, argv.ArgsStringSeparator("$"), "bbb$ccc")
assert.Equal(t, argv.ArgsStringSeparator("$", 1), "ccc")
}