Use platform::path_join in unittest tree and remove redundant code
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
#include "lammps.h"
|
||||
#include "library.h"
|
||||
#include "lmptype.h"
|
||||
#include "platform.h"
|
||||
#include <string>
|
||||
|
||||
#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");
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#include "lammps.h"
|
||||
#include "library.h"
|
||||
#include "lmptype.h"
|
||||
#include "platform.h"
|
||||
#include <string>
|
||||
|
||||
#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());
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user