MCPcopy
hub / github.com/hashicorp/hcl / visRangeOffsets

Function visRangeOffsets

pos_test.go:449–470  ·  view source on GitHub ↗

visRangeOffsets is a helper that produces a visual representation of the start and end byte offsets of the given range, which can then be stacked with the same for other ranges to more easily see how the ranges relate to one another.

(rng Range)

Source from the content-addressed store, hash-verified

447// with the same for other ranges to more easily see how the ranges relate
448// to one another.
449func visRangeOffsets(rng Range) string {
450 var buf bytes.Buffer
451 if rng.End.Byte < rng.Start.Byte {
452 // Should never happen, but we'll visualize it anyway so we can
453 // more easily debug failing tests.
454 for i := 0; i < rng.End.Byte; i++ {
455 buf.WriteByte(' ')
456 }
457 for i := rng.End.Byte; i < rng.Start.Byte; i++ {
458 buf.WriteByte('!')
459 }
460 return buf.String()
461 }
462
463 for i := 0; i < rng.Start.Byte; i++ {
464 buf.WriteByte(' ')
465 }
466 for i := rng.Start.Byte; i < rng.End.Byte; i++ {
467 buf.WriteByte('#')
468 }
469 return buf.String()
470}

Callers 3

TestRangeOverFunction · 0.85
TestPosOverlapFunction · 0.85
TestRangePartitionAroundFunction · 0.85

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected