mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 20:58:34 +01:00
added tests for ensuring genericfont correctness compared to regular font
This commit is contained in:
parent
8078d41724
commit
60bc320604
1 changed files with 31 additions and 0 deletions
|
@ -1,5 +1,7 @@
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using MLEM.Extensions;
|
||||||
using MLEM.Font;
|
using MLEM.Font;
|
||||||
using MLEM.Formatting;
|
using MLEM.Formatting;
|
||||||
using MLEM.Formatting.Codes;
|
using MLEM.Formatting.Codes;
|
||||||
|
@ -117,5 +119,34 @@ namespace Tests {
|
||||||
Assert.AreEqual(ret.AllCodes.Length, 12);
|
Assert.AreEqual(ret.AllCodes.Length, 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestConsistency() {
|
||||||
|
void CompareSizes(string s) {
|
||||||
|
var spriteFont = ((GenericSpriteFont) this.font).Font;
|
||||||
|
Assert.AreEqual(spriteFont.MeasureString(s), this.font.MeasureString(s));
|
||||||
|
}
|
||||||
|
|
||||||
|
CompareSizes("This is a very simple test string");
|
||||||
|
CompareSizes("This\n is a very\nsimple test string");
|
||||||
|
CompareSizes("\nThis is a very simple test string");
|
||||||
|
CompareSizes("This is a very simple test string\n");
|
||||||
|
CompareSizes("This is a very simple test string\n\n\n\n\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSpecialCharacters() {
|
||||||
|
void CompareSizes(string s) {
|
||||||
|
var spriteFont = ((GenericSpriteFont) this.font).Font;
|
||||||
|
Assert.AreNotEqual(spriteFont.MeasureString(s), this.font.MeasureString(s));
|
||||||
|
}
|
||||||
|
|
||||||
|
CompareSizes($"This is a very simple{GenericFont.Nbsp}test string");
|
||||||
|
CompareSizes($"This is a very simple{GenericFont.OneEmSpace}test string");
|
||||||
|
CompareSizes($"This is a very simple{GenericFont.Zwsp}test string");
|
||||||
|
|
||||||
|
Assert.AreEqual(new Vector2(this.font.LineHeight, this.font.LineHeight), this.font.MeasureString(GenericFont.OneEmSpace.ToCachedString()));
|
||||||
|
Assert.AreEqual(new Vector2(0, this.font.LineHeight), this.font.MeasureString(GenericFont.Zwsp.ToCachedString()));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue