diff --git a/unittest/c-library/test_library_properties.cpp b/unittest/c-library/test_library_properties.cpp index 754c6df77f..192c6897e9 100644 --- a/unittest/c-library/test_library_properties.cpp +++ b/unittest/c-library/test_library_properties.cpp @@ -3,6 +3,7 @@ #include "lammps.h" #include "library.h" #include "lmptype.h" +#include "platform.h" #include #include "gmock/gmock.h" @@ -13,6 +14,7 @@ #define STRINGIFY(val) XSTR(val) #define XSTR(val) #val +using ::LAMMPS_NS::platform::path_join; using ::LAMMPS_NS::tagint; using ::testing::HasSubstr; using ::testing::StartsWith; @@ -82,7 +84,7 @@ TEST_F(LibraryProperties, get_mpi_comm) TEST_F(LibraryProperties, natoms) { if (!lammps_has_style(lmp, "atom", "full")) GTEST_SKIP(); - std::string input = INPUT_DIR + PATH_SEP + "in.fourmol"; + std::string input = path_join(INPUT_DIR, "in.fourmol"); if (!verbose) ::testing::internal::CaptureStdout(); lammps_file(lmp, input.c_str()); if (!verbose) ::testing::internal::GetCapturedStdout(); @@ -92,7 +94,7 @@ TEST_F(LibraryProperties, natoms) TEST_F(LibraryProperties, thermo) { if (!lammps_has_style(lmp, "atom", "full")) GTEST_SKIP(); - std::string input = INPUT_DIR + PATH_SEP + "in.fourmol"; + std::string input = path_join(INPUT_DIR, "in.fourmol"); ::testing::internal::CaptureStdout(); lammps_file(lmp, input.c_str()); lammps_command(lmp, "run 2 post no"); @@ -108,7 +110,7 @@ TEST_F(LibraryProperties, thermo) TEST_F(LibraryProperties, box) { if (!lammps_has_style(lmp, "atom", "full")) GTEST_SKIP(); - std::string input = INPUT_DIR + PATH_SEP + "in.fourmol"; + std::string input = path_join(INPUT_DIR, "in.fourmol"); ::testing::internal::CaptureStdout(); lammps_file(lmp, input.c_str()); lammps_command(lmp, "run 2 post no"); @@ -248,7 +250,7 @@ TEST_F(LibraryProperties, setting) EXPECT_EQ(lammps_extract_setting(lmp, "UNKNOWN"), -1); if (lammps_has_style(lmp, "atom", "full")) { - std::string input = INPUT_DIR + PATH_SEP + "in.fourmol"; + std::string input = path_join(INPUT_DIR, "in.fourmol"); if (!verbose) ::testing::internal::CaptureStdout(); lammps_file(lmp, input.c_str()); lammps_command(lmp, "run 2 post no"); @@ -289,7 +291,7 @@ TEST_F(LibraryProperties, global) { if (!lammps_has_style(lmp, "atom", "full")) GTEST_SKIP(); - std::string input = INPUT_DIR + PATH_SEP + "in.fourmol"; + std::string input = path_join(INPUT_DIR, "in.fourmol"); if (!verbose) ::testing::internal::CaptureStdout(); lammps_file(lmp, input.c_str()); lammps_command(lmp, "run 2 post no"); diff --git a/unittest/c-library/test_library_scatter_gather.cpp b/unittest/c-library/test_library_scatter_gather.cpp index 7ee1cfc9eb..6144516ac2 100644 --- a/unittest/c-library/test_library_scatter_gather.cpp +++ b/unittest/c-library/test_library_scatter_gather.cpp @@ -3,6 +3,7 @@ #include "lammps.h" #include "library.h" #include "lmptype.h" +#include "platform.h" #include #include "gmock/gmock.h" @@ -13,6 +14,7 @@ #define STRINGIFY(val) XSTR(val) #define XSTR(val) #val +using ::LAMMPS_NS::platform::path_join; using ::LAMMPS_NS::bigint; using ::LAMMPS_NS::tagint; using ::testing::HasSubstr; @@ -55,7 +57,7 @@ protected: TEST_F(GatherProperties, gather_bonds_newton_on) { if (!lammps_has_style(lmp, "atom", "full")) GTEST_SKIP(); - std::string input = INPUT_DIR + PATH_SEP + "in.fourmol"; + std::string input = path_join(INPUT_DIR, "in.fourmol"); if (!verbose) ::testing::internal::CaptureStdout(); lammps_command(lmp, "newton on on"); lammps_file(lmp, input.c_str()); @@ -95,7 +97,7 @@ TEST_F(GatherProperties, gather_bonds_newton_on) TEST_F(GatherProperties, gather_bonds_newton_off) { if (!lammps_has_style(lmp, "atom", "full")) GTEST_SKIP(); - std::string input = INPUT_DIR + PATH_SEP + "in.fourmol"; + std::string input = path_join(INPUT_DIR, "in.fourmol"); if (!verbose) ::testing::internal::CaptureStdout(); lammps_command(lmp, "newton off off"); lammps_file(lmp, input.c_str()); diff --git a/unittest/c-library/test_main.h b/unittest/c-library/test_main.h index 567b913d27..9a719e4b88 100644 --- a/unittest/c-library/test_main.h +++ b/unittest/c-library/test_main.h @@ -25,9 +25,3 @@ extern bool verbose; } while (0); #endif - -#if defined _WIN32 -static const char PATH_SEP = '\\'; -#else -static const char PATH_SEP = '/'; -#endif diff --git a/unittest/force-styles/test_angle_style.cpp b/unittest/force-styles/test_angle_style.cpp index ca0573840e..002ea58a24 100644 --- a/unittest/force-styles/test_angle_style.cpp +++ b/unittest/force-styles/test_angle_style.cpp @@ -108,7 +108,7 @@ LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool new command(pre_command); } - std::string input_file = INPUT_FOLDER + PATH_SEP + cfg.input_file; + std::string input_file = platform::path_join(INPUT_FOLDER, cfg.input_file); parse_input_script(input_file); command("angle_style " + cfg.angle_style); @@ -194,7 +194,7 @@ void data_lammps(LAMMPS *lmp, const TestConfig &cfg) command("variable angle_style index '" + cfg.angle_style + "'"); command("variable data_file index " + cfg.basename + ".data"); - std::string input_file = INPUT_FOLDER + PATH_SEP + cfg.input_file; + std::string input_file = platform::path_join(INPUT_FOLDER, cfg.input_file); parse_input_script(input_file); for (auto &angle_coeff : cfg.angle_coeff) { diff --git a/unittest/force-styles/test_bond_style.cpp b/unittest/force-styles/test_bond_style.cpp index a8f5ba3044..b913c121e1 100644 --- a/unittest/force-styles/test_bond_style.cpp +++ b/unittest/force-styles/test_bond_style.cpp @@ -108,7 +108,7 @@ LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool new command(pre_command); } - std::string input_file = INPUT_FOLDER + PATH_SEP + cfg.input_file; + std::string input_file = platform::path_join(INPUT_FOLDER, cfg.input_file); parse_input_script(input_file); command("bond_style " + cfg.bond_style); @@ -194,7 +194,7 @@ void data_lammps(LAMMPS *lmp, const TestConfig &cfg) command("variable bond_style index '" + cfg.bond_style + "'"); command("variable data_file index " + cfg.basename + ".data"); - std::string input_file = INPUT_FOLDER + PATH_SEP + cfg.input_file; + std::string input_file = platform::path_join(INPUT_FOLDER, cfg.input_file); parse_input_script(input_file); for (auto &bond_coeff : cfg.bond_coeff) { diff --git a/unittest/force-styles/test_dihedral_style.cpp b/unittest/force-styles/test_dihedral_style.cpp index e26b066485..c98f97d260 100644 --- a/unittest/force-styles/test_dihedral_style.cpp +++ b/unittest/force-styles/test_dihedral_style.cpp @@ -108,7 +108,7 @@ LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool new command(pre_command); } - std::string input_file = INPUT_FOLDER + PATH_SEP + cfg.input_file; + std::string input_file = platform::path_join(INPUT_FOLDER, cfg.input_file); parse_input_script(input_file); command("dihedral_style " + cfg.dihedral_style); @@ -203,7 +203,7 @@ void data_lammps(LAMMPS *lmp, const TestConfig &cfg) command("variable pair_style index 'lj/charmmfsw/coul/charmmfsh 7.0 8.0'"); } - std::string input_file = INPUT_FOLDER + PATH_SEP + cfg.input_file; + std::string input_file = platform::path_join(INPUT_FOLDER, cfg.input_file); parse_input_script(input_file); for (auto &dihedral_coeff : cfg.dihedral_coeff) { diff --git a/unittest/force-styles/test_fix_timestep.cpp b/unittest/force-styles/test_fix_timestep.cpp index 8c6ffeb617..6a8ccdb948 100644 --- a/unittest/force-styles/test_fix_timestep.cpp +++ b/unittest/force-styles/test_fix_timestep.cpp @@ -99,7 +99,7 @@ LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool use for (auto &pre_command : cfg.pre_commands) command(pre_command); - std::string input_file = INPUT_FOLDER + PATH_SEP + cfg.input_file; + std::string input_file = platform::path_join(INPUT_FOLDER, cfg.input_file); lmp->input->file(input_file.c_str()); if (use_respa) command("run_style respa 2 1 bond 1 pair 2"); diff --git a/unittest/force-styles/test_improper_style.cpp b/unittest/force-styles/test_improper_style.cpp index 749f8be53f..cef703d614 100644 --- a/unittest/force-styles/test_improper_style.cpp +++ b/unittest/force-styles/test_improper_style.cpp @@ -108,7 +108,7 @@ LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool new command(pre_command); } - std::string input_file = INPUT_FOLDER + PATH_SEP + cfg.input_file; + std::string input_file = platform::path_join(INPUT_FOLDER, cfg.input_file); parse_input_script(input_file); command("improper_style " + cfg.improper_style); @@ -194,7 +194,7 @@ void data_lammps(LAMMPS *lmp, const TestConfig &cfg) command("variable improper_style index '" + cfg.improper_style + "'"); command("variable data_file index " + cfg.basename + ".data"); - std::string input_file = INPUT_FOLDER + PATH_SEP + cfg.input_file; + std::string input_file = platform::path_join(INPUT_FOLDER, cfg.input_file); parse_input_script(input_file); for (auto &improper_coeff : cfg.improper_coeff) { diff --git a/unittest/force-styles/test_main.h b/unittest/force-styles/test_main.h index 4fe0422318..f940f7dd3c 100644 --- a/unittest/force-styles/test_main.h +++ b/unittest/force-styles/test_main.h @@ -36,10 +36,4 @@ void write_yaml_header(class YamlWriter *writer, TestConfig *cfg, const char *ve void EXPECT_STRESS(const std::string & name, double * stress, const stress_t & expected_stress, double epsilon); -#if defined _WIN32 -static const char PATH_SEP = '\\'; -#else -static const char PATH_SEP = '/'; -#endif - #endif diff --git a/unittest/force-styles/test_pair_style.cpp b/unittest/force-styles/test_pair_style.cpp index 205f709c92..3a23b655e9 100644 --- a/unittest/force-styles/test_pair_style.cpp +++ b/unittest/force-styles/test_pair_style.cpp @@ -109,7 +109,7 @@ LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool new command(pre_command); } - std::string input_file = INPUT_FOLDER + PATH_SEP + cfg.input_file; + std::string input_file = platform::path_join(INPUT_FOLDER, cfg.input_file); parse_input_script(input_file); command("pair_style " + cfg.pair_style); @@ -207,7 +207,7 @@ void data_lammps(LAMMPS *lmp, const TestConfig &cfg) command("variable pair_style index '" + cfg.pair_style + "'"); command("variable data_file index " + cfg.basename + ".data"); - std::string input_file = INPUT_FOLDER + PATH_SEP + cfg.input_file; + std::string input_file = platform::path_join(INPUT_FOLDER, cfg.input_file); parse_input_script(input_file); for (auto &pair_coeff : cfg.pair_coeff) {