Skip to content
Snippets Groups Projects
Commit 38dd88e3 authored by Anna Wellmann's avatar Anna Wellmann
Browse files

Add tests for gridPath

parent 9ad110ed
No related branches found
No related tags found
1 merge request!115Enable running VirtualFluidsGPU without config file
......@@ -41,12 +41,10 @@ TEST(ParameterTest, check_all_Parameter_CanBePassedToConstructor)
Parameter para(config, 1, 0);
// this two parameters need to be defined in each config file
// test optional parameter
EXPECT_THAT(para.getOutputPath(), testing::Eq("/output/path"));
EXPECT_THAT(para.getGridPath(), testing::Eq("/path/to/grid/")); // ... all grid files (e.g. multi-gpu/ multi-level) could be tested as well
EXPECT_THAT(para.getgeoVec(), testing::Eq("/path/to/grid/geoVec.dat"));
// ... all grid files could be tested as well
// test optional parameter
EXPECT_THAT(para.getMaxDev(), testing::Eq(2));
EXPECT_THAT(para.getDevices(), testing::ElementsAreArray({ 2, 3 }));
EXPECT_THAT(para.getOutputPrefix(), testing::Eq("MyPrefix"));
......@@ -149,4 +147,62 @@ TEST(ParameterTest, check_all_Parameter_CanBePassedToConstructor)
EXPECT_THAT(para.getFine(), testing::Eq(1)); // NOGL - 1
EXPECT_THAT(para.parH.size(), testing::Eq(2));
EXPECT_THAT(para.parD.size(), testing::Eq(2));
}
TEST(ParameterTest, defaultGridPath)
{
Parameter para(1, 0);
EXPECT_THAT(para.getGridPath(), testing::Eq("grid/"));
EXPECT_THAT(para.getConcentration(), testing::Eq("grid/conc.dat"));
}
TEST(ParameterTest, defaultGridPathMultiGPU)
{
Parameter para(2, 1);
EXPECT_THAT(para.getGridPath(), testing::Eq("grid/1/"));
EXPECT_THAT(para.getConcentration(), testing::Eq("grid/1/conc.dat"));
}
TEST(ParameterTest, setGridPathOverridesDefaultGridPath)
{
Parameter para(2, 1);
para.setGridPath("gridPathTest");
EXPECT_THAT( para.getGridPath(), testing::Eq("gridPathTest/1/"));
EXPECT_THAT(para.getConcentration(), testing::Eq("gridPathTest/1/conc.dat"));
}
TEST(ParameterTest, setGridPathOverridesConfigFile)
{
// assuming that the config files is stored parallel to this file.
std::filesystem::path filePath = __FILE__;
filePath.replace_filename("parameterTest.cfg");
vf::basics::ConfigurationFile config;
config.load(filePath.string());
auto para = Parameter(config, 2, 0);
para.setGridPath("gridPathTest");
EXPECT_THAT( para.getGridPath(), testing::Eq("gridPathTest/0/"));
EXPECT_THAT(para.getConcentration(), testing::Eq("gridPathTest/0/conc.dat"));
}
TEST(ParameterTest, userMissedSlash)
{
Parameter para(1, 0);
para.setGridPath("gridPathTest");
EXPECT_THAT(para.getGridPath(), testing::Eq("gridPathTest/"));
EXPECT_THAT(para.getConcentration(), testing::Eq("gridPathTest/conc.dat"));
}
TEST(ParameterTest, userMissedSlashMultiGPU)
{
Parameter para(2, 0);
para.setGridPath("gridPathTest");
EXPECT_THAT(para.getGridPath(), testing::Eq("gridPathTest/0/"));
EXPECT_THAT(para.getConcentration(), testing::Eq("gridPathTest/0/conc.dat"));
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment