(t *testing.T)
| 151 | } |
| 152 | |
| 153 | func 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 | |
| 202 | func TestHPaddingAndVPadding(t *testing.T) { |
| 203 | b := NewBox().Padding(1, 2) |
nothing calls this directly
no test coverage detected