Skip to content

Commit

Permalink
Update tests for CVODE
Browse files Browse the repository at this point in the history
JCGoran committed Oct 21, 2024
1 parent fd0c619 commit 5f4a00a
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion test/unit/visitor/cvode.cpp
Original file line number Diff line number Diff line change
@@ -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);
}
}
}

0 comments on commit 5f4a00a

Please sign in to comment.