MCPcopy Create free account
hub / github.com/prometheus/common / TestEqualValues

Function TestEqualValues

model/value_float_test.go:59–112  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

57)
58
59func TestEqualValues(t *testing.T) {
60 tests := map[string]struct {
61 in1, in2 SampleValue
62 want bool
63 }{
64 "equal floats": {
65 in1: 3.14,
66 in2: 3.14,
67 want: true,
68 },
69 "unequal floats": {
70 in1: 3.14,
71 in2: 3.1415,
72 want: false,
73 },
74 "positive infinities": {
75 in1: SampleValue(math.Inf(+1)),
76 in2: SampleValue(math.Inf(+1)),
77 want: true,
78 },
79 "negative infinities": {
80 in1: SampleValue(math.Inf(-1)),
81 in2: SampleValue(math.Inf(-1)),
82 want: true,
83 },
84 "different infinities": {
85 in1: SampleValue(math.Inf(+1)),
86 in2: SampleValue(math.Inf(-1)),
87 want: false,
88 },
89 "number and infinity": {
90 in1: 42,
91 in2: SampleValue(math.Inf(+1)),
92 want: false,
93 },
94 "number and NaN": {
95 in1: 42,
96 in2: SampleValue(math.NaN()),
97 want: false,
98 },
99 "NaNs": {
100 in1: SampleValue(math.NaN()),
101 in2: SampleValue(math.NaN()),
102 want: true, // !!!
103 },
104 }
105
106 for name, test := range tests {
107 got := test.in1.Equal(test.in2)
108 if got != test.want {
109 t.Errorf("Comparing %s, %f and %f: got %t, want %t", name, test.in1, test.in2, got, test.want)
110 }
111 }
112}
113
114func TestSamplePairJSON(t *testing.T) {
115 input := []struct {

Callers

nothing calls this directly

Calls 2

SampleValueTypeAlias · 0.85
EqualMethod · 0.45

Tested by

no test coverage detected