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

Function TestSampleValueJSONV2

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

Source from the content-addressed store, hash-verified

22)
23
24func TestSampleValueJSONV2(t *testing.T) {
25 cases := []float64{
26 math.Inf(1),
27 math.MaxFloat64,
28 math.MaxFloat32,
29 math.SmallestNonzeroFloat64,
30 math.SmallestNonzeroFloat32,
31 1e21,
32 1.0,
33 1e-6,
34 0,
35 -1e-6,
36 -1.0,
37 -1e21,
38 -math.MaxFloat64,
39 -math.MaxFloat32,
40 -math.SmallestNonzeroFloat64,
41 -math.SmallestNonzeroFloat32,
42 math.Inf(-1),
43 math.NaN(),
44 }
45
46 for _, i := range cases {
47 t.Run(fmt.Sprintf("%v", i), func(t *testing.T) {
48 if i != -math.MaxFloat64 {
49 testV1V2Marshal(t, "-", SampleValue(math.Nextafter(i, math.Inf(-1))))
50 }
51 testV1V2Marshal(t, "=", SampleValue(i))
52 if i != math.MaxFloat64 {
53 testV1V2Marshal(t, "+", SampleValue(math.Nextafter(i, math.Inf(1))))
54 }
55 })
56 }
57 testRoundTrip(t, "-1", SampleValue(-1))
58 testRoundTrip(t, "-1.1", SampleValue(-1.1))
59 testRoundTrip(t, "0", SampleValue(0))
60 testRoundTrip(t, "1", SampleValue(1))
61 testRoundTrip(t, "1.1", SampleValue(1.1))
62}
63
64func TestSamplePairJSONV2(t *testing.T) {
65 cases := []SamplePair{

Callers

nothing calls this directly

Calls 3

testV1V2MarshalFunction · 0.85
SampleValueTypeAlias · 0.85
testRoundTripFunction · 0.85

Tested by

no test coverage detected