Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
cb38b02f
Commit
cb38b02f
authored
Jul 27, 2015
by
Justin Santa Barbara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unit test for StringSet Equal
parent
924350d5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
0 deletions
+54
-0
set_test.go
pkg/util/set_test.go
+54
-0
No files found.
pkg/util/set_test.go
View file @
cb38b02f
...
@@ -129,3 +129,57 @@ func TestStringSetHasAny(t *testing.T) {
...
@@ -129,3 +129,57 @@ func TestStringSetHasAny(t *testing.T) {
t
.
Errorf
(
"expected false, got true"
)
t
.
Errorf
(
"expected false, got true"
)
}
}
}
}
func
TestStringSetEquals
(
t
*
testing
.
T
)
{
// Simple case (order doesn't matter)
a
:=
NewStringSet
(
"1"
,
"2"
)
b
:=
NewStringSet
(
"2"
,
"1"
)
if
!
a
.
Equal
(
b
)
{
t
.
Errorf
(
"Expected to be equal: %v vs %v"
,
a
,
b
)
}
// It is a set; duplicates are ignored
b
=
NewStringSet
(
"2"
,
"2"
,
"1"
)
if
!
a
.
Equal
(
b
)
{
t
.
Errorf
(
"Expected to be equal: %v vs %v"
,
a
,
b
)
}
// Edge cases around empty sets / empty strings
a
=
NewStringSet
()
b
=
NewStringSet
()
if
!
a
.
Equal
(
b
)
{
t
.
Errorf
(
"Expected to be equal: %v vs %v"
,
a
,
b
)
}
b
=
NewStringSet
(
"1"
,
"2"
,
"3"
)
if
a
.
Equal
(
b
)
{
t
.
Errorf
(
"Expected to be not-equal: %v vs %v"
,
a
,
b
)
}
b
=
NewStringSet
(
"1"
,
"2"
,
""
)
if
a
.
Equal
(
b
)
{
t
.
Errorf
(
"Expected to be not-equal: %v vs %v"
,
a
,
b
)
}
// Check for equality after mutation
a
=
NewStringSet
()
a
.
Insert
(
"1"
)
if
a
.
Equal
(
b
)
{
t
.
Errorf
(
"Expected to be not-equal: %v vs %v"
,
a
,
b
)
}
a
.
Insert
(
"2"
)
if
a
.
Equal
(
b
)
{
t
.
Errorf
(
"Expected to be not-equal: %v vs %v"
,
a
,
b
)
}
a
.
Insert
(
""
)
if
!
a
.
Equal
(
b
)
{
t
.
Errorf
(
"Expected to be equal: %v vs %v"
,
a
,
b
)
}
a
.
Delete
(
""
)
if
a
.
Equal
(
b
)
{
t
.
Errorf
(
"Expected to be not-equal: %v vs %v"
,
a
,
b
)
}
}
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