Skip to content

Commit

Permalink
[unit] L, R test cases are Boost version proof
Browse files Browse the repository at this point in the history
  • Loading branch information
ajay-mk committed Jan 24, 2024
1 parent 4187eb8 commit 2175f5b
Showing 1 changed file with 53 additions and 23 deletions.
76 changes: 53 additions & 23 deletions tests/unit/test_mbpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,42 +454,72 @@ TEST_CASE("NBodyOp", "[mbpt]") {
expr->visit(op_lowerer, /* atoms only = */ true);
};

// TODO: Make these tests Boost version proof
auto R33 = mbpt::sr::op::R(3, 3);
lower_to_tensor_form(R33);
simplify(R33);
// std::wcout << "R33: " << to_latex(R33) << std::endl;
REQUIRE(to_latex(R33) ==
L"{ "
L"\\bigl({{{\\frac{1}{36}}}{R^{{i_1}{i_2}{i_3}}_{{a_1}{a_2}{a_3}}}{"
L"\\tilde{a}^{{a_1}{a_2}{a_3}}_{{i_1}{i_2}{i_3}}}} + "
L"{{R^{{i_1}}_{{a_1}}}{\\tilde{a}^{{a_1}}_{{i_1}}}} + "
L"{{{\\frac{1}{4}}}{R^{{i_1}{i_2}}_{{a_1}{a_2}}}{\\tilde{a}^{{a_1}{"
L"a_2}}_{{i_1}{i_2}}}}\\bigr) }");
if constexpr (hash_version() == hash::Impl::Boost181OrLater) {
REQUIRE(
to_latex(R33) ==
L"{ "
L"\\bigl({{{\\frac{1}{36}}}{R^{{i_1}{i_2}{i_3}}_{{a_1}{a_2}{a_3}}}{"
L"\\tilde{a}^{{a_1}{a_2}{a_3}}_{{i_1}{i_2}{i_3}}}} + "
L"{{R^{{i_1}}_{{a_1}}}{\\tilde{a}^{{a_1}}_{{i_1}}}} + "
L"{{{\\frac{1}{4}}}{R^{{i_1}{i_2}}_{{a_1}{a_2}}}{\\tilde{a}^{{a_1}{"
L"a_2}}_{{i_1}{i_2}}}}\\bigr) }");
} else {
REQUIRE(to_latex(R33) ==
L"{ \\bigl({{R^{{i_1}}_{{a_1}}}{\\tilde{a}^{{a_1}}_{{i_1}}}} + "
L"{{{\\frac{1}{4}}}{R^{{i_1}{i_2}}_{{a_1}{a_2}}}{\\tilde{a}^{{a_"
L"1}{a_2}}_{{i_1}{i_2}}}} + "
L"{{{\\frac{1}{36}}}{R^{{i_1}{i_2}{i_3}}_{{a_1}{a_2}{a_3}}}{"
L"\\tilde{a}^{{a_1}{a_2}{a_3}}_{{i_1}{i_2}{i_3}}}}\\bigr) }");
}

