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

Function TestMatrixHistogramJSON

model/value_histogram_test.go:711–750  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

709}
710
711func TestMatrixHistogramJSON(t *testing.T) {
712 input := []struct {
713 plain string
714 value Matrix
715 }{
716 {
717 plain: `[]`,
718 value: Matrix{},
719 },
720 {
721 plain: sampleHistogramPairMatrixPlain,
722 value: sampleHistogramPairMatrixValue,
723 },
724 }
725
726 for _, test := range input {
727 b, err := json.Marshal(test.value)
728 if err != nil {
729 t.Error(err)
730 continue
731 }
732
733 trimmed := noWhitespace.ReplaceAllString(test.plain, "")
734 if string(b) != trimmed {
735 t.Errorf("encoding error: expected %q, got %q", trimmed, b)
736 continue
737 }
738
739 var mat Matrix
740 err = json.Unmarshal(b, &mat)
741 if err != nil {
742 t.Error(err)
743 continue
744 }
745
746 if !reflect.DeepEqual(mat, test.value) {
747 t.Errorf("decoding error: expected %v, got %v", test.value, mat)
748 }
749 }
750}
751
752func BenchmarkJSONMarshallingSampleHistogramPairMatrix(b *testing.B) {
753 for i := 0; i < b.N; i++ {

Callers

nothing calls this directly

Calls 1

ErrorMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…