Add test for sublo and subhi
This commit is contained in:
@ -86,7 +86,7 @@ public:
|
|||||||
finalize_test = false;
|
finalize_test = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void OnTestPartResult(const TestPartResult& test_part_result) override {
|
virtual void OnTestPartResult(const TestPartResult& test_part_result) override {
|
||||||
// Called after a failed assertion or a SUCCESS().
|
// Called after a failed assertion or a SUCCESS().
|
||||||
// test_part_result()
|
// test_part_result()
|
||||||
@ -105,7 +105,7 @@ public:
|
|||||||
results.push_back(TestPartResult(test_part_result.type(), test_part_result.file_name(), test_part_result.line_number(), proc_message.str().c_str()));
|
results.push_back(TestPartResult(test_part_result.type(), test_part_result.file_name(), test_part_result.line_number(), proc_message.str().c_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnTestEnd(const TestInfo& test_info) override {
|
virtual void OnTestEnd(const TestInfo& test_info) override {
|
||||||
// Called after a test ends.
|
// Called after a test ends.
|
||||||
MPI_Barrier(comm);
|
MPI_Barrier(comm);
|
||||||
@ -195,11 +195,11 @@ public:
|
|||||||
}
|
}
|
||||||
results.pop_front();
|
results.pop_front();
|
||||||
}
|
}
|
||||||
|
|
||||||
default_listener->OnTestEnd(test_info);
|
default_listener->OnTestEnd(test_info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnTestSuiteEnd(const TestSuite& test_suite) override {
|
virtual void OnTestSuiteEnd(const TestSuite& test_suite) override {
|
||||||
if(me == 0) default_listener->OnTestSuiteEnd(test_suite);
|
if(me == 0) default_listener->OnTestSuiteEnd(test_suite);
|
||||||
}
|
}
|
||||||
@ -217,11 +217,11 @@ public:
|
|||||||
virtual void OnEnvironmentsTearDownEnd(const UnitTest& unit_test) override {
|
virtual void OnEnvironmentsTearDownEnd(const UnitTest& unit_test) override {
|
||||||
if(me == 0) default_listener->OnEnvironmentsTearDownEnd(unit_test);
|
if(me == 0) default_listener->OnEnvironmentsTearDownEnd(unit_test);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration) override {
|
virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration) override {
|
||||||
if(me == 0) default_listener->OnTestIterationEnd(unit_test, iteration);
|
if(me == 0) default_listener->OnTestIterationEnd(unit_test, iteration);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnTestProgramEnd(const UnitTest& unit_test) override {
|
virtual void OnTestProgramEnd(const UnitTest& unit_test) override {
|
||||||
if(me == 0) default_listener->OnTestProgramEnd(unit_test);
|
if(me == 0) default_listener->OnTestProgramEnd(unit_test);
|
||||||
}
|
}
|
||||||
@ -258,7 +258,7 @@ TEST(MPI, global_box)
|
|||||||
|
|
||||||
lammps_extract_box(lmp, boxlo, boxhi, &xy, &yz, &xz, pflags, &boxflag);
|
lammps_extract_box(lmp, boxlo, boxhi, &xy, &yz, &xz, pflags, &boxflag);
|
||||||
::testing::internal::GetCapturedStdout();
|
::testing::internal::GetCapturedStdout();
|
||||||
|
|
||||||
EXPECT_EQ(boxlo[0], 0.0);
|
EXPECT_EQ(boxlo[0], 0.0);
|
||||||
EXPECT_EQ(boxlo[1], 0.0);
|
EXPECT_EQ(boxlo[1], 0.0);
|
||||||
EXPECT_EQ(boxlo[2], 0.0);
|
EXPECT_EQ(boxlo[2], 0.0);
|
||||||
@ -266,7 +266,64 @@ TEST(MPI, global_box)
|
|||||||
EXPECT_EQ(boxhi[0], 2.0);
|
EXPECT_EQ(boxhi[0], 2.0);
|
||||||
EXPECT_EQ(boxhi[1], 2.0);
|
EXPECT_EQ(boxhi[1], 2.0);
|
||||||
EXPECT_EQ(boxhi[2], 2.0);
|
EXPECT_EQ(boxhi[2], 2.0);
|
||||||
|
|
||||||
|
::testing::internal::CaptureStdout();
|
||||||
|
lammps_close(lmp);
|
||||||
|
::testing::internal::GetCapturedStdout();
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST(MPI, sub_box)
|
||||||
|
{
|
||||||
|
int nprocs, me;
|
||||||
|
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
|
||||||
|
MPI_Comm_rank(MPI_COMM_WORLD, &me);
|
||||||
|
EXPECT_EQ(nprocs, 4);
|
||||||
|
EXPECT_GT(me, -1);
|
||||||
|
EXPECT_LT(me, 5);
|
||||||
|
|
||||||
|
double boxlo[3];
|
||||||
|
double boxhi[3];
|
||||||
|
double xy = 0.0;
|
||||||
|
double yz = 0.0;
|
||||||
|
double xz = 0.0;
|
||||||
|
int pflags[3];
|
||||||
|
int boxflag;
|
||||||
|
|
||||||
|
::testing::internal::CaptureStdout();
|
||||||
|
const char *args[] = {"LAMMPS_test", "-log", "none",
|
||||||
|
"-echo", "screen", "-nocite"};
|
||||||
|
char **argv = (char **)args;
|
||||||
|
int argc = sizeof(args) / sizeof(char *);
|
||||||
|
void * lmp = lammps_open(argc, argv, MPI_COMM_WORLD, nullptr);
|
||||||
|
lammps_command(lmp, "units lj");
|
||||||
|
lammps_command(lmp, "atom_style atomic");
|
||||||
|
lammps_command(lmp, "region box block 0 2 0 2 0 2");
|
||||||
|
lammps_command(lmp, "create_box 1 box");
|
||||||
|
|
||||||
|
lammps_extract_box(lmp, boxlo, boxhi, &xy, &yz, &xz, pflags, &boxflag);
|
||||||
|
::testing::internal::GetCapturedStdout();
|
||||||
|
|
||||||
|
EXPECT_EQ(boxlo[0], 0.0);
|
||||||
|
EXPECT_EQ(boxlo[1], 0.0);
|
||||||
|
EXPECT_EQ(boxlo[2], 0.0);
|
||||||
|
|
||||||
|
EXPECT_EQ(boxhi[0], 2.0);
|
||||||
|
EXPECT_EQ(boxhi[1], 2.0);
|
||||||
|
EXPECT_EQ(boxhi[2], 2.0);
|
||||||
|
|
||||||
|
double * sublo = (double*)lammps_extract_global(lmp, "sublo");
|
||||||
|
double * subhi = (double*)lammps_extract_global(lmp, "subhi");
|
||||||
|
|
||||||
|
ASSERT_NE(sublo, nullptr);
|
||||||
|
ASSERT_NE(subhi, nullptr);
|
||||||
|
|
||||||
|
EXPECT_GE(sublo[0], boxlo[0]);
|
||||||
|
EXPECT_GE(sublo[1], boxlo[1]);
|
||||||
|
EXPECT_GE(sublo[2], boxlo[2]);
|
||||||
|
EXPECT_LE(subhi[0], boxhi[0]);
|
||||||
|
EXPECT_LE(subhi[1], boxhi[1]);
|
||||||
|
EXPECT_LE(subhi[2], boxhi[2]);
|
||||||
|
|
||||||
::testing::internal::CaptureStdout();
|
::testing::internal::CaptureStdout();
|
||||||
lammps_close(lmp);
|
lammps_close(lmp);
|
||||||
::testing::internal::GetCapturedStdout();
|
::testing::internal::GetCapturedStdout();
|
||||||
|
|||||||
Reference in New Issue
Block a user