reformat unittest tree with clang-format

This commit is contained in:
Axel Kohlmeyer
2021-08-23 17:06:30 -04:00
parent 0f8b331d8f
commit 6bc8da05b9
37 changed files with 501 additions and 453 deletions

View File

@ -20,9 +20,9 @@
#include "input.h"
#include "region.h"
#include "../testing/core.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "../testing/core.h"
#include <cstring>
#include <vector>

View File

@ -11,6 +11,7 @@
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#include "../testing/core.h"
#include "fmt/format.h"
#include "info.h"
#include "input.h"
@ -22,7 +23,6 @@
#include "variable.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "../testing/core.h"
#include <cstdlib>
#include <mpi.h>
@ -36,7 +36,6 @@ namespace LAMMPS_NS {
using ::testing::MatchesRegex;
using ::testing::StrEq;
class KimCommandsTest : public LAMMPSTest {
protected:
Variable *variable;

View File

@ -11,6 +11,7 @@
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#include "../testing/core.h"
#include "atom.h"
#include "domain.h"
#include "fmt/format.h"
@ -22,7 +23,6 @@
#include "utils.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "../testing/core.h"
#include <cstdio>
#include <cstring>
@ -40,7 +40,6 @@ using ::testing::ExitedWithCode;
using ::testing::MatchesRegex;
using ::testing::StrEq;
class LatticeRegionTest : public LAMMPSTest {
protected:
void SetUp() override

View File

@ -1,14 +1,14 @@
// unit tests for checking LAMMPS MPI load balancing
#define LAMMPS_LIB_MPI 1
#include "lammps.h"
#include "atom.h"
#include "comm.h"
#include "domain.h"
#include "neighbor.h"
#include "input.h"
#include "timer.h"
#include "info.h"
#include "input.h"
#include "lammps.h"
#include "neighbor.h"
#include "timer.h"
#include <string>
#include "gmock/gmock.h"
@ -21,8 +21,7 @@ using ::testing::HasSubstr;
using ::testing::StartsWith;
using ::testing::StrEq;
namespace LAMMPS_NS
{
namespace LAMMPS_NS {
class MPILoadBalanceTest : public ::testing::Test {
public:
@ -54,7 +53,6 @@ protected:
command("create_box 1 box");
command("mass 1 1.0");
command("pair_style lj/cut 2.5");
command("pair_coeff 1 1 1.0 1.0 2.5");
@ -254,4 +252,4 @@ TEST_F(MPILoadBalanceTest, rcb_min_size)
ASSERT_GT(dz, lmp->neighbor->skin);
}
}
} // namespace LAMMPS_NS

View File

@ -11,6 +11,7 @@
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#include "../testing/core.h"
#include "atom.h"
#include "fmt/format.h"
#include "info.h"
@ -21,7 +22,6 @@
#include "utils.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "../testing/core.h"
#include <cstdio>
#include <mpi.h>
@ -36,7 +36,6 @@ using ::testing::MatchesRegex;
#define GETIDX(i) lmp->atom->map(i)
#define STRINGIFY(val) XSTR(val)
#define XSTR(val) #val

View File

@ -23,10 +23,10 @@
#include "utils.h"
#include "variable.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "../testing/core.h"
#include "../testing/utils.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include <cstdio>
#include <cstring>
@ -37,7 +37,6 @@
// whether to print verbose output (i.e. not capturing LAMMPS screen output).
bool verbose = false;
using LAMMPS_NS::utils::split_words;
namespace LAMMPS_NS {
@ -205,7 +204,8 @@ TEST_F(SimpleCommandsTest, Processors)
ASSERT_EQ(lmp->comm->user_procgrid[2], 0);
TEST_FAILURE(".*ERROR: Illegal processors command .*", command("processors -1 0 0"););
TEST_FAILURE(".*ERROR: Specified processors != physical processors.*", command("processors 100 100 100"););
TEST_FAILURE(".*ERROR: Specified processors != physical processors.*",
command("processors 100 100 100"););
}
TEST_F(SimpleCommandsTest, Quit)

View File

@ -22,9 +22,9 @@
#include "region.h"
#include "variable.h"
#include "../testing/core.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "../testing/core.h"
#include <cstring>
#include <vector>
@ -40,7 +40,6 @@ using ::testing::ExitedWithCode;
using ::testing::MatchesRegex;
using ::testing::StrEq;
class VariableTest : public LAMMPSTest {
protected:
Group *group;
@ -218,7 +217,9 @@ TEST_F(VariableTest, CreateDelete)
TEST_F(VariableTest, AtomicSystem)
{
HIDE_OUTPUT([&] { command("atom_modify map array"); });
HIDE_OUTPUT([&] {
command("atom_modify map array");
});
atomic_system();
file_vars();

View File

@ -13,9 +13,9 @@
#include "test_config_reader.h"
#include "test_config.h"
#include "utils.h"
#include "yaml.h"
#include "yaml_reader.h"
#include "utils.h"
#include <cstdlib>
#include <cstring>

View File

@ -938,8 +938,7 @@ TEST(FixTimestep, omp)
// rigid fixes need work to test properly with r-RESPA,
// also, torque is not supported by respa/omp
ifix = lmp->modify->find_fix("test");
if (!utils::strmatch(lmp->modify->fix[ifix]->style, "^rigid")
&& !lmp->atom->torque) {
if (!utils::strmatch(lmp->modify->fix[ifix]->style, "^rigid") && !lmp->atom->torque) {
if (!verbose) ::testing::internal::CaptureStdout();
cleanup_lammps(lmp, test_config);

View File

@ -41,9 +41,7 @@ bool read_yaml_file(const char *infile, TestConfig &config)
}
// write out common header items for yaml files
void write_yaml_header(YamlWriter *writer,
TestConfig *cfg,
const char *version)
void write_yaml_header(YamlWriter *writer, TestConfig *cfg, const char *version)
{
// lammps_version
writer->emit("lammps_version", version);
@ -59,8 +57,10 @@ void write_yaml_header(YamlWriter *writer,
// skip tests
block.clear();
for (auto &skip : cfg->skip_tests) {
if (block.empty()) block = skip;
else block += " " + skip;
if (block.empty())
block = skip;
else
block += " " + skip;
}
writer->emit("skip_tests", block);

View File

@ -23,8 +23,7 @@ extern bool verbose;
extern std::string INPUT_FOLDER;
// convenience method to write out common entries
void write_yaml_header(class YamlWriter *writer, TestConfig *cfg,
const char *version);
void write_yaml_header(class YamlWriter *writer, TestConfig *cfg, const char *version);
#define EXPECT_FP_LE_WITH_EPS(val1, val2, eps) \
do { \
@ -42,4 +41,3 @@ static const char PATH_SEP = '/';
#endif
#endif

View File

@ -279,7 +279,8 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
// init_stress
auto stress = lmp->force->pair->virial;
// avoid false positives on tiny stresses. force to zero instead.
for (int i = 0; i < 6; ++i) if (fabs(stress[i]) < 1.0e-13) stress[i] = 0.0;
for (int i = 0; i < 6; ++i)
if (fabs(stress[i]) < 1.0e-13) stress[i] = 0.0;
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]);
writer.emit_block("init_stress", block);
@ -305,7 +306,8 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
// run_stress
stress = lmp->force->pair->virial;
// avoid false positives on tiny stresses. force to zero instead.
for (int i = 0; i < 6; ++i) if (fabs(stress[i]) < 1.0e-13) stress[i] = 0.0;
for (int i = 0; i < 6; ++i)
if (fabs(stress[i]) < 1.0e-13) stress[i] = 0.0;
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]);
writer.emit_block("run_stress", block);

View File

@ -12,8 +12,8 @@
------------------------------------------------------------------------- */
#include "yaml_writer.h"
#include "yaml.h"
#include "fmt/format.h"
#include "yaml.h"
#include <cstdio>
#include <string>

View File

@ -27,19 +27,23 @@ protected:
std::string compression_style;
public:
CompressedDumpTest(const std::string & dump_style) : MeltTest(), dump_style(dump_style) {
CompressedDumpTest(const std::string &dump_style) : MeltTest(), dump_style(dump_style)
{
compression_style = fmt::format("{}/{}", dump_style, COMPRESS_SUFFIX);
}
std::string text_dump_filename(std::string ident) {
std::string text_dump_filename(std::string ident)
{
return fmt::format("dump_{}_text_{}", COMPRESS_SUFFIX, ident);
}
std::string compressed_dump_filename(std::string ident) {
std::string compressed_dump_filename(std::string ident)
{
return fmt::format("dump_{}_compressed_{}.{}", COMPRESS_SUFFIX, ident, COMPRESS_EXTENSION);
}
std::string converted_dump_filename(std::string ident) {
std::string converted_dump_filename(std::string ident)
{
return fmt::format("dump_{}_compressed_{}", COMPRESS_SUFFIX, ident);
}
@ -64,21 +68,22 @@ public:
}
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file,
std::string dump_options, std::string dump_modify_options, int ntimesteps)
std::string dump_options,
std::string dump_modify_options, int ntimesteps)
{
generate_text_and_compressed_dump(text_file, compressed_file,
dump_options, dump_options,
generate_text_and_compressed_dump(text_file, compressed_file, dump_options, dump_options,
dump_modify_options, dump_modify_options, ntimesteps);
}
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file,
std::string text_options, std::string compressed_options,
std::string text_modify_options, std::string compressed_modify_options,
int ntimesteps)
std::string text_modify_options,
std::string compressed_modify_options, int ntimesteps)
{
BEGIN_HIDE_OUTPUT();
command(fmt::format("dump id0 all {} 1 {} {}", dump_style, text_file, text_options));
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_file, compressed_options));
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_file,
compressed_options));
if (!text_modify_options.empty()) {
command(fmt::format("dump_modify id0 {}", text_modify_options));

View File

@ -11,8 +11,8 @@
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#include "compressed_dump_test.h"
#include "../testing/utils.h"
#include "compressed_dump_test.h"
#include "fmt/format.h"
#include "utils.h"
#include "gmock/gmock.h"

View File

@ -20,13 +20,11 @@
#include <string>
using ::testing::Eq;
class DumpAtomCompressTest : public CompressedDumpTest {
public:
DumpAtomCompressTest() : CompressedDumpTest("atom") {
}
DumpAtomCompressTest() : CompressedDumpTest("atom") {}
};
//-------------------------------------------------------------------------------------------------
@ -41,7 +39,8 @@ TEST_F(DumpAtomCompressTest, compressed_run0)
auto compressed_file = compressed_dump_filename("run0.melt");
if (compression_style == "atom/zstd") {
generate_text_and_compressed_dump(text_file, compressed_file, "", "", "", "checksum yes", 0);
generate_text_and_compressed_dump(text_file, compressed_file, "", "", "", "checksum yes",
0);
} else {
generate_text_and_compressed_dump(text_file, compressed_file, "", "", 0);
}
@ -69,7 +68,8 @@ TEST_F(DumpAtomCompressTest, compressed_no_buffer_run0)
auto compressed_file = compressed_dump_filename("no_buffer_run0.melt");
if (compression_style == "atom/zstd") {
generate_text_and_compressed_dump(text_file, compressed_file, "", "", "buffer no", "buffer no checksum yes", 0);
generate_text_and_compressed_dump(text_file, compressed_file, "", "", "buffer no",
"buffer no checksum yes", 0);
} else {
generate_text_and_compressed_dump(text_file, compressed_file, "", "buffer no", 0);
}
@ -369,12 +369,13 @@ TEST_F(DumpAtomCompressTest, compressed_modify_bad_param)
if (compression_style != "atom/gz") GTEST_SKIP();
BEGIN_HIDE_OUTPUT();
command(fmt::format("dump id1 all {} 1 {}", compression_style, compressed_dump_filename("modify_bad_param_run0_*.melt")));
command(fmt::format("dump id1 all {} 1 {}", compression_style,
compressed_dump_filename("modify_bad_param_run0_*.melt")));
END_HIDE_OUTPUT();
TEST_FAILURE(".*ERROR on proc 0: Illegal dump_modify command: Compression level must in the range of.*",
command("dump_modify id1 compression_level 12");
);
TEST_FAILURE(
".*ERROR on proc 0: Illegal dump_modify command: Compression level must in the range of.*",
command("dump_modify id1 compression_level 12"););
}
TEST_F(DumpAtomCompressTest, compressed_modify_multi_bad_param)
@ -382,12 +383,13 @@ TEST_F(DumpAtomCompressTest, compressed_modify_multi_bad_param)
if (compression_style != "atom/gz") GTEST_SKIP();
BEGIN_HIDE_OUTPUT();
command(fmt::format("dump id1 all {} 1 {}", compression_style, compressed_dump_filename("modify_multi_bad_param_run0_*.melt")));
command(fmt::format("dump id1 all {} 1 {}", compression_style,
compressed_dump_filename("modify_multi_bad_param_run0_*.melt")));
END_HIDE_OUTPUT();
TEST_FAILURE(".*ERROR on proc 0: Illegal dump_modify command: Compression level must in the range of.*",
command("dump_modify id1 pad 3 compression_level 12");
);
TEST_FAILURE(
".*ERROR on proc 0: Illegal dump_modify command: Compression level must in the range of.*",
command("dump_modify id1 pad 3 compression_level 12"););
}
TEST_F(DumpAtomCompressTest, compressed_modify_clevel_run0)
@ -398,7 +400,8 @@ TEST_F(DumpAtomCompressTest, compressed_modify_clevel_run0)
auto text_file = text_dump_filename(base_name);
auto compressed_file = compressed_dump_filename(base_name);
generate_text_and_compressed_dump(text_file, compressed_file, "", "", "", "compression_level 3", 0);
generate_text_and_compressed_dump(text_file, compressed_file, "", "", "", "compression_level 3",
0);
TearDown();

View File

@ -97,7 +97,8 @@ TEST_F(DumpCfgTest, write_dump)
ASSERT_THAT(lines[0], Eq("Number of particles = 32"));
delete_file("dump_cfg0.melt.cfg");
TEST_FAILURE(".*ERROR: Unrecognized dump style 'xxx'.*", command("write_dump all xxx test.xxx"););
TEST_FAILURE(".*ERROR: Unrecognized dump style 'xxx'.*",
command("write_dump all xxx test.xxx"););
}
TEST_F(DumpCfgTest, unwrap_run0)

View File

@ -20,13 +20,11 @@
#include <string>
using ::testing::Eq;
class DumpCfgCompressTest : public CompressedDumpTest {
public:
DumpCfgCompressTest() : CompressedDumpTest("cfg") {
}
DumpCfgCompressTest() : CompressedDumpTest("cfg") {}
};
//-------------------------------------------------------------------------------------------------
@ -47,7 +45,8 @@ TEST_F(DumpCfgCompressTest, compressed_run0)
auto fields = "mass type xs ys zs id proc procp1 x y z ix iy iz vx vy vz fx fy fz";
if (compression_style == "cfg/zstd") {
generate_text_and_compressed_dump(text_files, compressed_files, fields, fields, "", "checksum yes", 0);
generate_text_and_compressed_dump(text_files, compressed_files, fields, fields, "",
"checksum yes", 0);
} else {
generate_text_and_compressed_dump(text_files, compressed_files, fields, "", 0);
}
@ -80,7 +79,8 @@ TEST_F(DumpCfgCompressTest, compressed_no_buffer_run0)
auto fields = "mass type xs ys zs id proc procp1 x y z ix iy iz vx vy vz fx fy fz";
if (compression_style == "cfg/zstd") {
generate_text_and_compressed_dump(text_files, compressed_files, fields, fields, "buffer no", "buffer no", 0);
generate_text_and_compressed_dump(text_files, compressed_files, fields, fields, "buffer no",
"buffer no", 0);
} else {
generate_text_and_compressed_dump(text_files, compressed_files, fields, "buffer no", 0);
}
@ -144,7 +144,8 @@ TEST_F(DumpCfgCompressTest, compressed_multi_file_run1)
auto fields = "mass type xs ys zs id proc procp1 x y z ix iy iz vx vy vz fx fy fz";
if (compression_style == "cfg/zstd") {
generate_text_and_compressed_dump(text_file, compressed_file, fields, fields, "", "checksum no", 1);
generate_text_and_compressed_dump(text_file, compressed_file, fields, fields, "",
"checksum no", 1);
} else {
generate_text_and_compressed_dump(text_file, compressed_file, fields, "", 1);
}
@ -264,12 +265,13 @@ TEST_F(DumpCfgCompressTest, compressed_modify_bad_param)
auto fields = "mass type xs ys zs id proc procp1 x y z ix iy iz vx vy vz fx fy fz";
BEGIN_HIDE_OUTPUT();
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_dump_filename("modify_bad_param_run0_*.melt.cfg"), fields));
command(fmt::format("dump id1 all {} 1 {} {}", compression_style,
compressed_dump_filename("modify_bad_param_run0_*.melt.cfg"), fields));
END_HIDE_OUTPUT();
TEST_FAILURE(".*ERROR on proc 0: Illegal dump_modify command: Compression level must in the range of.*",
command("dump_modify id1 compression_level 12");
);
TEST_FAILURE(
".*ERROR on proc 0: Illegal dump_modify command: Compression level must in the range of.*",
command("dump_modify id1 compression_level 12"););
}
TEST_F(DumpCfgCompressTest, compressed_modify_multi_bad_param)
@ -278,12 +280,14 @@ TEST_F(DumpCfgCompressTest, compressed_modify_multi_bad_param)
auto fields = "mass type xs ys zs id proc procp1 x y z ix iy iz vx vy vz fx fy fz";
BEGIN_HIDE_OUTPUT();
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_dump_filename("modify_multi_bad_param_run0_*.melt.cfg"), fields));
command(fmt::format("dump id1 all {} 1 {} {}", compression_style,
compressed_dump_filename("modify_multi_bad_param_run0_*.melt.cfg"),
fields));
END_HIDE_OUTPUT();
TEST_FAILURE(".*ERROR on proc 0: Illegal dump_modify command: Compression level must in the range of.*",
command("dump_modify id1 pad 3 compression_level 12");
);
TEST_FAILURE(
".*ERROR on proc 0: Illegal dump_modify command: Compression level must in the range of.*",
command("dump_modify id1 pad 3 compression_level 12"););
}
TEST_F(DumpCfgCompressTest, compressed_modify_clevel_run0)
@ -298,7 +302,8 @@ TEST_F(DumpCfgCompressTest, compressed_modify_clevel_run0)
auto compressed_file_0 = compressed_dump_filename(base_name_0);
auto fields = "mass type xs ys zs id proc procp1 x y z ix iy iz vx vy vz fx fy fz";
generate_text_and_compressed_dump(text_file, compressed_file, fields, fields, "", "compression_level 3", 0);
generate_text_and_compressed_dump(text_file, compressed_file, fields, fields, "",
"compression_level 3", 0);
TearDown();

View File

@ -20,13 +20,11 @@
#include <string>
using ::testing::Eq;
class DumpCustomCompressTest : public CompressedDumpTest {
public:
DumpCustomCompressTest() : CompressedDumpTest("custom") {
}
DumpCustomCompressTest() : CompressedDumpTest("custom") {}
};
TEST_F(DumpCustomCompressTest, compressed_run1)
@ -39,7 +37,8 @@ TEST_F(DumpCustomCompressTest, compressed_run1)
auto fields = "id type proc x y z ix iy iz xs ys zs xu yu zu xsu ysu zsu vx vy vz fx fy fz";
if (compression_style == "custom/zstd") {
generate_text_and_compressed_dump(text_file, compressed_file, fields, fields, "units yes", "units yes checksum yes", 1);
generate_text_and_compressed_dump(text_file, compressed_file, fields, fields, "units yes",
"units yes checksum yes", 1);
} else {
generate_text_and_compressed_dump(text_file, compressed_file, fields, "units yes", 1);
}
@ -68,7 +67,8 @@ TEST_F(DumpCustomCompressTest, compressed_with_time_run1)
auto fields = "id type proc x y z ix iy iz xs ys zs xu yu zu xsu ysu zsu vx vy vz fx fy fz";
if (compression_style == "custom/zstd") {
generate_text_and_compressed_dump(text_file, compressed_file, fields, fields, "time yes", "time yes checksum yes", 1);
generate_text_and_compressed_dump(text_file, compressed_file, fields, fields, "time yes",
"time yes checksum yes", 1);
} else {
generate_text_and_compressed_dump(text_file, compressed_file, fields, "time yes", 1);
}
@ -97,7 +97,8 @@ TEST_F(DumpCustomCompressTest, compressed_no_buffer_run1)
auto fields = "id type proc x y z ix iy iz xs ys zs xu yu zu xsu ysu zsu vx vy vz fx fy fz";
if (compression_style == "custom/zstd") {
generate_text_and_compressed_dump(text_file, compressed_file, fields, fields, "buffer no", "buffer no checksum yes", 1);
generate_text_and_compressed_dump(text_file, compressed_file, fields, fields, "buffer no",
"buffer no checksum yes", 1);
} else {
generate_text_and_compressed_dump(text_file, compressed_file, fields, "buffer no", 1);
}
@ -159,7 +160,8 @@ TEST_F(DumpCustomCompressTest, compressed_multi_file_run1)
auto fields = "id type proc x y z ix iy iz xs ys zs xu yu zu xsu ysu zsu vx vy vz fx fy fz";
if (compression_style == "custom/zstd") {
generate_text_and_compressed_dump(text_file, compressed_file, fields, fields, "", "checksum no", 1);
generate_text_and_compressed_dump(text_file, compressed_file, fields, fields, "",
"checksum no", 1);
} else {
generate_text_and_compressed_dump(text_file, compressed_file, fields, "", 1);
}
@ -278,11 +280,12 @@ TEST_F(DumpCustomCompressTest, compressed_modify_bad_param)
if (compression_style != "custom/gz") GTEST_SKIP();
auto fields = "id type proc x y z ix iy iz xs ys zs xu yu zu xsu ysu zsu vx vy vz fx fy fz";
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_dump_filename("modify_bad_param_run0_*.melt.custom"), fields));
command(fmt::format("dump id1 all {} 1 {} {}", compression_style,
compressed_dump_filename("modify_bad_param_run0_*.melt.custom"), fields));
TEST_FAILURE(".*ERROR on proc 0: Illegal dump_modify command: Compression level must in the range of.*",
command("dump_modify id1 compression_level 12");
);
TEST_FAILURE(
".*ERROR on proc 0: Illegal dump_modify command: Compression level must in the range of.*",
command("dump_modify id1 compression_level 12"););
}
TEST_F(DumpCustomCompressTest, compressed_modify_multi_bad_param)
@ -290,11 +293,13 @@ TEST_F(DumpCustomCompressTest, compressed_modify_multi_bad_param)
if (compression_style != "custom/gz") GTEST_SKIP();
auto fields = "id type proc x y z ix iy iz xs ys zs xu yu zu xsu ysu zsu vx vy vz fx fy fz";
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_dump_filename("modify_multi_bad_param_run0_*.melt.custom"), fields));
command(fmt::format("dump id1 all {} 1 {} {}", compression_style,
compressed_dump_filename("modify_multi_bad_param_run0_*.melt.custom"),
fields));
TEST_FAILURE(".*ERROR on proc 0: Illegal dump_modify command: Compression level must in the range of.*",
command("dump_modify id1 pad 3 compression_level 12");
);
TEST_FAILURE(
".*ERROR on proc 0: Illegal dump_modify command: Compression level must in the range of.*",
command("dump_modify id1 pad 3 compression_level 12"););
}
TEST_F(DumpCustomCompressTest, compressed_modify_clevel_run0)
@ -306,7 +311,8 @@ TEST_F(DumpCustomCompressTest, compressed_modify_clevel_run0)
auto compressed_file = compressed_dump_filename(base_name);
auto fields = "id type proc x y z ix iy iz xs ys zs xu yu zu xsu ysu zsu vx vy vz fx fy fz";
generate_text_and_compressed_dump(text_file, compressed_file, fields, fields, "", "compression_level 3", 0);
generate_text_and_compressed_dump(text_file, compressed_file, fields, fields, "",
"compression_level 3", 0);
TearDown();

