simplify and apply clang-format

This commit is contained in:
Axel Kohlmeyer
2021-03-24 11:24:55 -04:00
parent b6a030532d
commit 487c55edf0
21 changed files with 983 additions and 1016 deletions

View File

@ -28,7 +28,6 @@ using LAMMPS_NS::utils::split_words;
namespace LAMMPS_NS {
using ::testing::Eq;
class ImageFlagsTest : public ::testing::Test {
protected:
LAMMPS *lmp;
@ -43,18 +42,18 @@ protected:
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_NE(lmp, nullptr);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("units real");
lmp->input->one("dimension 3");
lmp->input->one("region box block -2 2 -2 2 -2 2");
lmp->input->one("create_box 1 box");
lmp->input->one("create_atoms 1 single 0.0 0.0 0.0 units box");
lmp->input->one("create_atoms 1 single 1.9 -1.9 1.9999 units box");
lmp->input->one("pair_style zero 2.0");
lmp->input->one("pair_coeff * *");
lmp->input->one("mass * 1.0");
lmp->input->one("set atom 1 image -1 2 3");
lmp->input->one("set atom 2 image -2 1 -1");
lmp->input->one("write_data test_image_flags.data");
command("units real");
command("dimension 3");
command("region box block -2 2 -2 2 -2 2");
command("create_box 1 box");
command("create_atoms 1 single 0.0 0.0 0.0 units box");
command("create_atoms 1 single 1.9 -1.9 1.9999 units box");
command("pair_style zero 2.0");
command("pair_coeff * *");
command("mass * 1.0");
command("set atom 1 image -1 2 3");
command("set atom 2 image -2 1 -1");
command("write_data test_image_flags.data");
if (!verbose) ::testing::internal::GetCapturedStdout();
}
@ -65,196 +64,198 @@ protected:
if (!verbose) ::testing::internal::GetCapturedStdout();
remove("test_image_flags.data");
}
void command(const std::string &cmd) { lmp->input->one(cmd); }
};
TEST_F(ImageFlagsTest, change_box)
{
auto image = lmp->atom->image;
int imx = (image[0] & IMGMASK) - IMGMAX;
int imy = (image[0] >> IMGBITS & IMGMASK) - IMGMAX;
int imz = (image[0] >> IMG2BITS) - IMGMAX;
int imx = (image[0] & IMGMASK) - IMGMAX;
int imy = (image[0] >> IMGBITS & IMGMASK) - IMGMAX;
int imz = (image[0] >> IMG2BITS) - IMGMAX;
ASSERT_EQ(imx, -1);
ASSERT_EQ(imy, 2);
ASSERT_EQ(imz, 3);
ASSERT_EQ(imx,-1);
ASSERT_EQ(imy,2);
ASSERT_EQ(imz,3);
imx = (image[1] & IMGMASK) - IMGMAX;
imy = (image[1] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[1] >> IMG2BITS) - IMGMAX;
ASSERT_EQ(imx,-2);
ASSERT_EQ(imy,1);
ASSERT_EQ(imz,-1);
ASSERT_EQ(imx, -2);
ASSERT_EQ(imy, 1);
ASSERT_EQ(imz, -1);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("change_box all boundary f p p");
command("change_box all boundary f p p");
if (!verbose) ::testing::internal::GetCapturedStdout();
image = lmp->atom->image;
imx = (image[0] & IMGMASK) - IMGMAX;
imy = (image[0] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[0] >> IMG2BITS) - IMGMAX;
imx = (image[0] & IMGMASK) - IMGMAX;
imy = (image[0] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[0] >> IMG2BITS) - IMGMAX;
ASSERT_EQ(imx,0);
ASSERT_EQ(imy,2);
ASSERT_EQ(imz,3);
ASSERT_EQ(imx, 0);
ASSERT_EQ(imy, 2);
ASSERT_EQ(imz, 3);
imx = (image[1] & IMGMASK) - IMGMAX;
imy = (image[1] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[1] >> IMG2BITS) - IMGMAX;
ASSERT_EQ(imx,0);
ASSERT_EQ(imy,1);
ASSERT_EQ(imz,-1);
ASSERT_EQ(imx, 0);
ASSERT_EQ(imy, 1);
ASSERT_EQ(imz, -1);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("change_box all boundary f s p");
command("change_box all boundary f s p");
if (!verbose) ::testing::internal::GetCapturedStdout();
image = lmp->atom->image;
imx = (image[0] & IMGMASK) - IMGMAX;
imy = (image[0] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[0] >> IMG2BITS) - IMGMAX;
imx = (image[0] & IMGMASK) - IMGMAX;
imy = (image[0] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[0] >> IMG2BITS) - IMGMAX;
ASSERT_EQ(imx,0);
ASSERT_EQ(imy,0);
ASSERT_EQ(imz,3);
ASSERT_EQ(imx, 0);
ASSERT_EQ(imy, 0);
ASSERT_EQ(imz, 3);
imx = (image[1] & IMGMASK) - IMGMAX;
imy = (image[1] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[1] >> IMG2BITS) - IMGMAX;
ASSERT_EQ(imx,0);
ASSERT_EQ(imy,0);
ASSERT_EQ(imz,-1);
ASSERT_EQ(imx, 0);
ASSERT_EQ(imy, 0);
ASSERT_EQ(imz, -1);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("change_box all boundary p p m");
command("change_box all boundary p p m");
if (!verbose) ::testing::internal::GetCapturedStdout();
image = lmp->atom->image;
imx = (image[0] & IMGMASK) - IMGMAX;
imy = (image[0] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[0] >> IMG2BITS) - IMGMAX;
imx = (image[0] & IMGMASK) - IMGMAX;
imy = (image[0] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[0] >> IMG2BITS) - IMGMAX;
ASSERT_EQ(imx,0);
ASSERT_EQ(imy,0);
ASSERT_EQ(imz,0);
ASSERT_EQ(imx, 0);
ASSERT_EQ(imy, 0);
ASSERT_EQ(imz, 0);
imx = (image[1] & IMGMASK) - IMGMAX;
imy = (image[1] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[1] >> IMG2BITS) - IMGMAX;
ASSERT_EQ(imx,0);
ASSERT_EQ(imy,0);
ASSERT_EQ(imz,0);
ASSERT_EQ(imx, 0);
ASSERT_EQ(imy, 0);
ASSERT_EQ(imz, 0);
}
TEST_F(ImageFlagsTest, read_data)
{
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("units real");
lmp->input->one("dimension 3");
lmp->input->one("boundary p p p");
lmp->input->one("pair_style zero 2.0");
lmp->input->one("read_data test_image_flags.data");
command("clear");
command("units real");
command("dimension 3");
command("boundary p p p");
command("pair_style zero 2.0");
command("read_data test_image_flags.data");
if (!verbose) ::testing::internal::GetCapturedStdout();
auto image = lmp->atom->image;
int imx = (image[0] & IMGMASK) - IMGMAX;
int imy = (image[0] >> IMGBITS & IMGMASK) - IMGMAX;
int imz = (image[0] >> IMG2BITS) - IMGMAX;
int imx = (image[0] & IMGMASK) - IMGMAX;
int imy = (image[0] >> IMGBITS & IMGMASK) - IMGMAX;
int imz = (image[0] >> IMG2BITS) - IMGMAX;
ASSERT_EQ(imx, -1);
ASSERT_EQ(imy, 2);
ASSERT_EQ(imz, 3);
ASSERT_EQ(imx,-1);
ASSERT_EQ(imy,2);
ASSERT_EQ(imz,3);
imx = (image[1] & IMGMASK) - IMGMAX;
imy = (image[1] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[1] >> IMG2BITS) - IMGMAX;
ASSERT_EQ(imx,-2);
ASSERT_EQ(imy,1);
ASSERT_EQ(imz,-1);
ASSERT_EQ(imx, -2);
ASSERT_EQ(imy, 1);
ASSERT_EQ(imz, -1);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("units real");
lmp->input->one("dimension 3");
lmp->input->one("boundary f p p");
lmp->input->one("pair_style zero 2.0");
lmp->input->one("read_data test_image_flags.data");
command("clear");
command("units real");
command("dimension 3");
command("boundary f p p");
command("pair_style zero 2.0");
command("read_data test_image_flags.data");
if (!verbose) ::testing::internal::GetCapturedStdout();
image = lmp->atom->image;
imx = (image[0] & IMGMASK) - IMGMAX;
imy = (image[0] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[0] >> IMG2BITS) - IMGMAX;
imx = (image[0] & IMGMASK) - IMGMAX;
imy = (image[0] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[0] >> IMG2BITS) - IMGMAX;
ASSERT_EQ(imx,0);
ASSERT_EQ(imy,2);
ASSERT_EQ(imz,3);
ASSERT_EQ(imx, 0);
ASSERT_EQ(imy, 2);
ASSERT_EQ(imz, 3);
imx = (image[1] & IMGMASK) - IMGMAX;
imy = (image[1] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[1] >> IMG2BITS) - IMGMAX;
ASSERT_EQ(imx,0);
ASSERT_EQ(imy,1);
ASSERT_EQ(imz,-1);
ASSERT_EQ(imx, 0);
ASSERT_EQ(imy, 1);
ASSERT_EQ(imz, -1);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("units real");
lmp->input->one("dimension 3");
lmp->input->one("boundary p s p");
lmp->input->one("pair_style zero 2.0");
lmp->input->one("read_data test_image_flags.data");
command("clear");
command("units real");
command("dimension 3");
command("boundary p s p");
command("pair_style zero 2.0");
command("read_data test_image_flags.data");
if (!verbose) ::testing::internal::GetCapturedStdout();
image = lmp->atom->image;
imx = (image[0] & IMGMASK) - IMGMAX;
imy = (image[0] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[0] >> IMG2BITS) - IMGMAX;
imx = (image[0] & IMGMASK) - IMGMAX;
imy = (image[0] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[0] >> IMG2BITS) - IMGMAX;
ASSERT_EQ(imx,-1);
ASSERT_EQ(imy,0);
ASSERT_EQ(imz,3);
ASSERT_EQ(imx, -1);
ASSERT_EQ(imy, 0);
ASSERT_EQ(imz, 3);
imx = (image[1] & IMGMASK) - IMGMAX;
imy = (image[1] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[1] >> IMG2BITS) - IMGMAX;
ASSERT_EQ(imx,-2);
ASSERT_EQ(imy,0);
ASSERT_EQ(imz,-1);
ASSERT_EQ(imx, -2);
ASSERT_EQ(imy, 0);
ASSERT_EQ(imz, -1);
if (!verbose) ::testing::internal::CaptureStdout();
lmp->input->one("clear");
lmp->input->one("units real");
lmp->input->one("dimension 3");
lmp->input->one("boundary p p m");
lmp->input->one("pair_style zero 2.0");
lmp->input->one("read_data test_image_flags.data");
command("clear");
command("units real");
command("dimension 3");
command("boundary p p m");
command("pair_style zero 2.0");
command("read_data test_image_flags.data");
if (!verbose) ::testing::internal::GetCapturedStdout();
image = lmp->atom->image;
imx = (image[0] & IMGMASK) - IMGMAX;
imy = (image[0] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[0] >> IMG2BITS) - IMGMAX;
imx = (image[0] & IMGMASK) - IMGMAX;
imy = (image[0] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[0] >> IMG2BITS) - IMGMAX;
ASSERT_EQ(imx,-1);
ASSERT_EQ(imy,2);
ASSERT_EQ(imz,0);
ASSERT_EQ(imx, -1);
ASSERT_EQ(imy, 2);
ASSERT_EQ(imz, 0);
imx = (image[1] & IMGMASK) - IMGMAX;
imy = (image[1] >> IMGBITS & IMGMASK) - IMGMAX;
imz = (image[1] >> IMG2BITS) - IMGMAX;
ASSERT_EQ(imx,-2);
ASSERT_EQ(imy,1);
ASSERT_EQ(imz,0);
ASSERT_EQ(imx, -2);
ASSERT_EQ(imy, 1);
ASSERT_EQ(imz, 0);
}
} // namespace LAMMPS_NS