stuff-from-scratch/test/publishing/TestLatexConverter.cpp

29 lines
894 B
C++
Raw Normal View History

2023-01-12 09:18:16 +00:00
#include "TestFramework.h"
#include "TestUtils.h"
2023-01-12 10:58:43 +00:00
#include "TestRenderUtils.h"
2023-01-12 09:18:16 +00:00
#include "StringUtils.h"
#include "EquationNode.h"
#include "LatexMathExpression.h"
2023-01-12 09:18:16 +00:00
TEST_CASE(TestLatexConverter, "publishing")
{
2023-01-26 11:27:35 +00:00
auto expression = std::make_unique<LatexMathExpression>("\\psi = \\frac{\\alpha + \\beta}{c + d} + \\ket{e}");
auto equation_node = std::make_unique<EquationNode>(Point(10, 10));
equation_node->setContent(expression.get());
2023-01-12 10:58:43 +00:00
auto psi = LatexSymbolLookup::getSymbolUtf8("psi");
auto alpha = LatexSymbolLookup::getSymbolUtf8("alpha");
auto beta = LatexSymbolLookup::getSymbolUtf8("beta");
auto content = *psi + " " + *alpha + " " + *beta + " ";
2023-01-12 09:18:16 +00:00
2023-01-12 10:58:43 +00:00
TestRenderer renderer(800, 800);
2023-01-12 09:18:16 +00:00
renderer.getScene()->addNode(equation_node.get());
renderer.writeSvg(TestUtils::getTestOutputDir(__FILE__) / "out.svg");
2023-01-12 10:58:43 +00:00
renderer.write(TestUtils::getTestOutputDir(__FILE__) / "out.png");
2023-01-12 09:18:16 +00:00
};