github.com/hashicorp/hcl/v2@v2.20.0/json/fuzz/fuzz_test.go (about)

     1  // Copyright (c) HashiCorp, Inc.
     2  // SPDX-License-Identifier: MPL-2.0
     3  
     4  package fuzzjson
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/hashicorp/hcl/v2/json"
    10  )
    11  
    12  func FuzzParse(f *testing.F) {
    13  	f.Fuzz(func(t *testing.T, data []byte) {
    14  		_, diags := json.Parse(data, "<fuzz-conf>")
    15  
    16  		if diags.HasErrors() {
    17  			t.Logf("Error when parsing JSON %v", data)
    18  			for _, diag := range diags {
    19  				t.Logf("- %s", diag.Error())
    20  			}
    21  		}
    22  	})
    23  }