View File

@ -39,7 +39,8 @@ public:
END_HIDE_OUTPUT();
}
void generate_dump(std::string dump_file, std::string dump_options, std::string dump_modify_options, int ntimesteps)
void generate_dump(std::string dump_file, std::string dump_options,
std::string dump_modify_options, int ntimesteps)
{
BEGIN_HIDE_OUTPUT();
command(fmt::format("dump id all {} 1 {} {}", dump_style, dump_file, dump_options));
@ -59,7 +60,8 @@ public:
END_HIDE_OUTPUT();
}
void SetUp() override {
void SetUp() override
{
MeltTest::SetUp();
BEGIN_HIDE_OUTPUT();

View File

@ -20,15 +20,14 @@
#include <string>
using ::testing::Eq;
class DumpLocalCompressTest : public CompressedDumpTest {
public:
DumpLocalCompressTest() : CompressedDumpTest("local") {
}
DumpLocalCompressTest() : CompressedDumpTest("local") {}
void SetUp() override {
void SetUp() override
{
CompressedDumpTest::SetUp();
BEGIN_HIDE_OUTPUT();
@ -50,7 +49,8 @@ TEST_F(DumpLocalCompressTest, compressed_run0)
auto fields = "index c_comp[1]";
if (compression_style == "local/zstd") {
generate_text_and_compressed_dump(text_files, compressed_files, fields, fields, "", "checksum yes", 0);
generate_text_and_compressed_dump(text_files, compressed_files, fields, fields, "",
"checksum yes", 0);
} else {
generate_text_and_compressed_dump(text_files, compressed_files, fields, "", 0);
}
@ -82,7 +82,8 @@ TEST_F(DumpLocalCompressTest, compressed_no_buffer_run0)
auto fields = "index c_comp[1]";
if (compression_style == "local/zstd") {
generate_text_and_compressed_dump(text_files, compressed_files, fields, fields, "buffer no", "buffer no checksum yes", 0);
generate_text_and_compressed_dump(text_files, compressed_files, fields, fields, "buffer no",
"buffer no checksum yes", 0);
} else {
generate_text_and_compressed_dump(text_files, compressed_files, fields, "buffer no", 0);
}
@ -114,7 +115,8 @@ TEST_F(DumpLocalCompressTest, compressed_with_time_run0)
auto fields = "index c_comp[1]";
if (compression_style == "local/zstd") {
generate_text_and_compressed_dump(text_files, compressed_files, fields, fields, "time yes", "time yes checksum yes", 0);
generate_text_and_compressed_dump(text_files, compressed_files, fields, fields, "time yes",
"time yes checksum yes", 0);
} else {
generate_text_and_compressed_dump(text_files, compressed_files, fields, "time yes", 0);
}
@ -146,7 +148,8 @@ TEST_F(DumpLocalCompressTest, compressed_with_units_run0)
auto fields = "index c_comp[1]";
if (compression_style == "local/zstd") {
generate_text_and_compressed_dump(text_files, compressed_files, fields, fields, "units yes", "units yes checksum yes", 0);
generate_text_and_compressed_dump(text_files, compressed_files, fields, fields, "units yes",
"units yes checksum yes", 0);
} else {
generate_text_and_compressed_dump(text_files, compressed_files, fields, "units yes", 0);
}
@ -179,7 +182,8 @@ TEST_F(DumpLocalCompressTest, compressed_triclinic_run0)
auto fields = "index c_comp[1]";
if (compression_style == "local/zstd") {
generate_text_and_compressed_dump(text_files, compressed_files, fields, fields, "", "checksum yes", 0);
generate_text_and_compressed_dump(text_files, compressed_files, fields, fields, "",
"checksum yes", 0);
} else {
generate_text_and_compressed_dump(text_files, compressed_files, fields, "", 0);
}
@ -214,7 +218,8 @@ TEST_F(DumpLocalCompressTest, compressed_multi_file_run1)
auto fields = "index c_comp[1]";
if (compression_style == "local/zstd") {
generate_text_and_compressed_dump(text_file, compressed_file, fields, fields, "", "checksum no", 1);
generate_text_and_compressed_dump(text_file, compressed_file, fields, fields, "",
"checksum no", 1);
} else {
generate_text_and_compressed_dump(text_file, compressed_file, fields, "", 1);
}
@ -335,12 +340,13 @@ TEST_F(DumpLocalCompressTest, compressed_modify_bad_param)
auto fields = "index c_comp[1]";
BEGIN_HIDE_OUTPUT();
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_dump_filename("modify_bad_param_run0_*.melt.local"), fields));
command(fmt::format("dump id1 all {} 1 {} {}", compression_style,
compressed_dump_filename("modify_bad_param_run0_*.melt.local"), fields));
END_HIDE_OUTPUT();
TEST_FAILURE(".*ERROR on proc 0: Illegal dump_modify command: Compression level must in the range of.*",
command("dump_modify id1 compression_level 12");
);
TEST_FAILURE(
".*ERROR on proc 0: Illegal dump_modify command: Compression level must in the range of.*",
command("dump_modify id1 compression_level 12"););
}
TEST_F(DumpLocalCompressTest, compressed_modify_multi_bad_param)
@ -350,12 +356,14 @@ TEST_F(DumpLocalCompressTest, compressed_modify_multi_bad_param)
auto fields = "index c_comp[1]";
BEGIN_HIDE_OUTPUT();
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_dump_filename("modify_multi_bad_param_run0_*.melt.local"), fields));
command(fmt::format("dump id1 all {} 1 {} {}", compression_style,
compressed_dump_filename("modify_multi_bad_param_run0_*.melt.local"),
fields));
END_HIDE_OUTPUT();
TEST_FAILURE(".*ERROR on proc 0: Illegal dump_modify command: Compression level must in the range of.*",
command("dump_modify id1 pad 3 compression_level 12");
);
TEST_FAILURE(
".*ERROR on proc 0: Illegal dump_modify command: Compression level must in the range of.*",
command("dump_modify id1 pad 3 compression_level 12"););
}
TEST_F(DumpLocalCompressTest, compressed_modify_clevel_run0)
@ -367,7 +375,8 @@ TEST_F(DumpLocalCompressTest, compressed_modify_clevel_run0)
auto compressed_file = compressed_dump_filename(base_name);
auto fields = "index c_comp[1]";
generate_text_and_compressed_dump(text_file, compressed_file, fields, fields, "", "compression_level 3", 0);
generate_text_and_compressed_dump(text_file, compressed_file, fields, fields, "",
"compression_level 3", 0);
TearDown();

