added first grid test
This commit is contained in:
parent
4e043e712e
commit
8596f3ffda
@ -95,6 +95,13 @@ class Grid {
|
|||||||
*/
|
*/
|
||||||
int getDim();
|
int getDim();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets length of 1D grid. Must be one dimensional grid.
|
||||||
|
*
|
||||||
|
* @return int Length of 1D grid.
|
||||||
|
*/
|
||||||
|
int getLength();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Gets the number of rows of the grid.
|
* @brief Gets the number of rows of the grid.
|
||||||
*
|
*
|
||||||
@ -132,7 +139,7 @@ class Grid {
|
|||||||
double getDeltaCol();
|
double getDeltaCol();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Gets the delta value in y-direction.
|
* @brief Gets the delta value in y-direction. Must be two dimensional grid.
|
||||||
*
|
*
|
||||||
* @return double Delta value in y-direction.
|
* @return double Delta value in y-direction.
|
||||||
*/
|
*/
|
||||||
|
|||||||
12
src/Grid.cpp
12
src/Grid.cpp
@ -103,6 +103,14 @@ int Grid::getDim() {
|
|||||||
return dim;
|
return dim;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Grid::getLength() {
|
||||||
|
if (dim != 1) {
|
||||||
|
throw_invalid_argument("Grid is not one dimensional, you should probably use getRow() or getCol()!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return col;
|
||||||
|
}
|
||||||
|
|
||||||
int Grid::getRow() {
|
int Grid::getRow() {
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
@ -142,5 +150,9 @@ double Grid::getDeltaCol() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
double Grid::getDeltaRow() {
|
double Grid::getDeltaRow() {
|
||||||
|
if (dim != 2) {
|
||||||
|
throw_invalid_argument("Grid is not two dimensional, meaning there is no delta in y-direction!");
|
||||||
|
}
|
||||||
|
|
||||||
return this->deltaRow;
|
return this->deltaRow;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,7 +11,7 @@ if(NOT DOCTEST_LIB)
|
|||||||
FetchContent_MakeAvailable(DocTest)
|
FetchContent_MakeAvailable(DocTest)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(testTug setup.cpp testSimulation.cpp) # testBoundaryCondition.cpp testDiffusion.cpp
|
add_executable(testTug setup.cpp testSimulation.cpp testGrid.cpp) # testBoundaryCondition.cpp testDiffusion.cpp
|
||||||
target_link_libraries(testTug doctest tug)
|
target_link_libraries(testTug doctest tug)
|
||||||
|
|
||||||
# get relative path of the CSV file
|
# get relative path of the CSV file
|
||||||
|
|||||||
42
test/testGrid.cpp
Normal file
42
test/testGrid.cpp
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#include <doctest/doctest.h>
|
||||||
|
#include <tug/Grid.hpp>
|
||||||
|
|
||||||
|
TEST_CASE("1D Grid") {
|
||||||
|
int l = 12;
|
||||||
|
Grid grid(l);
|
||||||
|
|
||||||
|
SUBCASE("correct construction") {
|
||||||
|
CHECK_EQ(grid.getDim(), 1);
|
||||||
|
CHECK_EQ(grid.getLength(), l);
|
||||||
|
CHECK_EQ(grid.getCol(), l);
|
||||||
|
CHECK_EQ(grid.getRow(), 1);
|
||||||
|
|
||||||
|
CHECK_EQ(grid.getConcentrations().rows(), 1);
|
||||||
|
CHECK_EQ(grid.getConcentrations().cols(), l);
|
||||||
|
CHECK_EQ(grid.getAlpha().rows(), 1);
|
||||||
|
CHECK_EQ(grid.getAlpha().cols(), l);
|
||||||
|
CHECK_EQ(grid.getDeltaCol(), 1);
|
||||||
|
|
||||||
|
CHECK_THROWS(grid.getAlphaX());
|
||||||
|
CHECK_THROWS(grid.getAlphaY());
|
||||||
|
CHECK_THROWS(grid.getDeltaRow());
|
||||||
|
}
|
||||||
|
|
||||||
|
SUBCASE("") {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("2D Grid quadratic") {
|
||||||
|
int r = 12;
|
||||||
|
int c = 12;
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("2D Grid non-quadratic") {
|
||||||
|
int r = 12;
|
||||||
|
int c = 15;
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user