Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
08fb9210
Commit
08fb9210
authored
Nov 30, 2017
by
axetroy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: Improve test case for utils/safemap, make it 100% cover
parent
c5118e95
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
0 deletions
+31
-0
safemap_test.go
utils/safemap_test.go
+31
-0
No files found.
utils/safemap_test.go
View file @
08fb9210
...
...
@@ -31,6 +31,22 @@ func TestSet(t *testing.T) {
}
}
func
TestReSet
(
t
*
testing
.
T
)
{
safeMap
:=
NewBeeMap
()
if
ok
:=
safeMap
.
Set
(
"astaxie"
,
1
);
!
ok
{
t
.
Error
(
"expected"
,
true
,
"got"
,
false
)
}
// set diff value
if
ok
:=
safeMap
.
Set
(
"astaxie"
,
-
1
);
!
ok
{
t
.
Error
(
"expected"
,
true
,
"got"
,
false
)
}
// set same value
if
ok
:=
safeMap
.
Set
(
"astaxie"
,
-
1
);
ok
{
t
.
Error
(
"expected"
,
false
,
"got"
,
true
)
}
}
func
TestCheck
(
t
*
testing
.
T
)
{
if
exists
:=
safeMap
.
Check
(
"astaxie"
);
!
exists
{
t
.
Error
(
"expected"
,
true
,
"got"
,
false
)
...
...
@@ -50,6 +66,21 @@ func TestDelete(t *testing.T) {
}
}
func
TestItems
(
t
*
testing
.
T
)
{
safeMap
:=
NewBeeMap
()
safeMap
.
Set
(
"astaxie"
,
"hello"
)
for
k
,
v
:=
range
safeMap
.
Items
()
{
key
:=
k
.
(
string
)
value
:=
v
.
(
string
)
if
key
!=
"astaxie"
{
t
.
Error
(
"expected the key should be astaxie"
)
}
if
value
!=
"hello"
{
t
.
Error
(
"expected the value should be hello"
)
}
}
}
func
TestCount
(
t
*
testing
.
T
)
{
if
count
:=
safeMap
.
Count
();
count
!=
0
{
t
.
Error
(
"expected count to be"
,
0
,
"got"
,
count
)
...
...
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