From cbb3acc0c2f23bf483852033f21b86bf801d24b7 Mon Sep 17 00:00:00 2001 From: qmuntal Date: Fri, 9 Jul 2021 08:35:11 +0200 Subject: [PATCH] fix UnusedID returning wrong ID --- core.go | 1 + core_test.go | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/core.go b/core.go index f4d3aeb..fa6424d 100644 --- a/core.go +++ b/core.go @@ -153,6 +153,7 @@ func (rs *Resources) UnusedID() uint32 { for i, id := range ids { if id != i { lowest = i + break } } if lowest == 0 { diff --git a/core_test.go b/core_test.go index aa6cb12..8ea9ed1 100644 --- a/core_test.go +++ b/core_test.go @@ -193,7 +193,9 @@ func TestResources_UnusedID(t *testing.T) { {"one-object", &Resources{Objects: []*Object{{ID: 2}}}, 1}, {"two", &Resources{Assets: []Asset{&BaseMaterials{ID: 1}}}, 2}, {"sequence", &Resources{Assets: []Asset{&BaseMaterials{ID: 1}}, Objects: []*Object{{ID: 2}}}, 3}, - {"sparce", &Resources{Assets: []Asset{&BaseMaterials{ID: 1}}, Objects: []*Object{{ID: 3}}}, 2}, + {"sparce", &Resources{Assets: []Asset{&BaseMaterials{ID: 12}}, Objects: []*Object{ + {ID: 6}, {ID: 4}, {ID: 8}, {ID: 10}, {ID: 2}}}, 1, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {