Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions bindings/js/tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,19 @@ test("Addition of Real Numbers", async () => {
const addResult = Oasis.Simplify(add);
const addResultStr = Oasis.ToMathMLString(addResult);
assert.equal(addResultStr, "<mn>4</mn>\n");
});

test("Parsing and Serializing of Integrals", async () => {
const Oasis = await loadOasis();
const integral = Oasis.FromInFix("in ( 1 , x )");
const integralML = Oasis.ToMathMLString(integral);
assert.equal(integralML, `<mrow>
<mo>∫</mo>
<mn>1</mn>
<mrow>
<mo>d</mo>
<mi>x</mi>
</mrow>
</mrow>
`);
});
2 changes: 1 addition & 1 deletion io/src/MathMLSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ auto MathMLSerializer::TypedVisit(const Integral<>& integral) -> RetT

// Integral symbol
tinyxml2::XMLElement* inte = doc.NewElement("mo");
inte->SetText("&int;");
inte->SetText(reinterpret_cast<const char*>(u8"\u222B"));

tinyxml2::XMLElement* dNode = doc.NewElement("mo");
dNode->SetText("d");
Expand Down
42 changes: 31 additions & 11 deletions io/tests/MathMLTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "Oasis/Add.hpp"
#include "Oasis/Divide.hpp"
#include "Oasis/Integral.hpp"
#include "Oasis/Multiply.hpp"
#include "Oasis/Matrix.hpp"
#include "Oasis/Variable.hpp"
Expand Down Expand Up @@ -238,14 +239,33 @@ TEST_CASE("Matrix to MathML 3x2", "[Matrix][MathML]")
// std::cout<<mathml<<std::endl;
REQUIRE(expected == mathml);
}
//
//TEST_CASE("Test Magnitude", "[Magnitude]")
//{
// Oasis::Magnitude m{Oasis::Real{-5}};
//
// tinyxml2::XMLDocument doc;
// Oasis::MathMLSerializer serializer(doc);
//
// m.Serialize(serializer);
//
//}

TEST_CASE("Integral works", "[Integral][MathML]")
{
Oasis::Integral in {
Oasis::Real { 1 },
Oasis::Variable { "x" }
};


tinyxml2::XMLDocument doc;
Oasis::MathMLSerializer serializer(doc);
doc.InsertEndChild(in.Accept(serializer).value());

tinyxml2::XMLPrinter printer;
doc.Print(&printer);

std::string mathml { printer.CStr() };

std::string expected = reinterpret_cast<const char*>(u8R"(<mrow>
<mo>∫</mo>
<mn>1</mn>
<mrow>
<mo>d</mo>
<mi>x</mi>
</mrow>
</mrow>
)");

REQUIRE(expected == mathml);
}
Loading