Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3-cmds
Commits
b31facdf
Commit
b31facdf
authored
May 02, 2015
by
Christian Couder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
parse_test: move helper functions
License: MIT Signed-off-by:
Christian Couder
<
chriscool@tuxfamily.org
>
parent
15e3579a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
24 deletions
+24
-24
cli/parse_test.go
cli/parse_test.go
+24
-24
No files found.
cli/parse_test.go
View file @
b31facdf
...
@@ -7,31 +7,19 @@ import (
...
@@ -7,31 +7,19 @@ import (
"github.com/ipfs/go-ipfs/commands"
"github.com/ipfs/go-ipfs/commands"
)
)
func
TestOptionParsing
(
t
*
testing
.
T
)
{
type
kvs
map
[
string
]
interface
{}
subCmd
:=
&
commands
.
Command
{}
type
words
[]
string
cmd
:=
&
commands
.
Command
{
Options
:
[]
commands
.
Option
{
commands
.
StringOption
(
"string"
,
"s"
,
"a string"
),
commands
.
BoolOption
(
"bool"
,
"b"
,
"a bool"
),
},
Subcommands
:
map
[
string
]
*
commands
.
Command
{
"test"
:
subCmd
,
},
}
type
kvs
map
[
string
]
interface
{}
type
words
[]
string
sameWords
:=
func
(
a
words
,
b
words
)
bool
{
func
sameWords
(
a
words
,
b
words
)
bool
{
for
i
,
w
:=
range
a
{
for
i
,
w
:=
range
a
{
if
w
!=
b
[
i
]
{
if
w
!=
b
[
i
]
{
return
false
return
false
}
}
}
}
return
true
return
true
}
}
sameKVs
:=
func
(
a
kvs
,
b
kvs
)
bool
{
func
sameKVs
(
a
kvs
,
b
kvs
)
bool
{
if
len
(
a
)
!=
len
(
b
)
{
if
len
(
a
)
!=
len
(
b
)
{
return
false
return
false
}
}
...
@@ -41,6 +29,18 @@ func TestOptionParsing(t *testing.T) {
...
@@ -41,6 +29,18 @@ func TestOptionParsing(t *testing.T) {
}
}
}
}
return
true
return
true
}
func
TestOptionParsing
(
t
*
testing
.
T
)
{
subCmd
:=
&
commands
.
Command
{}
cmd
:=
&
commands
.
Command
{
Options
:
[]
commands
.
Option
{
commands
.
StringOption
(
"string"
,
"s"
,
"a string"
),
commands
.
BoolOption
(
"bool"
,
"b"
,
"a bool"
),
},
Subcommands
:
map
[
string
]
*
commands
.
Command
{
"test"
:
subCmd
,
},
}
}
testHelper
:=
func
(
args
string
,
expectedOpts
kvs
,
expectedWords
words
,
expectErr
bool
)
{
testHelper
:=
func
(
args
string
,
expectedOpts
kvs
,
expectedWords
words
,
expectErr
bool
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment