MCPcopy Create free account
hub / github.com/cli/cli / TestFormatSlice

Function TestFormatSlice

internal/text/text_test.go:91–181  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

89}
90
91func TestFormatSlice(t *testing.T) {
92 tests := []struct {
93 name string
94 values []string
95 indent uint
96 lineLength uint
97 prependWith string
98 appendWith string
99 sort bool
100 wants string
101 }{
102 {
103 name: "empty",
104 lineLength: 10,
105 values: []string{},
106 wants: "",
107 },
108 {
109 name: "empty with indent",
110 lineLength: 10,
111 indent: 2,
112 values: []string{},
113 wants: " ",
114 },
115 {
116 name: "single",
117 lineLength: 10,
118 values: []string{"foo"},
119 wants: "foo",
120 },
121 {
122 name: "single with indent",
123 lineLength: 10,
124 indent: 2,
125 values: []string{"foo"},
126 wants: " foo",
127 },
128 {
129 name: "long single with indent",
130 lineLength: 10,
131 indent: 2,
132 values: []string{"some-long-value"},
133 wants: " some-long-value",
134 },
135 {
136 name: "exact line length",
137 lineLength: 4,
138 values: []string{"a", "b"},
139 wants: "a, b",
140 },
141 {
142 name: "values longer than line length",
143 lineLength: 4,
144 values: []string{"long-value", "long-value"},
145 wants: "long-value,\nlong-value",
146 },
147 {
148 name: "zero line length (no wrapping expected)",

Callers

nothing calls this directly

Calls 3

FormatSliceFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected