diff --git a/unittest/force-styles/angle_style.cpp b/unittest/force-styles/angle_style.cpp index 8b85cabe95..a6f18f4409 100644 --- a/unittest/force-styles/angle_style.cpp +++ b/unittest/force-styles/angle_style.cpp @@ -99,20 +99,14 @@ LAMMPS_NS::LAMMPS *init_lammps(int argc, char **argv, lmp->input->one("variable newton_bond index off"); } -#define STRINGIFY(val) XSTR(val) -#define XSTR(val) #val std::string set_input_dir = "variable input_dir index "; - set_input_dir += STRINGIFY(TEST_INPUT_FOLDER); + set_input_dir += INPUT_FOLDER; lmp->input->one(set_input_dir.c_str()); for (auto pre_command : cfg.pre_commands) lmp->input->one(pre_command.c_str()); - std::string input_file = STRINGIFY(TEST_INPUT_FOLDER); - input_file += "/"; - input_file += cfg.input_file; + std::string input_file = INPUT_FOLDER + PATH_SEP + cfg.input_file; lmp->input->file(input_file.c_str()); -#undef STRINGIFY -#undef XSTR std::string cmd("angle_style "); cmd += cfg.angle_style; @@ -186,14 +180,8 @@ void data_lammps(LAMMPS_NS::LAMMPS *lmp, const TestConfig &cfg) cmd += cfg.basename + ".data"; lmp->input->one(cmd.c_str()); -#define STRINGIFY(val) XSTR(val) -#define XSTR(val) #val - std::string input_file = STRINGIFY(TEST_INPUT_FOLDER); - input_file += "/"; - input_file += cfg.input_file; + std::string input_file = INPUT_FOLDER + PATH_SEP + cfg.input_file; lmp->input->file(input_file.c_str()); -#undef STRINGIFY -#undef XSTR for (auto angle_coeff : cfg.angle_coeff) { cmd = "angle_coeff " + angle_coeff; diff --git a/unittest/force-styles/bond_style.cpp b/unittest/force-styles/bond_style.cpp index 2a7ef6f9ff..f39062b1c7 100644 --- a/unittest/force-styles/bond_style.cpp +++ b/unittest/force-styles/bond_style.cpp @@ -49,6 +49,7 @@ using ::testing::StartsWith; using ::testing::HasSubstr; + void cleanup_lammps(LAMMPS_NS::LAMMPS *lmp, const TestConfig &cfg) { std::string name; @@ -90,7 +91,7 @@ LAMMPS_NS::LAMMPS *init_lammps(int argc, char **argv, if (nfail > 0) { delete info; cleanup_lammps(lmp,cfg); - return NULL; + return nullptr; } if (newton) { @@ -99,20 +100,15 @@ LAMMPS_NS::LAMMPS *init_lammps(int argc, char **argv, lmp->input->one("variable newton_bond index off"); } -#define STRINGIFY(val) XSTR(val) -#define XSTR(val) #val std::string set_input_dir = "variable input_dir index "; - set_input_dir += STRINGIFY(TEST_INPUT_FOLDER); + set_input_dir += INPUT_FOLDER; lmp->input->one(set_input_dir.c_str()); for (auto pre_command : cfg.pre_commands) lmp->input->one(pre_command.c_str()); - std::string input_file = STRINGIFY(TEST_INPUT_FOLDER); - input_file += "/"; - input_file += cfg.input_file; + std::string input_file = INPUT_FOLDER + "/" + cfg.input_file; + lmp->input->file(input_file.c_str()); -#undef STRINGIFY -#undef XSTR std::string cmd("bond_style "); cmd += cfg.bond_style; @@ -186,14 +182,8 @@ void data_lammps(LAMMPS_NS::LAMMPS *lmp, const TestConfig &cfg) cmd += cfg.basename + ".data"; lmp->input->one(cmd.c_str()); -#define STRINGIFY(val) XSTR(val) -#define XSTR(val) #val - std::string input_file = STRINGIFY(TEST_INPUT_FOLDER); - input_file += "/"; - input_file += cfg.input_file; + std::string input_file = INPUT_FOLDER + PATH_SEP + cfg.input_file; lmp->input->file(input_file.c_str()); -#undef STRINGIFY -#undef XSTR for (auto bond_coeff : cfg.bond_coeff) { cmd = "bond_coeff " + bond_coeff; @@ -801,15 +791,11 @@ TEST(BondStyle, single) { lmp->input->one("variable newton_bond delete"); lmp->input->one("variable newton_bond index on"); -#define STRINGIFY(val) XSTR(val) -#define XSTR(val) #val std::string set_input_dir = "variable input_dir index "; - set_input_dir += STRINGIFY(TEST_INPUT_FOLDER); + set_input_dir += INPUT_FOLDER; lmp->input->one(set_input_dir.c_str()); for (auto pre_command : test_config.pre_commands) lmp->input->one(pre_command.c_str()); -#undef STRINGIFY -#undef XSTR lmp->input->one("atom_style molecular"); lmp->input->one("units ${units}"); diff --git a/unittest/force-styles/pair_style.cpp b/unittest/force-styles/pair_style.cpp index 679929d540..15326e6161 100644 --- a/unittest/force-styles/pair_style.cpp +++ b/unittest/force-styles/pair_style.cpp @@ -99,20 +99,14 @@ LAMMPS_NS::LAMMPS *init_lammps(int argc, char **argv, lmp->input->one("variable newton_pair index off"); } -#define STRINGIFY(val) XSTR(val) -#define XSTR(val) #val std::string set_input_dir = "variable input_dir index "; - set_input_dir += STRINGIFY(TEST_INPUT_FOLDER); + set_input_dir += INPUT_FOLDER; lmp->input->one(set_input_dir.c_str()); for (auto pre_command : cfg.pre_commands) lmp->input->one(pre_command.c_str()); - std::string input_file = STRINGIFY(TEST_INPUT_FOLDER); - input_file += "/"; - input_file += cfg.input_file; + std::string input_file = INPUT_FOLDER + PATH_SEP + cfg.input_file; lmp->input->file(input_file.c_str()); -#undef STRINGIFY -#undef XSTR std::string cmd("pair_style "); cmd += cfg.pair_style; @@ -186,14 +180,8 @@ void data_lammps(LAMMPS_NS::LAMMPS *lmp, const TestConfig &cfg) cmd += cfg.basename + ".data"; lmp->input->one(cmd.c_str()); -#define STRINGIFY(val) XSTR(val) -#define XSTR(val) #val - std::string input_file = STRINGIFY(TEST_INPUT_FOLDER); - input_file += "/"; - input_file += cfg.input_file; + std::string input_file = INPUT_FOLDER + PATH_SEP + cfg.input_file; lmp->input->file(input_file.c_str()); -#undef STRINGIFY -#undef XSTR for (auto pair_coeff : cfg.pair_coeff) { cmd = "pair_coeff " + pair_coeff; @@ -1050,15 +1038,11 @@ TEST(PairStyle, single) { lmp->input->one("variable newton_pair delete"); lmp->input->one("variable newton_pair index on"); -#define STRINGIFY(val) XSTR(val) -#define XSTR(val) #val std::string set_input_dir = "variable input_dir index "; - set_input_dir += STRINGIFY(TEST_INPUT_FOLDER); + set_input_dir += INPUT_FOLDER; lmp->input->one(set_input_dir.c_str()); for (auto pre_command : test_config.pre_commands) lmp->input->one(pre_command.c_str()); -#undef STRINGIFY -#undef XSTR lmp->input->one("atom_style full"); lmp->input->one("units ${units}"); diff --git a/unittest/force-styles/test_main.h b/unittest/force-styles/test_main.h index 126f433225..9002e3584f 100644 --- a/unittest/force-styles/test_main.h +++ b/unittest/force-styles/test_main.h @@ -15,6 +15,7 @@ #define TEST_MAIN_H #include "test_config.h" +#include extern TestConfig test_config; extern bool print_stats; @@ -31,3 +32,14 @@ extern bool verbose; #endif +#define STRINGIFY(val) XSTR(val) +#define XSTR(val) #val +static const std::string INPUT_FOLDER = STRINGIFY(TEST_INPUT_FOLDER); +#undef STRINGIFY +#undef XSTR + +#if defined _WIN32 +static const char PATH_SEP = '\\'; +#else +static const char PATH_SEP = '/'; +#endif