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-unixfs
Commits
5d9fa93c
Commit
5d9fa93c
authored
10 years ago
by
Matt Bell
Committed by
Juan Batiz-Benet
10 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commands/cli: Added test for single-dash option value
parent
66e6da3d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
commands/cli/parse_test.go
commands/cli/parse_test.go
+7
-3
No files found.
commands/cli/parse_test.go
View file @
5d9fa93c
...
...
@@ -8,10 +8,14 @@ import (
)
func
TestOptionParsing
(
t
*
testing
.
T
)
{
cmd
:=
&
commands
.
Command
{}
cmd
:=
&
commands
.
Command
{
Options
:
[]
commands
.
Option
{
commands
.
Option
{
[]
string
{
"b"
},
commands
.
String
},
},
}
cmd
.
Register
(
"test"
,
&
commands
.
Command
{})
opts
,
input
,
err
:=
parseOptions
([]
string
{
"--beep"
,
"--boop=
\"
5"
,
"lol
\"
"
,
"test2"
,
"-cV"
},
opts
,
input
,
err
:=
parseOptions
([]
string
{
"--beep"
,
"--boop=
\"
5"
,
"lol
\"
"
,
"test2"
,
"-cV
b"
,
"beep
"
},
[]
string
{
"test"
},
cmd
)
/*for k, v := range opts {
fmt.Printf("%s: %s\n", k, v)
...
...
@@ -20,7 +24,7 @@ func TestOptionParsing(t *testing.T) {
if
err
!=
nil
{
t
.
Error
(
"Should have passed"
)
}
if
len
(
opts
)
!=
4
||
opts
[
"c"
]
!=
""
||
opts
[
"V"
]
!=
""
||
opts
[
"beep"
]
!=
""
||
opts
[
"boop"
]
!=
"5 lol"
{
if
len
(
opts
)
!=
5
||
opts
[
"c"
]
!=
""
||
opts
[
"V"
]
!=
""
||
opts
[
"beep"
]
!=
""
||
opts
[
"boop"
]
!=
"5 lol"
||
opts
[
"b"
]
!=
"beep"
{
t
.
Error
(
"Returned options were defferent than expected: %v"
,
opts
)
}
if
len
(
input
)
!=
1
||
input
[
0
]
!=
"test2"
{
...
...
This diff is collapsed.
Click to expand it.
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