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

Function TestSamplePairJSON

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

Source from the content-addressed store, hash-verified

112}
113
114func TestSamplePairJSON(t *testing.T) {
115 input := []struct {
116 plain string
117 value SamplePair
118 }{
119 {
120 plain: `[1234.567,"123.1"]`,
121 value: SamplePair{
122 Value: 123.1,
123 Timestamp: 1234567,
124 },
125 },
126 }
127
128 for _, test := range input {
129 b, err := json.Marshal(test.value)
130 if err != nil {
131 t.Error(err)
132 continue
133 }
134
135 if string(b) != test.plain {
136 t.Errorf("encoding error: expected %q, got %q", test.plain, b)
137 continue
138 }
139
140 var sp SamplePair
141 err = json.Unmarshal(b, &sp)
142 if err != nil {
143 t.Error(err)
144 continue
145 }
146
147 if sp != test.value {
148 t.Errorf("decoding error: expected %v, got %v", test.value, sp)
149 }
150 }
151}
152
153func TestSampleJSON(t *testing.T) {
154 input := []struct {

Callers

nothing calls this directly

Calls 1

ErrorMethod · 0.80

Tested by

no test coverage detected