Commit b31facdf authored by Christian Couder's avatar Christian Couder

parse_test: move helper functions

License: MIT
Signed-off-by: default avatarChristian Couder <chriscool@tuxfamily.org>
parent 15e3579a
......@@ -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 is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment