(t *testing.T)
| 127 | } |
| 128 | |
| 129 | func TestHistogramNonMonotonicBuckets(t *testing.T) { |
| 130 | testCases := map[string][]float64{ |
| 131 | "not strictly monotonic": {1, 2, 2, 3}, |
| 132 | "not monotonic at all": {1, 2, 4, 3, 5}, |
| 133 | "have +Inf in the middle": {1, 2, math.Inf(+1), 3}, |
| 134 | } |
| 135 | for name, buckets := range testCases { |
| 136 | func() { |
| 137 | defer func() { |
| 138 | if r := recover(); r == nil { |
| 139 | t.Errorf("Buckets %v are %s but NewHistogram did not panic.", buckets, name) |
| 140 | } |
| 141 | }() |
| 142 | _ = NewHistogram(HistogramOpts{ |
| 143 | Name: "test_histogram", |
| 144 | Help: "helpless", |
| 145 | Buckets: buckets, |
| 146 | }) |
| 147 | }() |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | // Intentionally adding +Inf here to test if that case is handled correctly. |
| 152 | // Also, getCumulativeCounts depends on it. |
nothing calls this directly
no test coverage detected