mirror of
https://git.gfz-potsdam.de/naaice/tug.git
synced 2025-12-13 09:28:23 +01:00
add tests for Simulation class
This commit is contained in:
parent
aa4ce6a086
commit
30bc676604
@ -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:
|
||||
* <approach> + <number rows> + <number columns> + <number of iterations>-<counter>.csv
|
||||
* <approach> + <number rows> + <number columns> + <number of iterations>+<counter>.csv
|
||||
*
|
||||
* @return string Filename with given simulation parameter.
|
||||
*/
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user