diff --git a/test/unit/visitor/cvode.cpp b/test/unit/visitor/cvode.cpp index e42df2ec4..96d09549a 100644 --- a/test/unit/visitor/cvode.cpp +++ b/test/unit/visitor/cvode.cpp @@ -28,8 +28,16 @@ auto run_cvode_visitor(const std::string& text) { TEST_CASE("Make sure CVODE block is generated properly", "[visitor][cvode]") { + GIVEN("No DERIVATIVE block") { + auto nmodl_text = "NEURON { SUFFIX example }"; + auto ast = run_cvode_visitor(nmodl_text); + THEN("No CVODE block is added") { + auto blocks = collect_nodes(*ast, {ast::AstNodeType::CVODE_BLOCK}); + REQUIRE(blocks.empty()); + } + } GIVEN("DERIVATIVE block") { - std::string nmodl_text = R"( + auto nmodl_text = R"( NEURON { SUFFIX example } @@ -58,4 +66,24 @@ TEST_CASE("Make sure CVODE block is generated properly", "[visitor][cvode]") { } } } + GIVEN("Multiple DERIVATIVE blocks") { + auto nmodl_text = R"( + NEURON { + SUFFIX example + } + + STATE {X} + + DERIVATIVE equation { + X' = -X + } + + DERIVATIVE equation2 { + X' = -X * X + } +)"; + THEN("An error is raised") { + REQUIRE_THROWS_AS(run_cvode_visitor(nmodl_text), std::runtime_error); + } + } }