package syntax import "testing" func FuzzByteColToRuneIndexInvariants(f *testing.F) { f.Add("abc", 0) f.Add("aéb", 1) f.Add("こんにちは", 5) f.Add("", 0) f.Fuzz(func(t *testing.T, s string, col int) { line := []byte(s) idx := byteColToRuneIndex(line, col) runes := []rune(s) if idx < 0 || idx > len(runes) { t.Fatalf("rune index out of bounds: idx=%d len=%d", idx, len(runes)) } if col <= 0 && idx != 0 { t.Fatalf("expected idx 0 for non-positive col, got %d", idx) } if col >= len(line) && idx != len(runes) { t.Fatalf("expected idx len(runes) for col>=len(bytes), got %d", idx) } if col > 0 && col < len(line) { expected := len([]rune(string(line[:col]))) if idx != expected { t.Fatalf("expected idx %d got %d", expected, idx) } } }) }