Bound repair feedback construction
This commit is contained in:
@@ -298,6 +298,23 @@ func TestFormatRepairDiagnosticsBoundsAndPreservesData(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestFormatRepairDiagnosticsEmptyAndEscapedOversize(t *testing.T) {
|
||||
for _, values := range [][]string{nil, {}} {
|
||||
if got := formatRepairDiagnostics(values); got != "[]" {
|
||||
t.Fatalf("empty diagnostics = %q", got)
|
||||
}
|
||||
}
|
||||
value := strings.Repeat("<&>\x00\xff\xfe", maxRepairDiagnosticBytes)
|
||||
encoded := formatRepairDiagnostics([]string{value})
|
||||
var got []string
|
||||
if err := json.Unmarshal([]byte(encoded), &got); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(encoded) > maxRepairDiagnosticBytes || len(got) != 2 || got[1] != omittedRepairDiagnostics || !strings.HasPrefix(strings.ToValidUTF8(value, "\uFFFD"), got[0]) {
|
||||
t.Fatalf("oversize diagnostics length=%d, values=%d", len(encoded), len(got))
|
||||
}
|
||||
}
|
||||
|
||||
func manyRepairDiagnostics() []string {
|
||||
diagnostics := make([]string, 1_000)
|
||||
for index := range diagnostics {
|
||||
|
||||
Reference in New Issue
Block a user