Update of /cvsroot/hmath/org.hartmath.tex2mml.test/src/org/hartmath/tex2mml/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25438/src/org/hartmath/tex2mml/test
Added Files:
ParserTestCase.java
Log Message:
Initial TeX to MathML module
--- NEW FILE: ParserTestCase.java ---
package org.hartmath.tex2mml.test;
import junit.framework.TestCase;
//import org.hartmath.core.expression.ExpressionFactory;
import org.hartmath.tex2mml.TeXParser;
/**
* Tests parser funciond for SimpleParserFactory
*/
public class ParserTestCase extends TestCase {
TeXParser parser;
public ParserTestCase(String name) {
super(name);
}
public void testParser() {
tex2mml(
"\\sum_{n=0}^\\infty",
"<m:mrow><m:munderover><m:mo>∑</m:mo><m:mrow><m:mi>n</m:mi><m:mo>=</m:mo><m:mn>0</m:mn></m:mrow><m:mo>∞</m:mo></m:munderover></m:mrow>");
tex2mml(
"\\mathbb{ABCDEFGHIJKLMNOPQRSTUVWXYZ}",
"<m:mi>ℂℍℕℙℚℝℤ</m:mi>");
tex2mml(
"x 2+\\frac{b}{a}x+\\frac{c}{a}=0",
"<m:mrow><m:mi>x</m:mi><m:mn>2</m:mn><m:mo>+</m:mo><m:mfrac><m:mi>b</m:mi><m:mi>a</m:mi></m:mfrac><m:mi>x</m:mi><m:mo>+</m:mo><m:mfrac><m:mi>c</m:mi><m:mi>a</m:mi></m:mfrac><m:mo>=</m:mo><m:mn>0</m:mn></m:mrow>");
tex2mml(
"x 2+\\frac{b}{a x}+\\frac{c}{a}=0",
"<m:mrow><m:mi>x</m:mi><m:mn>2</m:mn><m:mo>+</m:mo><m:mfrac><m:mi>b</m:mi><m:mrow><m:mi>a</m:mi><m:mi>x</m:mi></m:mrow></m:mfrac><m:mo>+</m:mo><m:mfrac><m:mi>c</m:mi><m:mi>a</m:mi></m:mfrac><m:mo>=</m:mo><m:mn>0</m:mn></m:mrow>");
tex2mml(
"x 2+y_1+z_1234",
"<m:mrow><m:mi>x</m:mi><m:mn>2</m:mn><m:mo>+</m:mo><m:msub><m:mi>y</m:mi><m:mn>1</m:mn></m:msub><m:mo>+</m:mo><m:msub><m:mi>z</m:mi><m:mn>1234</m:mn></m:msub></m:mrow>");
tex2mml("\\frac{1}{2}", "<m:mfrac><m:mn>1</m:mn><m:mn>2</m:mn></m:mfrac>");
tex2mml("a_b", "<m:mrow><m:msub><m:mi>a</m:mi><m:mi>b</m:mi></m:msub></m:mrow>");
tex2mml("a", "<m:mi>a</m:mi>");
tex2mml("\\alpha", "<m:mi>α</m:mi>");
}
public void tex2mml(String tex, String mml) {
StringBuffer buf = new StringBuffer();
parser.initialize(tex);
parser.start(buf);
assertEquals(buf.toString(), mml);
}
/**
* The JUnit setup method
*/
protected void setUp() {
parser = new TeXParser("");
}
}
|