Esempio n. 1
0
        public void TestMatrix(string env, string left, string right, string leftOutput, string rightOutput)
        {
            var   list = LaTeXBuilder.MathListFromLaTeX($@"\begin{{{env}}} x & y \\ z & w \end{{{env}}}");
            Table table;

            if (left is null && right is null)
            {
                table = Assert.IsType <Table>(Assert.Single(list));
            }
Esempio n. 2
0
        public void TestUnderline()
        {
            var list = LaTeXBuilder.MathListFromLaTeX(@"\underline 2");

            Assert.Collection(list,
                              CheckAtom <Underline>("", underline =>
                                                    Assert.Collection(underline.InnerList, CheckAtom <Number>("2"))
                                                    )
                              );
            Assert.Equal(@"\underline{2}", LaTeXBuilder.MathListToLaTeX(list).ToString());
        }
Esempio n. 3
0
        public void TestAccent()
        {
            var list = LaTeXBuilder.MathListFromLaTeX(@"\bar x");

            Assert.Collection(list,
                              CheckAtom <Accent>("\u0304", accent =>
                                                 Assert.Collection(accent.InnerList, CheckAtom <Variable>("x"))
                                                 )
                              );
            Assert.Equal(@"\bar{x}", LaTeXBuilder.MathListToLaTeX(list).ToString());
        }
Esempio n. 4
0
        public void TestMathStyle()
        {
            var list = LaTeXBuilder.MathListFromLaTeX(@"\textstyle y \scriptstyle x");

            Assert.Collection(list,
                              CheckAtom <Style>("", style => Assert.Equal(LineStyle.Text, style.LineStyle)),
                              CheckAtom <Variable>("y"),
                              CheckAtom <Style>("", style2 => Assert.Equal(LineStyle.Script, style2.LineStyle)),
                              CheckAtom <Variable>("x")
                              );
            Assert.Equal(@"\textstyle y\scriptstyle x", LaTeXBuilder.MathListToLaTeX(list).ToString());
        }
Esempio n. 5
0
        public void TestRadical()
        {
            var list = LaTeXBuilder.MathListFromLaTeX(@"\sqrt[3]2");

            Assert.Collection(list,
                              CheckAtom <Radical>("", radical => {
                Assert.Collection(radical.Degree, CheckAtom <Number>("3"));
                Assert.Collection(radical.Radicand, CheckAtom <Number>("2"));
            })
                              );
            Assert.Equal(@"\sqrt[3]{2}", LaTeXBuilder.MathListToLaTeX(list).ToString());
        }
Esempio n. 6
0
        public void TestListFinalizedCopy()
        {
            var input = @"-52x^{13+y}_{15-} + (-12.3 *)\frac{-12}{15.2}\int^\sqrt[!\ ]{=(}_0 \theta";
            var list  = LaTeXBuilder.MathListFromLaTeX(input);

            Assert.ThrowsAny <Xunit.Sdk.XunitException>(() => CheckListContents(list));
            Assert.ThrowsAny <Xunit.Sdk.XunitException>(() => CheckListContents(list.Clone(false)));
            Assert.All(list, a => Assert.Equal(Range.Zero, a.IndexRange));
            var finalized = list.Clone(true);

            CheckListContents(finalized);
            CheckListContents(finalized.Clone(false));
            CheckListContents(finalized.Clone(true));
Esempio n. 7
0
        public void TestChooseBrackBraceBinomial(string input, string output, string left, string right)
        {
            var list = LaTeXBuilder.MathListFromLaTeX(input);

            Assert.Collection(list,
                              CheckAtom <Fraction>("", fraction => {
                Assert.False(fraction.HasRule);
                Assert.Equal(left, fraction.LeftDelimiter);
                Assert.Equal(right, fraction.RightDelimiter);
                Assert.Collection(fraction.Numerator, CheckAtom <Variable>("n"));
                Assert.Collection(fraction.Denominator, CheckAtom <Variable>("k"));
            })
                              );
            Assert.Equal(output, LaTeXBuilder.MathListToLaTeX(list).ToString());
        }
Esempio n. 8
0
        public void TestOverAndAtop(string input, string output, bool hasRule)
        {
            var list = LaTeXBuilder.MathListFromLaTeX(input);

            Assert.Collection(list,
                              CheckAtom <Fraction>("", fraction => {
                Assert.Equal(hasRule, fraction.HasRule);
                Assert.Null(fraction.LeftDelimiter);
                Assert.Null(fraction.RightDelimiter);
                Assert.Collection(fraction.Numerator, CheckAtom <Number>("1"));
                Assert.Collection(fraction.Denominator, CheckAtom <Variable>("c"));
            })
                              );
            Assert.Equal(output, LaTeXBuilder.MathListToLaTeX(list).ToString());
        }
Esempio n. 9
0
        public void TestSqrtInSqrt()
        {
            var list = LaTeXBuilder.MathListFromLaTeX(@"\sqrt\sqrt2");

            Assert.Collection(list,
                              CheckAtom <Radical>("", radical =>
                                                  Assert.Collection(radical.Radicand,
                                                                    CheckAtom <Radical>("", subRadical =>
                                                                                        Assert.Collection(subRadical.Radicand, CheckAtom <Number>("2"))
                                                                                        )
                                                                    )
                                                  )
                              );
            Assert.Equal(@"\sqrt{\sqrt{2}}", LaTeXBuilder.MathListToLaTeX(list).ToString());
        }
Esempio n. 10
0
        public void TestFraction()
        {
            var list = LaTeXBuilder.MathListFromLaTeX(@"\frac1c");

            Assert.Collection(list,
                              CheckAtom <Fraction>("", fraction => {
                Assert.True(fraction.HasRule);
                Assert.Null(fraction.LeftDelimiter);
                Assert.Null(fraction.RightDelimiter);
                Assert.Collection(fraction.Numerator, CheckAtom <Number>("1"));
                Assert.Collection(fraction.Denominator, CheckAtom <Variable>("c"));
            })
                              );
            Assert.Equal(@"\frac{1}{c}", LaTeXBuilder.MathListToLaTeX(list).ToString());
        }
Esempio n. 11
0
        public void TestFractionInFraction()
        {
            var list = LaTeXBuilder.MathListFromLaTeX(@"\frac1\frac23");

            Assert.Collection(list,
                              CheckAtom <Fraction>("", fraction => {
                Assert.Collection(fraction.Numerator, CheckAtom <Number>("1"));
                Assert.Collection(fraction.Denominator,
                                  CheckAtom <Fraction>("", subFraction => {
                    Assert.Collection(subFraction.Numerator, CheckAtom <Number>("2"));
                    Assert.Collection(subFraction.Denominator, CheckAtom <Number>("3"));
                })
                                  );
            })
                              );
            Assert.Equal(@"\frac{1}{\frac{2}{3}}", LaTeXBuilder.MathListToLaTeX(list).ToString());
        }
Esempio n. 12
0
        public void TestMathSpace()
        {
            var list = LaTeXBuilder.MathListFromLaTeX(@"\!\,\:\>\;\mskip15mu\quad\mkern36mu\qquad");

            Assert.Collection(list,
                              CheckAtom <Space>("", space => {
                Assert.Equal(-3, space.Length);
                Assert.True(space.IsMu);
            }),
                              CheckAtom <Space>("", space => {
                Assert.Equal(3, space.Length);
                Assert.True(space.IsMu);
            }),
                              CheckAtom <Space>("", space => {
                Assert.Equal(4, space.Length);
                Assert.True(space.IsMu);
            }),
                              CheckAtom <Space>("", space => {
                Assert.Equal(4, space.Length);
                Assert.True(space.IsMu);
            }),
                              CheckAtom <Space>("", space => {
                Assert.Equal(5, space.Length);
                Assert.True(space.IsMu);
            }),
                              CheckAtom <Space>("", space => {
                Assert.Equal(15, space.Length);
                Assert.True(space.IsMu);
            }),
                              CheckAtom <Space>("", space => {
                Assert.Equal(18, space.Length);
                Assert.True(space.IsMu);
            }),
                              CheckAtom <Space>("", space => {
                Assert.Equal(36, space.Length);
                Assert.True(space.IsMu);
            }),
                              CheckAtom <Space>("", space => {
                Assert.Equal(36, space.Length);
                Assert.True(space.IsMu);
            })
                              );
            Assert.Equal(@"\! \, \: \: \; \mkern15.0mu\quad \qquad \qquad ", LaTeXBuilder.MathListToLaTeX(list).ToString());
        }
Esempio n. 13
0
 void TestOuter(string latex, int rangeMax, double ascent, double descent, double width,
                params System.Action <IDisplay <TFont, TGlyph> >[] inspectors) =>
 TestList(rangeMax, ascent, descent, width, 0, 0, LinePosition.Regular, Range.UndefinedInt, inspectors)
     (Typesetter.CreateLine(LaTeXBuilder.MathListFromLaTeX(latex), _font, _context, LineStyle.Display));