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
p2p
go-flow-metrics
Commits
3b17196f
Commit
3b17196f
authored
Oct 31, 2019
by
Roman Proskuryakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a test for Meter::Reset
parent
a0a12174
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
meter_test.go
meter_test.go
+19
-0
No files found.
meter_test.go
View file @
3b17196f
...
...
@@ -3,6 +3,7 @@ package flow
import
(
"fmt"
"math"
"testing"
"time"
)
...
...
@@ -29,6 +30,24 @@ func ExampleMeter() {
// Output: 3000 (300/s)
}
func
TestResetMeter
(
t
*
testing
.
T
)
{
meter
:=
new
(
Meter
)
meter
.
Mark
(
30
)
time
.
Sleep
(
2
*
time
.
Second
)
if
total
:=
meter
.
Snapshot
()
.
Total
;
total
!=
30
{
t
.
Errorf
(
"total = %d; want 30"
,
total
)
}
meter
.
Reset
()
if
total
:=
meter
.
Snapshot
()
.
Total
;
total
!=
0
{
t
.
Errorf
(
"total = %d; want 0"
,
total
)
}
}
func
roundTens
(
x
float64
)
int64
{
return
int64
(
math
.
Floor
(
x
/
10
+
0.5
))
*
10
}
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