-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathoptions_test.go
36 lines (34 loc) · 1 KB
/
options_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
package datadog
import "testing"
func TestGetPercentileNamesOutOfRange(t *testing.T) {
reporter := &Reporter{}
if UsePercentiles([]float64{0.23, 0})(reporter) == nil {
t.Fatal("Expected error")
}
if UsePercentiles([]float64{0.23, 1})(reporter) == nil {
t.Fatal("Expected error")
}
if UsePercentiles([]float64{0.23, -0.1})(reporter) == nil {
t.Fatal("Expected error")
}
if UsePercentiles([]float64{0.23, 2})(reporter) == nil {
t.Fatal("Expected error")
}
}
func TestGetPercentileNames(t *testing.T) {
reporter := &Reporter{}
percentiles := []float64{0.23, 0.4, 0.99999, 0.45346356}
err := UsePercentiles(percentiles)(reporter)
if err != nil {
t.Fatal(err)
}
expectedNames := []string{".p23", ".p4", ".p99999", ".p45346356"}
if len(expectedNames) != len(reporter.p) {
t.Fatalf("Expected names: %v, got: %v", expectedNames, reporter.p)
}
for i, expectedName := range expectedNames {
if reporter.p[i] != expectedName {
t.Fatalf("Expected names: %v, got: %v", expectedNames, reporter.p)
}
}
}