提交 2a5b2f2f 作者: Christian Couder

parse_test: move helper functions

License: MIT
Signed-off-by: 's avatarChristian Couder <chriscool@tuxfamily.org>
上级 cc5f6bb3
......@@ -7,6 +7,30 @@ import (
"github.com/ipfs/go-ipfs/commands"
)
type kvs map[string]interface{}
type words []string
func sameWords(a words, b words) bool {
for i, w := range a {
if w != b[i] {
return false
}
}
return true
}
func sameKVs(a kvs, b kvs) bool {
if len(a) != len(b) {
return false
}
for k, v := range a {
if v != b[k] {
return false
}
}
return true
}
func TestOptionParsing(t *testing.T) {
subCmd := &commands.Command{}
cmd := &commands.Command{
......@@ -19,30 +43,6 @@ func TestOptionParsing(t *testing.T) {
},
}
type kvs map[string]interface{}
type words []string
sameWords := func(a words, b words) bool {
for i, w := range a {
if w != b[i] {
return false
}
}
return true
}
sameKVs := func(a kvs, b kvs) bool {
if len(a) != len(b) {
return false
}
for k, v := range a {
if v != b[k] {
return false
}
}
return true
}
testHelper := func(args string, expectedOpts kvs, expectedWords words, expectErr bool) {
_, opts, input, _, err := parseOpts(strings.Split(args, " "), cmd)
if expectErr {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论