apply clang-format

This commit is contained in:
Axel Kohlmeyer
2022-01-30 17:18:40 -05:00
parent 3707b327c0
commit 7ee7d0c570
25 changed files with 77 additions and 68 deletions

View File

@ -20,7 +20,7 @@ const char *cont_input[] = {"create_atoms 1 single &", "0.2 0.1 0.1"};
class LibraryCommands : public ::testing::Test {
protected:
void *lmp;
LibraryCommands() = default;
LibraryCommands() = default;
~LibraryCommands() override = default;
void SetUp() override
@ -55,13 +55,13 @@ TEST_F(LibraryCommands, from_file)
const char cont_file[] = "in.cont";
fp = fopen(demo_file, "w");
for (auto & inp : demo_input) {
for (auto &inp : demo_input) {
fputs(inp, fp);
fputc('\n', fp);
}
fclose(fp);
fp = fopen(cont_file, "w");
for (auto & inp : cont_input) {
for (auto &inp : cont_input) {
fputs(inp, fp);
fputc('\n', fp);
}
@ -85,7 +85,7 @@ TEST_F(LibraryCommands, from_line)
{
EXPECT_EQ(lammps_get_natoms(lmp), 0);
if (!verbose) ::testing::internal::CaptureStdout();
for (auto & inp : demo_input) {
for (auto &inp : demo_input) {
lammps_command(lmp, inp);
}
if (!verbose) ::testing::internal::GetCapturedStdout();
@ -106,11 +106,11 @@ TEST_F(LibraryCommands, from_string)
{
std::string cmds("");
for (auto & inp : demo_input) {
for (auto &inp : demo_input) {
cmds += inp;
cmds += "\n";
}
for (auto & inp : cont_input) {
for (auto &inp : cont_input) {
cmds += inp;
cmds += "\n";
}
@ -126,11 +126,11 @@ TEST_F(LibraryCommands, from_string)
if (!verbose) ::testing::internal::GetCapturedStdout();
cmds.clear();
for (auto & inp : demo_input) {
for (auto &inp : demo_input) {
cmds += inp;
cmds += "\r\n";
}
for (auto & inp : cont_input) {
for (auto &inp : cont_input) {
cmds += inp;
cmds += "\r\n";
}

View File

@ -22,7 +22,7 @@ protected:
void *lmp;
std::string INPUT_DIR = STRINGIFY(TEST_INPUT_FOLDER);
LibraryConfig() = default;
LibraryConfig() = default;
~LibraryConfig() override = default;
void SetUp() override

View File

@ -23,7 +23,7 @@ protected:
void *lmp;
std::string INPUT_DIR = STRINGIFY(TEST_INPUT_FOLDER);
LibraryProperties() = default;
LibraryProperties() = default;
~LibraryProperties() override = default;
void SetUp() override
@ -436,8 +436,10 @@ class AtomProperties : public ::testing::Test {
protected:
void *lmp;
AtomProperties()= default;;
~AtomProperties() override= default;;
AtomProperties() = default;
;
~AtomProperties() override = default;
;
void SetUp() override
{

View File

@ -23,7 +23,7 @@ protected:
void *lmp;
std::string INPUT_DIR = STRINGIFY(TEST_INPUT_FOLDER);
GatherProperties() = default;
GatherProperties() = default;
~GatherProperties() override = default;
void SetUp() override

View File

@ -35,8 +35,8 @@ bool verbose = false;
using LAMMPS_NS::utils::split_words;
namespace LAMMPS_NS {
using ::testing::ExitedWithCode;
using ::testing::ContainsRegex;
using ::testing::ExitedWithCode;
using ::testing::StrEq;
class LatticeRegionTest : public LAMMPSTest {

View File

@ -39,8 +39,8 @@ bool verbose = false;
using LAMMPS_NS::utils::split_words;
namespace LAMMPS_NS {
using ::testing::ExitedWithCode;
using ::testing::ContainsRegex;
using ::testing::ExitedWithCode;
using ::testing::StrEq;
class SimpleCommandsTest : public LAMMPSTest {
@ -412,14 +412,14 @@ TEST_F(SimpleCommandsTest, Plugin)
text = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << text;
ASSERT_THAT(text, ContainsRegex(".*1: command style plugin hello"
".*2: fix style plugin nve2.*"));
".*2: fix style plugin nve2.*"));
::testing::internal::CaptureStdout();
lmp->input->one(fmt::format(loadfmt, "hello"));
text = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << text;
ASSERT_THAT(text, ContainsRegex(".*Ignoring load of command style hello: "
"must unload existing hello plugin.*"));
"must unload existing hello plugin.*"));
::testing::internal::CaptureStdout();
lmp->input->one("plugin unload command hello");
@ -479,7 +479,8 @@ TEST_F(SimpleCommandsTest, Shell)
test_var = getenv("TEST_VARIABLE");
ASSERT_NE(test_var, nullptr);
#if defined(_WIN32)
// we cannot create empty environment variables on Windows so platform::putenv() sets their value to "1"
// we cannot create empty environment variables on Windows so platform::putenv() sets their
// value to "1"
ASSERT_THAT(test_var, StrEq("1"));
#else
ASSERT_THAT(test_var, StrEq(""));
@ -501,7 +502,8 @@ TEST_F(SimpleCommandsTest, CiteMe)
// find the two unique citations, but not the third
ASSERT_THAT(text, ContainsRegex("test citation one.\n.*test citation two.*"));
ASSERT_THAT(text, Not(ContainsRegex("test citation one.\n.*test citation two.*\n.*test citation one.*")));
ASSERT_THAT(text, Not(ContainsRegex(
"test citation one.\n.*test citation two.*\n.*test citation one.*")));
BEGIN_CAPTURE_OUTPUT();
lmp->citeme->add("test citation one:\n 0\n");

View File

@ -36,8 +36,8 @@ using LAMMPS_NS::MathConst::MY_PI;
using LAMMPS_NS::utils::split_words;
namespace LAMMPS_NS {
using ::testing::ExitedWithCode;
using ::testing::ContainsRegex;
using ::testing::ExitedWithCode;
using ::testing::StrEq;
class VariableTest : public LAMMPSTest {
@ -317,7 +317,7 @@ TEST_F(VariableTest, Expressions)
ASSERT_TRUE(variable->equalstyle(ivar));
ASSERT_DOUBLE_EQ(variable->compute_equal(ivar), 2.0);
ASSERT_DOUBLE_EQ(variable->compute_equal("v_three"), 3.0);
ASSERT_NEAR(variable->compute_equal("v_four"), MY_PI,1.0e-14);
ASSERT_NEAR(variable->compute_equal("v_four"), MY_PI, 1.0e-14);
ASSERT_GE(variable->compute_equal("v_five"), 20210310);
ASSERT_DOUBLE_EQ(variable->compute_equal("v_seven"), -1);
ASSERT_DOUBLE_EQ(variable->compute_equal("v_eight"), 2.5);

View File

@ -60,13 +60,13 @@ TEST_F(Input_commands, from_file)
const char cont_file[] = "in.cont";
fp = fopen(demo_file, "w");
for (auto & inp : demo_input) {
for (auto &inp : demo_input) {
fputs(inp, fp);
fputc('\n', fp);
}
fclose(fp);
fp = fopen(cont_file, "w");
for (auto & inp : cont_input) {
for (auto &inp : cont_input) {
fputs(inp, fp);
fputc('\n', fp);
}
@ -84,7 +84,7 @@ TEST_F(Input_commands, from_file)
TEST_F(Input_commands, from_line)
{
EXPECT_EQ(lmp->atom->natoms, 0);
for (auto & inp : demo_input) {
for (auto &inp : demo_input) {
lmp->input->one(inp);
}
EXPECT_EQ(lmp->atom->natoms, 1);

View File

@ -372,8 +372,8 @@ TEST(LAMMPS_init, NoOpenMP)
::testing::internal::CaptureStdout();
LAMMPS *lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
std::string output = ::testing::internal::GetCapturedStdout();
EXPECT_THAT(output,
ContainsRegex(".*OMP_NUM_THREADS environment is not set.*Defaulting to 1 thread.*"));
EXPECT_THAT(output, ContainsRegex(
".*OMP_NUM_THREADS environment is not set.*Defaulting to 1 thread.*"));
EXPECT_EQ(lmp->comm->nthreads, 1);
::testing::internal::CaptureStdout();
delete lmp;

View File

@ -289,7 +289,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
// run_stress
stress = lmp->force->angle->virial;
block = fmt::format("{:23.16e} {:23.16e} {:23.16e} {:23.16e} {:23.16e} {:23.16e}", stress[0],
stress[1], stress[2], stress[3], stress[4], stress[5]);
stress[1], stress[2], stress[3], stress[4], stress[5]);
writer.emit_block("run_stress", block);
block.clear();

View File

@ -289,7 +289,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
// run_stress
stress = lmp->force->bond->virial;
block = fmt::format("{:23.16e} {:23.16e} {:23.16e} {:23.16e} {:23.16e} {:23.16e}", stress[0],
stress[1], stress[2], stress[3], stress[4], stress[5]);
stress[1], stress[2], stress[3], stress[4], stress[5]);
writer.emit_block("run_stress", block);
block.clear();

View File

@ -374,7 +374,7 @@ void TestConfigReader::tags(const yaml_event_t &event)
{
std::stringstream data((char *)event.data.scalar.value);
config.tags.clear();
for (std::string tag; std::getline(data, tag, ','); ) {
for (std::string tag; std::getline(data, tag, ',');) {
config.tags.push_back(trim(tag));
}
}

View File

@ -292,7 +292,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
// run_stress
stress = lmp->force->dihedral->virial;
block = fmt::format("{:23.16e} {:23.16e} {:23.16e} {:23.16e} {:23.16e} {:23.16e}", stress[0],
stress[1], stress[2], stress[3], stress[4], stress[5]);
stress[1], stress[2], stress[3], stress[4], stress[5]);
writer.emit_block("run_stress", block);
block.clear();

View File

@ -209,8 +209,8 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
if (fix->thermo_virial) {
auto stress = fix->virial;
block = fmt::format("{:23.16e} {:23.16e} {:23.16e} "
"{:23.16e} {:23.16e} {:23.16e}",
stress[0], stress[1], stress[2], stress[3], stress[4], stress[5]);
"{:23.16e} {:23.16e} {:23.16e}",
stress[0], stress[1], stress[2], stress[3], stress[4], stress[5]);
writer.emit_block("run_stress", block);
}

View File

@ -283,7 +283,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
// run_stress
stress = lmp->force->improper->virial;
block = fmt::format("{:23.16e} {:23.16e} {:23.16e} {:23.16e} {:23.16e} {:23.16e}", stress[0],
stress[1], stress[2], stress[3], stress[4], stress[5]);
stress[1], stress[2], stress[3], stress[4], stress[5]);
writer.emit_block("run_stress", block);
block.clear();

View File

@ -2123,7 +2123,7 @@ TEST_F(AtomStyleTest, body_nparticle)
"12.0 0.0 12.0 0.0 0.0 0.0\n"
"0.0 1.0 0.0\n"
"0.0 -3.0 0.0\n";
FILE *fp = fopen("input_atom_styles.data", "w");
FILE *fp = fopen("input_atom_styles.data", "w");
fputs(data_file, fp);
fclose(fp);
BEGIN_HIDE_OUTPUT();

View File

@ -547,12 +547,12 @@ TEST_F(DumpAtomTest, rerun_bin)
command(fmt::format("rerun {} first 1 last 1 every 1 post no dump x y z", dump_file));
});
lmp->output->thermo->evaluate_keyword("pe", &pe_rerun);
ASSERT_NEAR(pe_1, pe_rerun,1.0e-14);
ASSERT_NEAR(pe_1, pe_rerun, 1.0e-14);
HIDE_OUTPUT([&] {
command(fmt::format("rerun {} first 2 last 2 every 1 post yes dump x y z", dump_file));
});
lmp->output->thermo->evaluate_keyword("pe", &pe_rerun);
ASSERT_NEAR(pe_2, pe_rerun,1.0e-14);
ASSERT_NEAR(pe_2, pe_rerun, 1.0e-14);
delete_file(dump_file);
}

View File

@ -346,7 +346,7 @@ TEST_F(DumpCustomTest, rerun)
});
lmp->output->thermo->evaluate_keyword("pe", &pe_rerun);
ASSERT_DOUBLE_EQ(pe_1, pe_rerun);
HIDE_OUTPUT([&] {
command(fmt::format("rerun {} first 2 last 2 every 1 post yes dump x y z", dump_file));
});
@ -375,12 +375,12 @@ TEST_F(DumpCustomTest, rerun_bin)
command(fmt::format("rerun {} first 1 last 1 every 1 post no dump x y z", dump_file));
});
lmp->output->thermo->evaluate_keyword("pe", &pe_rerun);
ASSERT_NEAR(pe_1, pe_rerun,1.0e-14);
ASSERT_NEAR(pe_1, pe_rerun, 1.0e-14);
HIDE_OUTPUT([&] {
command(fmt::format("rerun {} first 2 last 2 every 1 post yes dump x y z", dump_file));
});
lmp->output->thermo->evaluate_keyword("pe", &pe_rerun);
ASSERT_NEAR(pe_2, pe_rerun,1.0e-14);
ASSERT_NEAR(pe_2, pe_rerun, 1.0e-14);
delete_file(dump_file);
}

View File

@ -334,7 +334,9 @@ TEST_F(FileOperationsTest, write_restart)
ASSERT_FILE_EXISTS("multi2-0.restart");
ASSERT_FILE_EXISTS("multi3-base.restart");
ASSERT_FILE_EXISTS("multi3-0.restart");
if (info->has_package("MPIIO")) { ASSERT_FILE_EXISTS("test.restart.mpiio"); }
if (info->has_package("MPIIO")) {
ASSERT_FILE_EXISTS("test.restart.mpiio");
}
if (!info->has_package("MPIIO")) {
TEST_FAILURE(".*ERROR: Writing to MPI-IO filename when MPIIO package is not inst.*",

View File

@ -189,7 +189,7 @@ TEST_F(MoleculeFileTest, notype)
".*0 fragments.*\n.*1 atoms.*\n.*0 bonds.*"));
TEST_FAILURE(".*ERROR: Create_atoms molecule must have atom types.*",
command("create_atoms 0 single 0.0 0.0 0.0 mol notype 542465"););
}
}
TEST_F(MoleculeFileTest, extramass)
{
@ -197,12 +197,13 @@ TEST_F(MoleculeFileTest, extramass)
command("atom_style atomic");
command("region box block 0 1 0 1 0 1");
command("create_box 1 box");
run_mol_cmd(test_name, "", "Comment\n1 atoms\n\n Coords\n\n 1 0.0 0.0 0.0\n"
run_mol_cmd(test_name, "",
"Comment\n1 atoms\n\n Coords\n\n 1 0.0 0.0 0.0\n"
" Types\n\n 1 1\n Masses\n\n 1 1.0\n");
command("create_atoms 0 single 0.0 0.0 0.0 mol extramass 73546");
auto output = END_CAPTURE_OUTPUT();
ASSERT_THAT(output, ContainsRegex(".*WARNING: Molecule attributes do not match "
"system attributes.*"));
"system attributes.*"));
}
TEST_F(MoleculeFileTest, twomols)
@ -222,12 +223,14 @@ TEST_F(MoleculeFileTest, twofiles)
BEGIN_CAPTURE_OUTPUT();
command("molecule twomols moltest.h2o.mol moltest.co2.mol offset 2 1 1 0 0");
auto output = END_CAPTURE_OUTPUT();
ASSERT_THAT(output, ContainsRegex(".*Read molecule template twomols:.*\n.*1 molecules.*\n"
".*0 fragments.*\n.*3 atoms with max type 2.*\n.*2 bonds with max type 1.*\n"
".*1 angles with max type 1.*\n.*0 dihedrals.*\n.*0 impropers.*\n"
".*Read molecule template twomols:.*\n.*1 molecules.*\n"
".*0 fragments.*\n.*3 atoms with max type 4.*\n.*2 bonds with max type 2.*\n"
".*1 angles with max type 2.*\n.*0 dihedrals.*"));
ASSERT_THAT(
output,
ContainsRegex(".*Read molecule template twomols:.*\n.*1 molecules.*\n"
".*0 fragments.*\n.*3 atoms with max type 2.*\n.*2 bonds with max type 1.*\n"
".*1 angles with max type 1.*\n.*0 dihedrals.*\n.*0 impropers.*\n"
".*Read molecule template twomols:.*\n.*1 molecules.*\n"
".*0 fragments.*\n.*3 atoms with max type 4.*\n.*2 bonds with max type 2.*\n"
".*1 angles with max type 2.*\n.*0 dihedrals.*"));
}
TEST_F(MoleculeFileTest, bonds)

View File

@ -72,7 +72,7 @@ TEST_F(TextFileReaderTest, permissions)
{
platform::unlink("text_reader_noperms.file");
FILE *fp = fopen("text_reader_noperms.file", "w");
ASSERT_NE(fp,nullptr);
ASSERT_NE(fp, nullptr);
fputs("word\n", fp);
fclose(fp);
chmod("text_reader_noperms.file", 0);

View File

@ -43,9 +43,9 @@ bool verbose = false;
using LAMMPS_NS::utils::split_words;
namespace LAMMPS_NS {
using ::testing::ContainsRegex;
using ::testing::Eq;
using ::testing::HasSubstr;
using ::testing::ContainsRegex;
using ::testing::StrEq;
class PythonPackageTest : public LAMMPSTest {

View File

@ -48,7 +48,7 @@ inline static bool SimilarVec(Vector a, Vector b, int n, Scalar eps = 1.0e-06,
Scalar ratio = 1.0e-06, Scalar ratio_denom = 1.0)
{
for (int i = 0; i < n; i++)
if (! Similar(a[i], b[i], eps, ratio, ratio_denom)) return false;
if (!Similar(a[i], b[i], eps, ratio, ratio_denom)) return false;
return true;
}
@ -61,7 +61,7 @@ inline static bool SimilarVecUnsigned(Vector a, Vector b, int n, Scalar eps = 1.
return true;
else {
for (int i = 0; i < n; i++)
if (! Similar(a[i], -b[i], eps, ratio, ratio_denom)) return false;
if (!Similar(a[i], -b[i], eps, ratio, ratio_denom)) return false;
return true;
}
}
@ -464,7 +464,7 @@ void TestJacobi(int n, //<! matrix size
Scalar const(*)[NF]>::SORT_INCREASING_ABS_EVALS);
#else
ecalc.Diagonalize(M, evals, evecs,
Jacobi<Scalar, Scalar *, Scalar **,
Jacobi<Scalar, Scalar *, Scalar **,
Scalar const *const *>::SORT_INCREASING_ABS_EVALS);
#endif
@ -488,7 +488,7 @@ void TestJacobi(int n, //<! matrix size
Scalar const(*)[NF]>::SORT_DECREASING_ABS_EVALS);
#else
ecalc.Diagonalize(M, evals, evecs,
Jacobi<Scalar, Scalar *, Scalar **,
Jacobi<Scalar, Scalar *, Scalar **,
Scalar const *const *>::SORT_DECREASING_ABS_EVALS);
#endif
@ -511,7 +511,7 @@ void TestJacobi(int n, //<! matrix size
Scalar const(*)[NF]>::SORT_INCREASING_EVALS);
#else
ecalc.Diagonalize(M, evals, evecs,
Jacobi<Scalar, Scalar *, Scalar **,
Jacobi<Scalar, Scalar *, Scalar **,
Scalar const *const *>::SORT_INCREASING_EVALS);
#endif
for (int i = 1; i < n; i++)
@ -533,8 +533,8 @@ void TestJacobi(int n, //<! matrix size
Jacobi<Scalar, Scalar *, Scalar(*)[NF], Scalar const(*)[NF]>::DO_NOT_SORT);
#else
ecalc.Diagonalize(
M, evals, evecs,
Jacobi<Scalar, Scalar *, Scalar **, Scalar const *const *>::DO_NOT_SORT);
M, evals, evecs,
Jacobi<Scalar, Scalar *, Scalar **, Scalar const *const *>::DO_NOT_SORT);
#endif
} // if (test_code_coverage)

View File

@ -68,10 +68,10 @@ TEST(Platform, putenv_unsetenv)
ASSERT_EQ(platform::unsetenv(""), -1);
ASSERT_EQ(platform::unsetenv("UNITTEST_VAR3=two"), -1);
var = getenv("UNITTEST_VAR1");
var = getenv("UNITTEST_VAR1");
ASSERT_NE(var, nullptr);
ASSERT_EQ(platform::unsetenv("UNITTEST_VAR1"), 0);
var = getenv("UNITTEST_VAR1");
var = getenv("UNITTEST_VAR1");
ASSERT_EQ(var, nullptr);
}

View File

@ -838,15 +838,15 @@ TEST(Utils, date2num)
TEST(Utils, current_date)
{
auto vals = ValueTokenizer(utils::current_date(),"-");
int year = vals.next_int();
auto vals = ValueTokenizer(utils::current_date(), "-");
int year = vals.next_int();
int month = vals.next_int();
int day = vals.next_int();
ASSERT_GT(year,2020);
ASSERT_GE(month,1);
ASSERT_GE(day,1);
ASSERT_LE(month,12);
ASSERT_LE(day,31);
int day = vals.next_int();
ASSERT_GT(year, 2020);
ASSERT_GE(month, 1);
ASSERT_GE(day, 1);
ASSERT_LE(month, 12);
ASSERT_LE(day, 31);
}
TEST(Utils, binary_search)