8 #include <catch2/catch_test_macros.hpp>
16 using namespace nmodl;
17 using namespace visitor;
22 std::pair<std::string, std::pair<std::string, std::unordered_set<std::string>>>
24 IndexedNameVisitor testvisitor;
25 testvisitor.visit_program(node);
26 return std::make_pair(testvisitor.get_indexed_name(), testvisitor.get_dependencies());
29 SCENARIO(
"Get node name with index TestVisitor",
"[visitor][node_index]") {
30 auto to_ast = [](
const std::string& text) {
35 GIVEN(
"A simple NMODL block") {
36 std::string nmodl_text_a = R
"(
41 SOLVE states METHOD euler
47 std::string nmodl_text_b = R"(
49 SOLVE states STEADYSTATE sparse
56 WHEN("Get node name with index") {
57 THEN(
"Get node name with index") {
58 auto ast = to_ast(nmodl_text_a);
59 std::unordered_set<std::string> vars{
"mInf",
"mTau"};
60 std::string var(
"m[0]");
61 auto expect = std::make_pair(var, vars);
64 REQUIRE(result_name == var);
65 REQUIRE(result_dependencies.first == expect.first);
66 REQUIRE(result_dependencies.second == expect.second);
68 THEN(
"Get dependencies") {
69 auto ast = to_ast(nmodl_text_b);
70 std::unordered_set<std::string> vars{
"m",
"h"};
72 auto expect = std::make_pair(var, vars);
75 REQUIRE(result_dependencies.first == expect.first);
76 REQUIRE(result_dependencies.second == expect.second);