auto R23 = mbpt::sr::op::R(2, 3);
lower_to_tensor_form(R23);
simplify(R23);
// std::wcout << "R23: " << to_latex(R23) << std::endl;
REQUIRE(
to_latex(R23) ==
L"{ \\bigl({{R^{}_{{a_1}}}{\\tilde{a}^{{a_1}}}} + "
L"{{{\\frac{1}{12}}}{R^{{i_1}{i_2}}_{{a_1}{a_2}{a_3}}}{\\tilde{a}^{{"
L"a_1}{a_2}{a_3}}_{\\textvisiblespace\\,{i_1}{i_2}}}} + "
L"{{{\\frac{1}{2}}}{R^{{i_1}}_{{a_1}{a_2}}}{\\tilde{a}^{{a_1}{a_2}}_{"
L"\\textvisiblespace\\,{i_1}}}}\\bigr) }");
if constexpr (hash_version() == hash::Impl::Boost181OrLater) {
REQUIRE(
to_latex(R23) ==
L"{ \\bigl({{R^{}_{{a_1}}}{\\tilde{a}^{{a_1}}}} + "
L"{{{\\frac{1}{12}}}{R^{{i_1}{i_2}}_{{a_1}{a_2}{a_3}}}{\\tilde{a}^{{"
L"a_1}{a_2}{a_3}}_{\\textvisiblespace\\,{i_1}{i_2}}}} + "
L"{{{\\frac{1}{2}}}{R^{{i_1}}_{{a_1}{a_2}}}{\\tilde{a}^{{a_1}{a_2}}_{"
L"\\textvisiblespace\\,{i_1}}}}\\bigr) }");
} else {
REQUIRE(
to_latex(R23) ==
L"{ \\bigl({{R^{}_{{a_1}}}{\\tilde{a}^{{a_1}}}} + "
L"{{{\\frac{1}{2}}}{R^{{i_1}}_{{a_1}{a_2}}}{\\tilde{a}^{{a_1}{a_2}}_{"
L"\\textvisiblespace\\,{i_1}}}} + "
L"{{{\\frac{1}{12}}}{R^{{i_1}{i_2}}_{{a_1}{a_2}{a_3}}}{\\tilde{a}^{{"
L"a_1}{a_2}{a_3}}_{\\textvisiblespace\\,{i_1}{i_2}}}}\\bigr) }");
}

auto L23 = mbpt::sr::op::L(2, 3);
lower_to_tensor_form(L23);
simplify(L23);
// std::wcout << "L23: " << to_latex(L23) << std::endl;
REQUIRE(
to_latex(L23) ==
L"{ \\bigl({{{\\frac{1}{12}}}{L^{{a_1}{a_2}{a_3}}_{{i_1}{i_2}}}{"
L"\\tilde{a}^{\\textvisiblespace\\,{i_1}{i_2}}_{{a_1}{a_2}{a_3}}}} + "
L"{{{\\frac{1}{2}}}{L^{{a_1}{a_2}}_{{i_1}}}{\\tilde{a}^{"
L"\\textvisiblespace\\,{i_1}}_{{a_1}{a_2}}}} + "
L"{{L^{{a_1}}_{}}{\\tilde{a}_{{a_1}}}}\\bigr) }");
// std::wcout << "L23: " << to_latex(L23) << std::endl;
if constexpr (hash_version() == hash::Impl::Boost181OrLater) {
REQUIRE(
to_latex(L23) ==
L"{ \\bigl({{{\\frac{1}{12}}}{L^{{a_1}{a_2}{a_3}}_{{i_1}{i_2}}}{"
L"\\tilde{a}^{\\textvisiblespace\\,{i_1}{i_2}}_{{a_1}{a_2}{a_3}}}} + "
L"{{{\\frac{1}{2}}}{L^{{a_1}{a_2}}_{{i_1}}}{\\tilde{a}^{"
L"\\textvisiblespace\\,{i_1}}_{{a_1}{a_2}}}} + "
L"{{L^{{a_1}}_{}}{\\tilde{a}_{{a_1}}}}\\bigr) }");
} else {
REQUIRE(
to_latex(L23) ==
L"{ "
L"\\bigl({{{\\frac{1}{2}}}{L^{{a_1}{a_2}}_{{i_1}}}{\\tilde{a}^{"
L"\\textvisiblespace\\,{i_1}}_{{a_1}{a_2}}}} + "
L"{{L^{{a_1}}_{}}{\\tilde{a}_{{a_1}}}} + "
L"{{{\\frac{1}{12}}}{L^{{a_1}{a_2}{a_3}}_{{i_1}{i_2}}}{\\tilde{a}^{"
L"\\textvisiblespace\\,{i_1}{i_2}}_{{a_1}{a_2}{a_3}}}}\\bigr) }");
}

} // SECTION("operators")

Expand Down

0 comments on commit 2175f5b

Please sign in to comment.