[Theory, InlineData('[', ']'), InlineData('(', '}'), InlineData('{', ']')] // Using ) confuses the test explorer... public void TestInner(char left, char right) => TestOuter($@"a\left{left}x\right{right}", 2, 14, 4, 43.333, d => Assert.IsType <TextLineDisplay <TFont, TGlyph> >(d), d => { var inner = Assert.IsType <InnerDisplay <TFont, TGlyph> >(d); Approximately.At(13.333, 0, inner.Position); Assert.Equal(new Range(1, 1), inner.Range); Assert.Equal(14, inner.Ascent); Assert.Equal(4, inner.Descent); Assert.Equal(30, inner.Width); var glyph = Assert.IsType <GlyphDisplay <TFont, TGlyph> >(inner.Left); Approximately.At(13.333, 0, glyph.Position); Assert.Equal(Range.NotFound, glyph.Range); Assert.False(glyph.HasScript); Assert.Equal(left, glyph.Glyph); TestList(1, 14, 4, 10, 23.333, 0, LinePosition.Regular, Range.UndefinedInt, d => { var line = Assert.IsType <TextLineDisplay <TFont, TGlyph> >(d); Assert.Single(line.Atoms); AssertText("x", line); Assert.Equal(new PointF(), line.Position); Assert.Equal(new Range(0, 1), d.Range); Assert.False(line.HasScript); })(inner.Inner); var glyph2 = Assert.IsType <GlyphDisplay <TFont, TGlyph> >(inner.Right); Approximately.At(33.333, 0, glyph2.Position); Assert.Equal(Range.NotFound, glyph2.Range); Assert.False(glyph2.HasScript); Assert.Equal(right, glyph2.Glyph); });
System.Action <IDisplay <TFont, TGlyph>?> TestList(int rangeMax, double ascent, double descent, double width, double x, double y, LinePosition linePos, int indexInParent, params System.Action <IDisplay <TFont, TGlyph> >[] inspectors) => d => { var list = Assert.IsType <ListDisplay <TFont, TGlyph> >(d); Assert.False(list.HasScript); Assert.Equal(new Range(0, rangeMax), list.Range); Approximately.Equal(ascent, list.Ascent); Approximately.Equal(descent, list.Descent); Approximately.Equal(width, list.Width); Approximately.At(x, y, list.Position); // may change as we implement more details? Assert.Equal(linePos, list.LinePosition); Assert.Equal(indexInParent, list.IndexInParent); Assert.Collection(list.Displays, inspectors); };
[Theory, InlineData("[", "]"), InlineData("(", @"\}"), InlineData(@"\{", "]")] // Using ) confuses the test explorer... public void TestInner(string left, string right) => TestOuter($@"a\left{left}x\right{right}", 2, 14, 4, 43.333, d => Assert.IsType <TextLineDisplay <TFont, TGlyph> >(d), d => { var inner = Assert.IsType <InnerDisplay <TFont, TGlyph> >(d); Approximately.At(13.333, 0, inner.Position); Assert.Equal(new Range(1, 1), inner.Range); Assert.Equal(14, inner.Ascent); Assert.Equal(4, inner.Descent); Assert.Equal(30, inner.Width); var glyph = Assert.IsType <GlyphDisplay <TFont, TGlyph> >(inner.Left); Approximately.At(13.333, 0, glyph.Position); Assert.Equal(Range.NotFound, glyph.Range); Assert.False(glyph.HasScript); Assert.Equal(left[^ 1], glyph.Glyph);
public void TestBinomial(string latex) => TestOuter(latex, 1, 27.54, 17.72, 30, TestList(1, 27.54, 17.72, 30, 0, 0, LinePosition.Regular, Range.UndefinedInt, d => { var glyph = Assert.IsType <GlyphDisplay <TFont, TGlyph> >(d); Assert.Equal(new PointF(), glyph.Position); Assert.Equal(Range.NotFound, glyph.Range); Assert.False(glyph.HasScript); }, d => { var subFraction = Assert.IsType <FractionDisplay <TFont, TGlyph> >(d); Assert.Equal(new Range(0, 1), subFraction.Range); Assert.False(subFraction.HasScript); Approximately.At(10, 0, subFraction.Position); TestList(1, 14, 4, 10, 10, 13.54, LinePosition.Regular, Range.UndefinedInt, dd => { var subNumerator = Assert.IsType <TextLineDisplay <TFont, TGlyph> >(dd); Assert.Single(subNumerator.Atoms); AssertText("1", subNumerator); Assert.Equal(new PointF(), subNumerator.Position); Assert.Equal(new Range(0, 1), subNumerator.Range); Assert.False(subNumerator.HasScript); })(subFraction.Numerator); TestList(1, 14, 4, 10, 10, -13.72, LinePosition.Regular, Range.UndefinedInt, dd => { var subDenominator = Assert.IsType <TextLineDisplay <TFont, TGlyph> >(dd); Assert.Single(subDenominator.Atoms); AssertText("3", subDenominator); Assert.Equal(new PointF(), subDenominator.Position); Assert.Equal(new Range(0, 1), subDenominator.Range); Assert.False(subDenominator.HasScript); })(subFraction.Denominator); }, d => { var subRight = Assert.IsType <GlyphDisplay <TFont, TGlyph> >(d); Assert.False(subRight.HasScript); Assert.Equal(Range.NotFound, subRight.Range); Approximately.At(20, 0, subRight.Position); }));