View File

@ -20,13 +20,11 @@
#include <string>
using ::testing::Eq;
class DumpXYZCompressTest : public CompressedDumpTest {
public:
DumpXYZCompressTest() : CompressedDumpTest("xyz") {
}
DumpXYZCompressTest() : CompressedDumpTest("xyz") {}
};
TEST_F(DumpXYZCompressTest, compressed_run0)
@ -41,7 +39,8 @@ TEST_F(DumpXYZCompressTest, compressed_run0)
auto compressed_file_0 = compressed_dump_filename(base_name_0);
if (compression_style == "xyz/zstd") {
generate_text_and_compressed_dump(text_files, compressed_files, "", "", "", "checksum yes", 0);
generate_text_and_compressed_dump(text_files, compressed_files, "", "", "", "checksum yes",
0);
} else {
generate_text_and_compressed_dump(text_files, compressed_files, "", "", 0);
}
@ -72,7 +71,8 @@ TEST_F(DumpXYZCompressTest, compressed_no_buffer_run0)
auto compressed_file_0 = compressed_dump_filename(base_name_0);
if (compression_style == "xyz/zstd") {
generate_text_and_compressed_dump(text_files, compressed_files, "", "", "buffer no", "buffer no", 0);
generate_text_and_compressed_dump(text_files, compressed_files, "", "", "buffer no",
"buffer no", 0);
} else {
generate_text_and_compressed_dump(text_files, compressed_files, "", "buffer no", 0);
}
@ -223,12 +223,13 @@ TEST_F(DumpXYZCompressTest, compressed_modify_bad_param)
if (compression_style != "xyz/gz") GTEST_SKIP();
BEGIN_HIDE_OUTPUT();
command(fmt::format("dump id1 all {} 1 {}", compression_style, compressed_dump_filename("modify_bad_param_run0_*.melt.xyz")));
command(fmt::format("dump id1 all {} 1 {}", compression_style,
compressed_dump_filename("modify_bad_param_run0_*.melt.xyz")));
END_HIDE_OUTPUT();
TEST_FAILURE(".*ERROR on proc 0: Illegal dump_modify command: Compression level must in the range of.*",
command("dump_modify id1 compression_level 12");
);
TEST_FAILURE(
".*ERROR on proc 0: Illegal dump_modify command: Compression level must in the range of.*",
command("dump_modify id1 compression_level 12"););
}
TEST_F(DumpXYZCompressTest, compressed_modify_multi_bad_param)
@ -236,12 +237,13 @@ TEST_F(DumpXYZCompressTest, compressed_modify_multi_bad_param)
if (compression_style != "xyz/gz") GTEST_SKIP();
BEGIN_HIDE_OUTPUT();
command(fmt::format("dump id1 all {} 1 {}", compression_style, compressed_dump_filename("modify_multi_bad_param_run0_*.melt.xyz")));
command(fmt::format("dump id1 all {} 1 {}", compression_style,
compressed_dump_filename("modify_multi_bad_param_run0_*.melt.xyz")));
END_HIDE_OUTPUT();
TEST_FAILURE(".*ERROR on proc 0: Illegal dump_modify command: Compression level must in the range of.*",
command("dump_modify id1 pad 3 compression_level 12");
);
TEST_FAILURE(
".*ERROR on proc 0: Illegal dump_modify command: Compression level must in the range of.*",
command("dump_modify id1 pad 3 compression_level 12"););
}
TEST_F(DumpXYZCompressTest, compressed_modify_clevel_run0)
@ -252,7 +254,8 @@ TEST_F(DumpXYZCompressTest, compressed_modify_clevel_run0)
auto text_file = text_dump_filename(base_name);
auto compressed_file = compressed_dump_filename(base_name);
generate_text_and_compressed_dump(text_file, compressed_file, "", "", "", "compression_level 3", 0);
generate_text_and_compressed_dump(text_file, compressed_file, "", "", "", "compression_level 3",
0);
TearDown();

