From 3a635ee8e8ba58eb3800307f8a565f4447212286 Mon Sep 17 00:00:00 2001 From: "Frank T. Bergmann" Date: Fri, 10 May 2024 10:15:03 +0200 Subject: [PATCH] - add test for stepsize --- test/copasijs_test.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/test/copasijs_test.cpp b/test/copasijs_test.cpp index 879a48f..b3ef47a 100644 --- a/test/copasijs_test.cpp +++ b/test/copasijs_test.cpp @@ -124,6 +124,40 @@ TEST_CASE("Simulate SBML multiple times", "[copasijs][multiple]") } + +TEST_CASE("Test stepsize in multiple runs", "[copasijs][multiple]") +{ + Instance instance; + std::string model = loadFromFile(getTestFile("../example_files/oscli.xml")); + + + nlohmann::ordered_json yaml; + yaml["problem"]["OutputStartTime"] = 0; + yaml["problem"]["Duration"] = 10; + yaml["problem"]["StepSize"] = 1; + + auto data = simulateJSON(yaml); + CAPTURE(data); + CAPTURE(getTimeCourseSettings()); + auto json = nlohmann::json::parse(data); + REQUIRE(json["recorded_steps"].get() == 11); + + yaml["problem"]["OutputStartTime"] = 10; + yaml["problem"]["Duration"] = 20; + data = simulateJSON(yaml); + CAPTURE(data); + CAPTURE(getTimeCourseSettings()); + json = nlohmann::json::parse(data); + REQUIRE(json["recorded_steps"].get() == 11); + + yaml["problem"]["StepSize"] = 0.1; + data = simulateJSON(yaml); + CAPTURE(data); + CAPTURE(getTimeCourseSettings()); + json = nlohmann::json::parse(data); + REQUIRE(json["recorded_steps"].get() == 101); +} + TEST_CASE("Load SBML Model", "[copasijs][sbml]") { Instance instance;