Skip to content

Commit

Permalink
fix UnusedID returning wrong ID
Browse files Browse the repository at this point in the history
  • Loading branch information
qmuntal committed Jul 9, 2021
1 parent e1d9c5d commit 15713ab
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions core.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ func (rs *Resources) UnusedID() uint32 {
for i, id := range ids {
if id != i {
lowest = i
break
}
}
if lowest == 0 {
Expand Down
4 changes: 3 additions & 1 deletion core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 15713ab

Please sign in to comment.