Skip to content

Commit

Permalink
🚧Refactor GlyphMetrics to readonly record (#820)
Browse files Browse the repository at this point in the history
* Start work for issue #803

* Refactor: GlyphMetrics struct to readonly record struct.

* Fix "GameHelpers-> ApplySize" return value override actual values.

* Refactor: Fix tests using "with" for "readonly record struct" initializations.

* Clean up

* Only use the "with" keyword when it is needed (avoid unnecessary copy).

* Remove old struct custom tests.
  • Loading branch information
map-b authored Nov 27, 2023
1 parent 76bdcf9 commit 1690172
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 564 deletions.
32 changes: 17 additions & 15 deletions Testing/VelaptorTests/GameHelpersTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -338,21 +338,23 @@ public void ApplySize_WithRectangleF_ReturnsCorrectResult()
public void ApplySize_WithGlyphMetrics_ReturnsCorrectResult()
{
// Arrange
var metrics = default(GlyphMetrics);
metrics.Glyph = 'V';
metrics.GlyphBounds = new RectangleF(2f, 4f, 6f, 8f);
metrics.Ascender = 2f;
metrics.Descender = 2f;
metrics.HorizontalAdvance = 2f;
metrics.HoriBearingX = 2f;
metrics.HoriBearingY = 2f;
metrics.GlyphWidth = 2f;
metrics.GlyphHeight = 2f;
metrics.XMin = 2f;
metrics.XMax = 2f;
metrics.YMin = 2f;
metrics.YMax = 2f;
metrics.CharIndex = 123u;
var metrics = new GlyphMetrics
{
Glyph = 'V',
GlyphBounds = new RectangleF(2f, 4f, 6f, 8f),
Ascender = 2f,
Descender = 2f,
HorizontalAdvance = 2f,
HoriBearingX = 2f,
HoriBearingY = 2f,
GlyphWidth = 2f,
GlyphHeight = 2f,
XMin = 2f,
XMax = 2f,
YMin = 2f,
YMax = 2f,
CharIndex = 123u,
};

// Act
var actual = metrics.ApplySize(2f);
Expand Down
Loading

0 comments on commit 1690172

Please sign in to comment.