View File

@ -11,6 +11,7 @@
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#include "../testing/core.h"
#include "MANYBODY/pair_eim.h"
#include "info.h"
#include "input.h"
@ -18,7 +19,6 @@
#include "utils.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "../testing/core.h"
#include <cstring>
#include <mpi.h>

View File

@ -60,9 +60,11 @@ protected:
"##################################################################"
"############################################################\n";
out << "one line\ntwo_lines\n\n";
for (int i = 0; i < 100; ++i) out << "one two ";
for (int i = 0; i < 100; ++i)
out << "one two ";
out << "\nthree\nfour five #";
for (int i = 0; i < 1000; ++i) out << '#';
for (int i = 0; i < 1000; ++i)
out << '#';
out.close();
}
@ -286,8 +288,7 @@ TEST_F(FileOperationsTest, error_all_one)
command("echo none");
command("log none");
END_HIDE_OUTPUT();
TEST_FAILURE(".*ERROR: exit \\(testme.cpp:10\\).*",
lmp->error->all("testme.cpp", 10, "exit"););
TEST_FAILURE(".*ERROR: exit \\(testme.cpp:10\\).*", lmp->error->all("testme.cpp", 10, "exit"););
TEST_FAILURE(".*ERROR: exit too \\(testme.cpp:10\\).*",
lmp->error->all("testme.cpp", 10, "exit {}", "too"););
TEST_FAILURE(".*ERROR: argument not found \\(testme.cpp:10\\).*",

View File

@ -11,11 +11,11 @@
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#include "../testing/core.h"
#include "atom.h"
#include "input.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "../testing/core.h"
#include <cmath>
#include <cstring>

View File

@ -11,6 +11,7 @@
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#include "../testing/core.h"
#include "atom.h"
#include "info.h"
#include "input.h"
@ -19,7 +20,6 @@
#include "utils.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "../testing/core.h"
#include <cstdio>
#include <mpi.h>
@ -34,7 +34,6 @@ using utils::split_words;
#define test_name test_info_->name()
static void create_molecule_files(const std::string &h2o_filename, const std::string &co2_filename)
{
// create molecule files
@ -77,11 +76,10 @@ bool verbose = false;
class MoleculeFileTest : public LAMMPSTest {
protected:
static void SetUpTestSuite() {
create_molecule_files("moltest.h2o.mol", "moltest.co2.mol");
}
static void SetUpTestSuite() { create_molecule_files("moltest.h2o.mol", "moltest.co2.mol"); }
static void TearDownTestSuite() {
static void TearDownTestSuite()
{
remove("moltest.h2o.mol");
remove("moltest.co2.mol");
}
@ -93,10 +91,7 @@ protected:
ASSERT_NE(lmp, nullptr);
}
void TearDown() override
{
LAMMPSTest::TearDown();
}
void TearDown() override { LAMMPSTest::TearDown(); }
void run_mol_cmd(const std::string &name, const std::string &args, const std::string &content)
{

View File

@ -11,6 +11,7 @@
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#include "../testing/core.h"
#include "atom.h"
#include "force.h"
#include "info.h"
@ -20,7 +21,6 @@
#include "thermo.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "../testing/core.h"
#include <cmath>
#include <cstring>

View File

@ -20,9 +20,9 @@
#include "MANYBODY/pair_tersoff.h"
#include "MANYBODY/pair_tersoff_mod.h"
#include "MANYBODY/pair_tersoff_mod_c.h"
#include "MANYBODY/pair_tersoff_table.h"
#include "MANYBODY/pair_tersoff_zbl.h"
#include "MANYBODY/pair_vashishta.h"
#include "MANYBODY/pair_tersoff_table.h"
#include "info.h"
#include "input.h"
#include "potential_file_reader.h"

View File

@ -78,8 +78,7 @@ TEST_F(TextFileReaderTest, permissions)
TEST_F(TextFileReaderTest, nofp)
{
ASSERT_THROW({ TextFileReader reader(nullptr, "test"); },
FileReaderException);
ASSERT_THROW({ TextFileReader reader(nullptr, "test"); }, FileReaderException);
}
TEST_F(TextFileReaderTest, usefp)

View File

@ -14,15 +14,15 @@
#include "atom.h"
#include "info.h"
#include "input.h"
#include "variable.h"
#include "library.h"
#include "variable.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include <cmath>
#include <cstring>
#include <vector>
#include <functional>
#include <vector>
#include "../testing/core.h"
#include "../testing/systems/melt.h"
@ -32,16 +32,17 @@
#define XSTR(val) #val
std::string INPUT_FOLDER = STRINGIFY(TEST_INPUT_FOLDER);
const char * LOREM_IPSUM = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent metus.";
const char *LOREM_IPSUM =
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent metus.";
bool verbose = false;
using LAMMPS_NS::utils::split_words;
namespace LAMMPS_NS {
using ::testing::MatchesRegex;
using ::testing::StrEq;
using ::testing::Eq;
using ::testing::HasSubstr;
using ::testing::MatchesRegex;
using ::testing::StrEq;
class PythonPackageTest : public LAMMPSTest {
protected:
@ -115,7 +116,8 @@ TEST_F(PythonPackageTest, InvokeFunctionPassString)
// execute python function, passing string as argument
HIDE_OUTPUT([&] {
command("variable val python bool_to_val");
command("python bool_to_val input 1 \"true\" format sf return v_val file ${input_dir}/func.py");
command(
"python bool_to_val input 1 \"true\" format sf return v_val file ${input_dir}/func.py");
});
ASSERT_EQ(get_variable_value("val"), 1.0);
@ -126,7 +128,8 @@ TEST_F(PythonPackageTest, InvokeFunctionPassStringVariable)
// execute python function, passing string variable as argument
HIDE_OUTPUT([&] {
command("variable val python bool_to_val");
command("python bool_to_val input 1 v_str format sf return v_val file ${input_dir}/func.py");
command(
"python bool_to_val input 1 v_str format sf return v_val file ${input_dir}/func.py");
});
HIDE_OUTPUT([&] {
@ -147,7 +150,8 @@ TEST_F(PythonPackageTest, InvokeStringFunction)
// execute python function, passing string variable as argument
HIDE_OUTPUT([&] {
command("variable str python val_to_bool");
command("python val_to_bool input 1 v_val format is return v_str file ${input_dir}/func.py");
command(
"python val_to_bool input 1 v_val format is return v_str file ${input_dir}/func.py");
});
HIDE_OUTPUT([&] {
@ -264,8 +268,7 @@ TEST_F(PythonPackageTest, RunSourceInline)
command("python xyz source \"\"\"\n"
"from __future__ import print_function\n"
"print(2+2)\n"
"\"\"\""
);
"\"\"\"");
});
ASSERT_THAT(output, HasSubstr("4"));

View File

@ -13,17 +13,17 @@
#ifndef TESTING_CORE__H
#define TESTING_CORE__H
#include "exceptions.h"
#include "info.h"
#include "input.h"
#include "lammps.h"
#include "variable.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "exceptions.h"
#include <functional>
#include <vector>
#include <string>
#include <vector>
using namespace LAMMPS_NS;
@ -41,8 +41,7 @@ using ::testing::MatchesRegex;
ASSERT_DEATH({__VA_ARGS__}, ""); \
auto mesg = ::testing::internal::GetCapturedStdout(); \
ASSERT_THAT(mesg, MatchesRegex(errmsg)); \
} \
else { \
} else { \
std::cerr << "[ ] [ INFO ] Skipping death test (no exception support) \n"; \
} \
}
@ -54,25 +53,27 @@ class LAMMPSTest : public ::testing::Test {
public:
void command(const std::string &line) { lmp->input->one(line.c_str()); }
void BEGIN_HIDE_OUTPUT() {
void BEGIN_HIDE_OUTPUT()
{
if (!verbose) ::testing::internal::CaptureStdout();
}
void END_HIDE_OUTPUT() {
void END_HIDE_OUTPUT()
{
if (!verbose) ::testing::internal::GetCapturedStdout();
}
void BEGIN_CAPTURE_OUTPUT() {
::testing::internal::CaptureStdout();
}
void BEGIN_CAPTURE_OUTPUT() { ::testing::internal::CaptureStdout(); }
std::string END_CAPTURE_OUTPUT() {
std::string END_CAPTURE_OUTPUT()
{
auto output = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << output;
return output;
}
void HIDE_OUTPUT(std::function<void()> f) {
void HIDE_OUTPUT(std::function<void()> f)
{
if (!verbose) ::testing::internal::CaptureStdout();
try {
f();
@ -83,7 +84,8 @@ public:
if (!verbose) ::testing::internal::GetCapturedStdout();
}
std::string CAPTURE_OUTPUT(std::function<void()> f) {
std::string CAPTURE_OUTPUT(std::function<void()> f)
{
::testing::internal::CaptureStdout();
try {
f();
@ -96,14 +98,16 @@ public:
return output;
}
double get_variable_value(const std::string & name) {
double get_variable_value(const std::string &name)
{
char *str = utils::strdup(fmt::format("v_{}", name));
double value = lmp->input->variable->compute_equal(str);
delete[] str;
return value;
}
std::string get_variable_string(const std::string & name) {
std::string get_variable_string(const std::string &name)
{
return lmp->input->variable->retrieve(name.c_str());
}

View File

@ -16,12 +16,12 @@
#include <deque>
#include <mpi.h>
using ::testing::TestEventListener;
using ::testing::TestCase;
using ::testing::TestEventListener;
using ::testing::TestInfo;
using ::testing::TestPartResult;
using ::testing::TestSuite;
using ::testing::UnitTest;
using ::testing::TestPartResult;
using ::testing::TestInfo;
class MPIPrinter : public TestEventListener {
MPI_Comm comm;
@ -32,8 +32,10 @@ class MPIPrinter : public TestEventListener {
size_t buffer_size;
std::deque<TestPartResult> results;
bool finalize_test;
public:
MPIPrinter(TestEventListener * default_listener) : default_listener(default_listener) {
MPIPrinter(TestEventListener *default_listener) : default_listener(default_listener)
{
comm = MPI_COMM_WORLD;
MPI_Comm_rank(comm, &me);
MPI_Comm_size(comm, &nprocs);
@ -42,7 +44,8 @@ public:
finalize_test = false;
}
~MPIPrinter() override {
~MPIPrinter() override
{
delete default_listener;
default_listener = nullptr;
@ -51,43 +54,49 @@ public:
buffer_size = 0;
}
virtual void OnTestProgramStart(const UnitTest& unit_test) override {
virtual void OnTestProgramStart(const UnitTest &unit_test) override
{
if (me == 0) default_listener->OnTestProgramStart(unit_test);
}
virtual void OnTestIterationStart(const UnitTest& unit_test, int iteration) override {
virtual void OnTestIterationStart(const UnitTest &unit_test, int iteration) override
{
if (me == 0) default_listener->OnTestIterationStart(unit_test, iteration);
}
virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test) override {
virtual void OnEnvironmentsSetUpStart(const UnitTest &unit_test) override
{
if (me == 0) default_listener->OnEnvironmentsSetUpStart(unit_test);
}
virtual void OnEnvironmentsSetUpEnd(const UnitTest& unit_test) override {
virtual void OnEnvironmentsSetUpEnd(const UnitTest &unit_test) override
{
if (me == 0) default_listener->OnEnvironmentsSetUpEnd(unit_test);
}
virtual void OnTestSuiteStart(const TestSuite& test_suite) override {
virtual void OnTestSuiteStart(const TestSuite &test_suite) override
{
if (me == 0) default_listener->OnTestSuiteStart(test_suite);
}
// Legacy API is deprecated but still available
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
virtual void OnTestCaseStart(const TestCase& test_case) override {
virtual void OnTestCaseStart(const TestCase &test_case) override
{
if (me == 0) default_listener->OnTestSuiteStart(test_case);
}
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
virtual void OnTestStart(const TestInfo& test_info) override {
virtual void OnTestStart(const TestInfo &test_info) override
{
// Called before a test starts.
if (me == 0) default_listener->OnTestStart(test_info);
results.clear();
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().
// test_part_result()
@ -102,11 +111,14 @@ public:
proc_message << "[Rank " << me << "] " << line << std::endl;
}
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.
MPI_Barrier(comm);
@ -178,7 +190,8 @@ public:
message = std::string(buffer);
}
results.push_back(TestPartResult((TestPartResult::Type)type, file_name.c_str(), lineno, message.c_str()));
results.push_back(TestPartResult((TestPartResult::Type)type, file_name.c_str(),
lineno, message.c_str()));
}
}
@ -200,29 +213,35 @@ public:
}
}
virtual void OnTestSuiteEnd(const TestSuite& test_suite) override {
virtual void OnTestSuiteEnd(const TestSuite &test_suite) override
{
if (me == 0) default_listener->OnTestSuiteEnd(test_suite);
}
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
virtual void OnTestCaseEnd(const TestCase& test_case) override {
virtual void OnTestCaseEnd(const TestCase &test_case) override
{
if (me == 0) default_listener->OnTestCaseEnd(test_case);
}
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test) override {
virtual void OnEnvironmentsTearDownStart(const UnitTest &unit_test) override
{
if (me == 0) default_listener->OnEnvironmentsTearDownStart(unit_test);
}
virtual void OnEnvironmentsTearDownEnd(const UnitTest& unit_test) override {
virtual void OnEnvironmentsTearDownEnd(const UnitTest &unit_test) override
{
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);
}
virtual void OnTestProgramEnd(const UnitTest& unit_test) override {
virtual void OnTestProgramEnd(const UnitTest &unit_test) override
{
if (me == 0) default_listener->OnTestProgramEnd(unit_test);
}
};

View File

@ -11,10 +11,10 @@
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#include "mpitesting.h"
#include "utils.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "mpitesting.h"
#include <iostream>
#include <mpi.h>

View File

@ -71,6 +71,4 @@ static bool file_exists(const std::string &filename)
#define ASSERT_FILE_NOT_EXISTS(NAME) ASSERT_FALSE(file_exists(NAME))
#define ASSERT_FILE_EQUAL(FILE_A, FILE_B) ASSERT_TRUE(equal_lines(FILE_A, FILE_B))
#endif