-
Notifications
You must be signed in to change notification settings - Fork 0
/
gost_test.go
40 lines (34 loc) · 849 Bytes
/
gost_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package gost
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
)
func TestMeasureSpeedTest(t *testing.T) {
p, _ := NewSpeedTestProvider()
v, err := Measure(context.Background(), p)
if assert.Nil(t, err) {
assert.NotEqualValues(t, 0, v.Download)
assert.NotEqualValues(t, 0, v.Upload)
}
}
func TestMeasureFast(t *testing.T) {
p, _ := NewFastProvider(false, nil)
v, err := Measure(context.Background(), p)
if assert.Nil(t, err) {
assert.NotEqualValues(t, 0, v.Download)
assert.NotEqualValues(t, 0, v.Upload)
}
}
func BenchmarkSpeedTest(b *testing.B) {
p, _ := NewSpeedTestProvider()
for i := 0; i < b.N; i++ {
_, _ = Measure(context.Background(), p)
}
}
func BenchmarkSpeedFast(b *testing.B) {
p, _ := NewFastProvider(false, nil)
for i := 0; i < b.N; i++ {
_, _ = Measure(context.Background(), p)
}
}