Correctly build argv with nullptr at the end
This commit is contained in:
committed by
Richard Berger
parent
e655cda066
commit
46768d0ff3
@ -8,6 +8,7 @@
|
||||
#include <mpi.h>
|
||||
#include <string>
|
||||
|
||||
#include "../testing/utils.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
const char *demo_input[] = {"region box block 0 $x 0 2 0 2", "create_box 1 box",
|
||||
@ -21,9 +22,9 @@ protected:
|
||||
LAMMPS *lmp;
|
||||
Input_commands()
|
||||
{
|
||||
const char *args[] = {"LAMMPS_test"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
const char * args[] = {"LAMMPS_test", nullptr};
|
||||
char ** argv = (char**)args;
|
||||
int argc = 1;
|
||||
|
||||
int flag;
|
||||
MPI_Initialized(&flag);
|
||||
@ -33,13 +34,11 @@ protected:
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
const char *args[] = {"LAMMPS_test", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-var", "zpos", "1.5", "-var", "x", "2"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
LAMMPS::argv args = {"LAMMPS_test", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-var", "zpos", "1.5", "-var", "x", "2"};
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
|
||||
lmp = new LAMMPS(args, MPI_COMM_WORLD);
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
EXPECT_STREQ(output.substr(0, 8).c_str(), "LAMMPS (");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user