Files
MonoGame.Extended/tests/MonoGame.Extended.Tests/Graphics/Texture2DAtlasTests.cs
T
Christopher WhitleyandGitHub 50c9f04910 Auto Genereate Region Names in Textture2DAtlas.Create (#1014)
* Generate unique names for regions

Region names previously were generated using the name + bounds.  This was removed in #997 which caused a regression bug.

This is now fixed, and region names are generated using the common format of "name_index"

* Add tests for issue #1013
2025-08-16 16:20:27 -04:00

24 lines
900 B
C#

using System;
using MonoGame.Extended.Graphics;
namespace MonoGame.Extended.Tests.Graphics;
public sealed class Texture2DAtlasTests
{
// Reference: https://github.com/MonoGame-Extended/Monogame-Extended/issues/1013
// Region names being generated during TextureAtlas.Create were not unique
// which was leading to an exception being thrown after the first region was
// added
[Fact]
public void CalculateRegions_ShouldGenerateUniqueRegionNames()
{
ReadOnlySpan<Texture2DAtlas.CalculatedRegion> regions = Texture2DAtlas.CalculateRegions("spritesheet", 64, 64, 32, 32, int.MaxValue, 0, 0);
Assert.Equal(4, regions.Length);
Assert.Equal("spritesheet_0", regions[0].Name);
Assert.Equal("spritesheet_1", regions[1].Name);
Assert.Equal("spritesheet_2", regions[2].Name);
Assert.Equal("spritesheet_3", regions[3].Name);
}
}