/** * Translates the given infix formula into MathML. * * @return the MathML as a string. The caller owns the memory and is * responsible for freeing it. */ char * translateInfix (const char* formula, L3ParserSettings_t* settings) { char* result; ASTNode_t* math = SBML_parseL3FormulaWithSettings(formula, settings); if (math==NULL) { result = SBML_getLastParseL3Error(); } else { result = writeMathMLToString(math); ASTNode_free(math); } return result; }
END_TEST #if (0) START_TEST (test_parse_function_matrix_empty) { const char* expected = wrapMathML ( " <matrix/>\n" ); N = SBML_parseL3Formula("matrix()"); S = writeMathMLToString(N); fail_unless( equals(expected, S) ); }
END_TEST #endif START_TEST (test_parse_function_vector_0args) { const char* expected = wrapMathML ( " <vector/>\n" ); N = SBML_parseL3Formula("vector()"); S = writeMathMLToString(N); fail_unless( equals(expected, S) ); }
END_TEST START_TEST (test_parse_function_vector_1args) { const char* expected = wrapMathML ( " <vector>\n" " <ci> x </ci>\n" " </vector>\n" ); N = SBML_parseL3Formula("vector(x)"); S = writeMathMLToString(N); fail_unless( equals(expected, S) ); }
END_TEST START_TEST (test_parse_function_determinant) { const char* expected = wrapMathML ( " <apply>\n" " <determinant/>\n" " <ci> a </ci>\n" " </apply>\n" ); N = SBML_parseL3Formula("determinant(a)"); S = writeMathMLToString(N); fail_unless( equals(expected, S) ); }
END_TEST START_TEST (test_parse_function_selector_1args) { const char* expected = wrapMathML ( " <apply>\n" " <selector/>\n" " <ci> a </ci>\n" " </apply>\n" ); N = SBML_parseL3Formula("selector(a)"); S = writeMathMLToString(N); fail_unless( equals(expected, S) ); }
END_TEST START_TEST (test_parse_function_matrix_emptyrows) { ASTNode_t *r = SBML_parseL3Formula("matrix(matrixrow(), matrixrow())"); const char* expected = wrapMathML ( " <matrix>\n" " <matrixrow/>\n" " <matrixrow/>\n" " </matrix>\n" ); N = SBML_parseL3Formula("matrix(matrixrow(), matrixrow())"); S = writeMathMLToString(N); fail_unless( equals(expected, S) ); }
END_TEST START_TEST (test_parse_function_outer) { const char* expected = wrapMathML ( " <apply>\n" " <outerproduct/>\n" " <ci> a </ci>\n" " <ci> x </ci>\n" " </apply>\n" ); N = SBML_parseL3Formula("outer(a, x)"); S = writeMathMLToString(N); fail_unless( equals(expected, S) ); }
LIBSBML_CPP_NAMESPACE_USE CK_CPPSTART #endif START_TEST (test_parse_brackets_0args) { const char* expected = wrapMathML ( " <apply>\n" " <selector/>\n" " <ci> a </ci>\n" " </apply>\n" ); N = SBML_parseL3Formula("a[]"); S = writeMathMLToString(N); fail_unless( equals(expected, S) ); }
END_TEST START_TEST (test_parse_function_matrix_1row) { const char* expected = wrapMathML ( " <matrix>\n" " <matrixrow>\n" " <ci> x </ci>\n" " <ci> y </ci>\n" " </matrixrow>\n" " </matrix>\n" ); N = SBML_parseL3Formula("matrix(matrixrow(x, y))"); S = writeMathMLToString(N); fail_unless( equals(expected, S) ); }
END_TEST START_TEST (test_parse_brackets_2args) { const char* expected = wrapMathML ( " <apply>\n" " <selector/>\n" " <ci> a </ci>\n" " <ci> x </ci>\n" " <ci> y </ci>\n" " </apply>\n" ); N = SBML_parseL3Formula("a[x, y]"); S = writeMathMLToString(N); fail_unless( equals(expected, S) ); }
END_TEST START_TEST (test_parse_curlybraces_semicolons_short) { const char* expected = wrapMathML ( " <matrix>\n" " <matrixrow>\n" " <ci> x </ci>\n" " </matrixrow>\n" " <matrixrow>\n" " <ci> p </ci>\n" " </matrixrow>\n" " </matrix>\n" ); N = SBML_parseL3Formula("{x; p}"); S = writeMathMLToString(N); fail_unless( equals(expected, S) ); }
END_TEST START_TEST (test_parse_curlybraces_2args) { const char* expected = wrapMathML ( " <vector>\n" " <ci> x </ci>\n" " <apply>\n" " <power/>\n" " <ci> a </ci>\n" " <ci> b </ci>\n" " </apply>\n" " </vector>\n" ); N = SBML_parseL3Formula("{x, a^b}"); S = writeMathMLToString(N); fail_unless( equals(expected, S) ); }
END_TEST START_TEST (test_parse_function_selector_needNoParens2) { const char* expected = wrapMathML ( " <apply>\n" " <selector/>\n" " <vector>\n" " <cn type=\"integer\"> 1 </cn>\n" " <cn type=\"integer\"> 2 </cn>\n" " <cn type=\"integer\"> 3 </cn>\n" " <cn type=\"integer\"> 4 </cn>\n" " </vector>\n" " <ci> x </ci>\n" " </apply>\n" ); N = SBML_parseL3Formula("selector({1, 2, 3, 4},x)"); S = writeMathMLToString(N); fail_unless( equals(expected, S) ); }