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

Function TestSamplePairJSONV2

model/value_float127_test.go:64–83  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

62}
63
64func TestSamplePairJSONV2(t *testing.T) {
65 cases := []SamplePair{
66 {},
67 {Timestamp: Time(1)},
68 {Value: SampleValue(1)},
69 {Timestamp: Time(1), Value: SampleValue(1)},
70 }
71
72 for _, v := range cases {
73 testV1V2Marshal(t, fmt.Sprintf("%#v", v), v)
74 testRoundTrip(t, fmt.Sprintf("%#v", v), v)
75 }
76
77 for _, input := range []string{`null`, `[]`, `[1.123]`, `[1.123,"2"]`, `[null,"2"]`, `[1.123,null]`, `[1.123,"2","bogus","trailing","data"]`} {
78 testDecodeSuccessParity(t, input, func() *SamplePair { return &SamplePair{Timestamp: Time(9), Value: SampleValue(9)} })
79 }
80 for _, input := range []string{`[`, `[1.123,"2" true`, `{}`} {
81 testDecodeErrorParity(t, input, func() *SamplePair { return &SamplePair{Timestamp: Time(9), Value: SampleValue(9)} })
82 }
83}

Callers

nothing calls this directly

Calls 6

TimeTypeAlias · 0.85
SampleValueTypeAlias · 0.85
testV1V2MarshalFunction · 0.85
testRoundTripFunction · 0.85
testDecodeSuccessParityFunction · 0.85
testDecodeErrorParityFunction · 0.85

Tested by

no test coverage detected