MCPcopy
hub / github.com/cli/cli / TestFormatSlice

Function TestFormatSlice

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

Source from the content-addressed store, hash-verified

57}
58
59func TestFormatSlice(t *testing.T) {
60 tests := []struct {
61 name string
62 values []string
63 indent uint
64 lineLength uint
65 prependWith string
66 appendWith string
67 sort bool
68 wants string
69 }{
70 {
71 name: "empty",
72 lineLength: 10,
73 values: []string{},
74 wants: "",
75 },
76 {
77 name: "empty with indent",
78 lineLength: 10,
79 indent: 2,
80 values: []string{},
81 wants: " ",
82 },
83 {
84 name: "single",
85 lineLength: 10,
86 values: []string{"foo"},
87 wants: "foo",
88 },
89 {
90 name: "single with indent",
91 lineLength: 10,
92 indent: 2,
93 values: []string{"foo"},
94 wants: " foo",
95 },
96 {
97 name: "long single with indent",
98 lineLength: 10,
99 indent: 2,
100 values: []string{"some-long-value"},
101 wants: " some-long-value",
102 },
103 {
104 name: "exact line length",
105 lineLength: 4,
106 values: []string{"a", "b"},
107 wants: "a, b",
108 },
109 {
110 name: "values longer than line length",
111 lineLength: 4,
112 values: []string{"long-value", "long-value"},
113 wants: "long-value,\nlong-value",
114 },
115 {
116 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