(t *testing.T)
| 709 | } |
| 710 | |
| 711 | func 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 | |
| 752 | func BenchmarkJSONMarshallingSampleHistogramPairMatrix(b *testing.B) { |
| 753 | for i := 0; i < b.N; i++ { |
nothing calls this directly
no test coverage detected
searching dependent graphs…