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
|
package commands_test
import (
"strings"
"testing"
"git.sr.ht/~rjarry/aerc/commands"
)
func TestCommands_Operand(t *testing.T) {
tests := []struct {
args []string
spec string
want string
}{
{
args: []string{"cmd", "-a", "-b", "arg1", "-c", "bla"},
spec: "ab:c",
want: "cmdbla",
},
{
args: []string{"cmd", "-a", "-b", "arg1", "-c", "--", "bla"},
spec: "ab:c",
want: "bla",
},
{
args: []string{"cmd", "-a", "-b", "arg1", "-c", "bla"},
spec: "ab:c:",
want: "cmd",
},
{
args: nil,
spec: "ab:c:",
want: "",
},
}
for i, test := range tests {
arg := strings.Join(commands.Operands(test.args, test.spec), "")
if arg != test.want {
t.Errorf("failed test %d: want '%s', got '%s'", i,
test.want, arg)
}
}
}
|