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
Commits
3e4a0694
Commit
3e4a0694
authored
9 years ago
by
Christian Couder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
parse_test: fix and test sameWords()
License: MIT Signed-off-by:
Christian Couder
<
chriscool@tuxfamily.org
>
parent
2a5b2f2f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
commands/cli/parse_test.go
commands/cli/parse_test.go
+30
-0
No files found.
commands/cli/parse_test.go
View file @
3e4a0694
...
...
@@ -11,6 +11,9 @@ type kvs map[string]interface{}
type
words
[]
string
func
sameWords
(
a
words
,
b
words
)
bool
{
if
len
(
a
)
!=
len
(
b
)
{
return
false
}
for
i
,
w
:=
range
a
{
if
w
!=
b
[
i
]
{
return
false
...
...
@@ -31,6 +34,33 @@ func sameKVs(a kvs, b kvs) bool {
return
true
}
func
TestSameWords
(
t
*
testing
.
T
)
{
a
:=
[]
string
{
"v1"
,
"v2"
}
b
:=
[]
string
{
"v1"
,
"v2"
,
"v3"
}
c
:=
[]
string
{
"v2"
,
"v3"
}
d
:=
[]
string
{
"v2"
}
e
:=
[]
string
{
"v2"
,
"v3"
}
f
:=
[]
string
{
"v2"
,
"v1"
}
test
:=
func
(
a
words
,
b
words
,
v
bool
)
{
if
sameWords
(
a
,
b
)
!=
v
{
t
.
Errorf
(
"sameWords('%v', '%v') != %v"
,
a
,
b
,
v
)
}
}
test
(
a
,
b
,
false
)
test
(
a
,
a
,
true
)
test
(
a
,
c
,
false
)
test
(
b
,
c
,
false
)
test
(
c
,
d
,
false
)
test
(
c
,
e
,
true
)
test
(
b
,
e
,
false
)
test
(
a
,
b
,
false
)
test
(
a
,
f
,
false
)
test
(
e
,
f
,
false
)
test
(
f
,
f
,
true
)
}
func
TestOptionParsing
(
t
*
testing
.
T
)
{
subCmd
:=
&
commands
.
Command
{}
cmd
:=
&
commands
.
Command
{
...
...
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