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

Function TestEqualValues

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

SampleValueTypeAlias · 0.85
EqualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…