diff --git a/include/tug/Simulation.hpp b/include/tug/Simulation.hpp index 9d334eb..6ec69c4 100644 --- a/include/tug/Simulation.hpp +++ b/include/tug/Simulation.hpp @@ -123,7 +123,7 @@ class Simulation { * @brief Creates a CSV file with a name containing the current simulation * parameters. If the data name already exists, an additional counter is * appended to the name. The name of the file is built up as follows: - * + + + -.csv + * + + + +.csv * * @return string Filename with given simulation parameter. */ diff --git a/test/testSimulation.cpp b/test/testSimulation.cpp index aaac3fa..70ad0cf 100644 --- a/test/testSimulation.cpp +++ b/test/testSimulation.cpp @@ -63,3 +63,41 @@ TEST_CASE("equality to reference matrix") { Grid grid = setupSimulation(); CHECK(checkSimilarity(reference, grid.getConcentrations(), 0.1) == true); } + +TEST_CASE("Initialize environment"){ + int rc = 12; + Grid grid(rc, rc); + Boundary boundary(grid); + + CHECK_NOTHROW(Simulation sim(grid, boundary, FTCS_APPROACH)); + } + +TEST_CASE("Simulation environment"){ + int rc = 12; + Grid grid(rc, rc); + Boundary boundary(grid); + Simulation sim(grid, boundary, FTCS_APPROACH); + + SUBCASE("default paremeters"){ + CHECK_EQ(sim.getIterations(), 1000); + } + + SUBCASE("set iterations"){ + CHECK_NOTHROW(sim.setIterations(2000)); + CHECK_EQ(sim.getIterations(), 2000); + CHECK_THROWS(sim.setIterations(-300)); + } + + SUBCASE("set timestep"){ + CHECK_NOTHROW(sim.setTimestep(0.1)); + CHECK_EQ(sim.getTimestep(), 0.1); + CHECK_THROWS(sim.setTimestep(-0.3)); + } + + SUBCASE("filename"){ + string s1 = sim.createCSVfile(); + string s2 = "FTCS_12_12_1000"; + CHECK_EQ(s1.find(s2) != std::string::npos, true); + } +} +