MCPcopy Create free account
hub / github.com/segmentio/encoding / TestIndent

Function TestIndent

json/golang_scanner_test.go:105–123  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

103}
104
105func TestIndent(t *testing.T) {
106 var buf bytes.Buffer
107 for _, tt := range examples {
108 buf.Reset()
109 if err := Indent(&buf, []byte(tt.indent), "", "\t"); err != nil {
110 t.Errorf("Indent(%#q): %v", tt.indent, err)
111 } else if s := buf.String(); s != tt.indent {
112 t.Errorf("Indent(%#q) = %#q, want original", tt.indent, s)
113 }
114
115 buf.Reset()
116 if err := Indent(&buf, []byte(tt.compact), "", "\t"); err != nil {
117 t.Errorf("Indent(%#q): %v", tt.compact, err)
118 continue
119 } else if s := buf.String(); s != tt.indent {
120 t.Errorf("Indent(%#q) = %#q, want %#q", tt.compact, s, tt.indent)
121 }
122 }
123}
124
125// Tests of a large random structure.
126

Callers

nothing calls this directly

Calls 3

IndentFunction · 0.85
StringMethod · 0.65
ResetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…