diff --git a/src/gpu/VirtualFluids_GPU/Parameter/ParameterTest.cpp b/src/gpu/VirtualFluids_GPU/Parameter/ParameterTest.cpp index 06b2cf940d2b0dd44b8429bddc294c0a02123905..2751a9489fc947f8a17d0cd80e8432b1cb79248d 100644 --- a/src/gpu/VirtualFluids_GPU/Parameter/ParameterTest.cpp +++ b/src/gpu/VirtualFluids_GPU/Parameter/ParameterTest.cpp @@ -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