From 8fa36cc7ef62ef4eb88ea4155a94ee4aa5101c00 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Fri, 11 Nov 2022 19:25:52 +0900 Subject: [PATCH] internal/packing: improve test Updates #2327 --- internal/packing/packing_test.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/packing/packing_test.go b/internal/packing/packing_test.go index 5dba2eb45..ef1cc0aa7 100644 --- a/internal/packing/packing_test.go +++ b/internal/packing/packing_test.go @@ -254,7 +254,7 @@ func TestPage(t *testing.T) { } func TestAlloc(t *testing.T) { - p := packing.NewPage(1024, 4096) + p := packing.NewPage(1024, 2048) w, h := p.Size() p.Alloc(w/2, h/2) @@ -266,12 +266,18 @@ func TestAlloc(t *testing.T) { if n1 == nil { t.Errorf("p.Alloc failed: width: %d, height: %d", w/2, h*3/2) } + if p.Alloc(1, 1) != nil { + t.Errorf("p.Alloc(1, 1) must fail but not") + } p.Free(n1) + if p.Alloc(1, 1) == nil { + t.Errorf("p.Alloc(1, 1) failed") + } p.Free(n0) } func TestAlloc2(t *testing.T) { - p := packing.NewPage(1024, 4096) + p := packing.NewPage(1024, 2048) w, h := p.Size() p.Alloc(w/2, h/2) n1 := p.Alloc(w/2, h/2)