| 336 | } |
| 337 | |
| 338 | func TestRenderNegativePadding(t *testing.T) { |
| 339 | // Horizontal padding < 0. |
| 340 | b := NewBox().Padding(-1, 1).Style(Single) |
| 341 | if _, err := b.Render("Title", "Content"); err == nil { |
| 342 | t.Fatalf("expected error for negative horizontal padding, got nil") |
| 343 | } else if !strings.Contains(err.Error(), "horizontal padding cannot be negative") { |
| 344 | t.Errorf("unexpected error for negative horizontal padding: %v", err) |
| 345 | } |
| 346 | |
| 347 | // Vertical padding < 0. |
| 348 | b = NewBox().Padding(1, -1).Style(Single) |
| 349 | if _, err := b.Render("Title", "Content"); err == nil { |
| 350 | t.Fatalf("expected error for negative vertical padding, got nil") |
| 351 | } else if !strings.Contains(err.Error(), "vertical padding cannot be negative") { |
| 352 | t.Errorf("unexpected error for negative vertical padding: %v", err) |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | func TestRenderInvalidContentAlign(t *testing.T) { |
| 357 | b := NewBox().Padding(1, 1).Style(Single).ContentAlign(AlignType("Weird")) |