Correctly build argv with nullptr at the end

This commit is contained in:
Richard Berger
2023-11-06 23:18:42 -07:00
committed by Richard Berger
parent e655cda066
commit 46768d0ff3
22 changed files with 207 additions and 283 deletions

View File

@ -106,31 +106,21 @@ public:
}
protected:
std::string testbinary = "LAMMPSTest";
std::vector<std::string> args = {"-log", "none", "-echo", "screen", "-nocite"};
std::string testbinary = "LAMMPSTest";
LAMMPS::argv args = {"-log", "none", "-echo", "screen", "-nocite"};
LAMMPS *lmp;
Info *info;
void SetUp() override
{
int argc = args.size() + 1;
char **argv = new char *[argc];
argv[0] = LAMMPS_NS::utils::strdup(testbinary);
for (int i = 1; i < argc; i++) {
argv[i] = LAMMPS_NS::utils::strdup(args[i - 1]);
}
LAMMPS::argv full_args = {testbinary};
full_args.insert(full_args.end(), args.begin(), args.end());
HIDE_OUTPUT([&] {
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
lmp = new LAMMPS(full_args, MPI_COMM_WORLD);
info = new Info(lmp);
});
InitSystem();
for (int i = 0; i < argc; i++) {
delete[] argv[i];
argv[i] = nullptr;
}
delete[] argv;
}
virtual void InitSystem() {}