MCPcopy Index your code
hub / github.com/box-cli-maker/box-cli-maker / TestBoxCopy

Function TestBoxCopy

box_render_test.go:153–200  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

151}
152
153func TestBoxCopy(t *testing.T) {
154 t.Run("independent copies", func(t *testing.T) {
155 original := NewBox().
156 Padding(1, 2).
157 Color(Red).
158 TitleColor(Blue).
159 ContentColor(Yellow).
160 TitlePosition(Top).
161 Style(Double).
162 WrapContent(true).
163 WrapLimit(30)
164 original.TopLeft("[").TopRight("]").BottomLeft("{").BottomRight("}").Horizontal("-").Vertical("|")
165
166 clone := original.Copy()
167 if clone == nil {
168 t.Fatalf("expected non-nil copy")
169 }
170 if clone == original {
171 t.Fatalf("Copy should return a distinct pointer")
172 }
173
174 clone.Color(Green).Padding(5, 6).TitlePosition(Bottom).TopLeft("*")
175 if original.color != Red {
176 t.Fatalf("expected original color to remain Red, got %q", original.color)
177 }
178 if original.px != 1 || original.py != 2 {
179 t.Fatalf("expected original padding (1,2), got (%d,%d)", original.px, original.py)
180 }
181 if original.titlePos != Top {
182 t.Fatalf("expected original title position to stay Top, got %v", original.titlePos)
183 }
184 if original.topLeft != "[" {
185 t.Fatalf("expected original topLeft to stay '[', got %q", original.topLeft)
186 }
187
188 original.Color(Magenta)
189 if clone.color != Green {
190 t.Fatalf("expected clone color to remain Green after mutating original, got %q", clone.color)
191 }
192 })
193
194 t.Run("nil receiver", func(t *testing.T) {
195 var b *Box
196 if copy := b.Copy(); copy != nil {
197 t.Fatalf("expected nil copy from nil receiver, got %#v", copy)
198 }
199 })
200}
201
202func TestHPaddingAndVPadding(t *testing.T) {
203 b := NewBox().Padding(1, 2)

Callers

nothing calls this directly

Calls 15

CopyMethod · 0.95
NewBoxFunction · 0.85
WrapLimitMethod · 0.80
WrapContentMethod · 0.80
StyleMethod · 0.80
TitlePositionMethod · 0.80
ContentColorMethod · 0.80
TitleColorMethod · 0.80
ColorMethod · 0.80
PaddingMethod · 0.80
VerticalMethod · 0.80
HorizontalMethod · 0.80

Tested by

no test coverage detected