start tests for lammps_extract_global()

This commit is contained in:
Axel Kohlmeyer
2020-09-15 09:27:07 -04:00
parent 39681acfa4
commit bc31486fd1
2 changed files with 28 additions and 1 deletions

View File

@ -10,8 +10,8 @@ variable improper_style index zero
atom_style full
atom_modify map array
neigh_modify delay 2 every 2 check no
timestep 0.1
units ${units}
timestep 0.1
pair_style ${pair_style}
bond_style ${bond_style}

View File

@ -2,6 +2,7 @@
#include "lammps.h"
#include "library.h"
#include "lmptype.h"
#include <string>
#include "gmock/gmock.h"
@ -14,6 +15,7 @@
using ::testing::HasSubstr;
using ::testing::StartsWith;
using ::testing::StrEq;
class LibraryProperties : public ::testing::Test {
protected:
@ -160,6 +162,7 @@ TEST_F(LibraryProperties, box)
EXPECT_DOUBLE_EQ(lammps_get_thermo(lmp, "vol"), 3390.3580784497199);
EXPECT_DOUBLE_EQ(lammps_get_thermo(lmp, "cellgamma"), 89.61785205109274);
};
TEST_F(LibraryProperties, setting)
{
#if defined(LAMMPS_SMALLSMALL)
@ -214,3 +217,27 @@ TEST_F(LibraryProperties, setting)
EXPECT_EQ(lammps_extract_setting(lmp, "rmass_flag"), 1);
}
};
TEST_F(LibraryProperties, global)
{
if (!lammps_has_style(lmp, "atom", "full")) GTEST_SKIP();
std::string input = INPUT_DIR + PATH_SEP + "in.fourmol";
if (!verbose) ::testing::internal::CaptureStdout();
lammps_file(lmp, input.c_str());
lammps_command(lmp, "run 2 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
LAMMPS_NS::bigint *b_ptr;
char *c_ptr;
double *d_ptr;
int *i_ptr;
EXPECT_EQ(lammps_extract_global(lmp, "UNKNOWN"), nullptr);
c_ptr = (char *)lammps_extract_global(lmp, "units");
EXPECT_THAT(c_ptr, StrEq("real"));
b_ptr = (LAMMPS_NS::bigint *)lammps_extract_global(lmp, "ntimestep");
EXPECT_EQ((*b_ptr), 2);
d_ptr = (double *)lammps_extract_global(lmp, "dt");
EXPECT_DOUBLE_EQ((*d_ptr), 0.1);
};