Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
G
gostnops
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wei.xuan
gostnops
Commits
3f67d565
Commit
3f67d565
authored
Nov 13, 2020
by
wangwx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix fmt error
parent
2298844a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
10 deletions
+10
-10
poolqueue.go
container/queue/poolqueue.go
+2
-2
poolqueue_test.go
container/queue/poolqueue_test.go
+8
-8
No files found.
container/queue/poolqueue.go
View file @
3f67d565
...
...
@@ -199,11 +199,11 @@ func (d *poolDequeue) PopTail() (interface{}, bool) {
}
func
NewPoolDequeue
(
n
int
)
(
*
poolDequeue
,
error
)
{
if
n
&
(
n
-
1
)
!=
0
{
if
n
&
(
n
-
1
)
!=
0
{
return
nil
,
errors
.
New
(
"the size of pool must be a power of 2"
)
}
d
:=
&
poolDequeue
{
vals
:
make
([]
eface
,
n
),
}
return
d
,
nil
}
\ No newline at end of file
}
container/queue/poolqueue_test.go
View file @
3f67d565
...
...
@@ -25,21 +25,21 @@ import (
"testing"
)
func
TestCreatePoolDequeue
(
t
*
testing
.
T
){
_
,
err
:=
NewPoolDequeue
(
15
)
func
TestCreatePoolDequeue
(
t
*
testing
.
T
)
{
_
,
err
:=
NewPoolDequeue
(
15
)
assert
.
EqualError
(
t
,
err
,
"the size of pool must be a power of 2"
)
_
,
err
=
NewPoolDequeue
(
18
)
_
,
err
=
NewPoolDequeue
(
18
)
assert
.
EqualError
(
t
,
err
,
"the size of pool must be a power of 2"
)
_
,
err
=
NewPoolDequeue
(
24
)
_
,
err
=
NewPoolDequeue
(
24
)
assert
.
EqualError
(
t
,
err
,
"the size of pool must be a power of 2"
)
_
,
err
=
NewPoolDequeue
(
8
)
_
,
err
=
NewPoolDequeue
(
8
)
assert
.
NoError
(
t
,
err
)
}
func
TestPoolDequeue
(
t
*
testing
.
T
)
{
const
P
=
10
var
N
int
=
2e6
d
,
err
:=
NewPoolDequeue
(
16
)
if
err
!=
nil
{
d
,
err
:=
NewPoolDequeue
(
16
)
if
err
!=
nil
{
t
.
Errorf
(
"create poolDequeue fail"
)
}
if
testing
.
Short
()
{
...
...
@@ -112,4 +112,4 @@ func TestPoolDequeue(t *testing.T) {
if
!
testing
.
Short
()
&&
nPopHead
==
0
{
t
.
Errorf
(
"popHead never succeeded"
)
}
}
\ No newline at end of file
}
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