Refactoring of more tests

This commit is contained in:
Richard Berger
2021-03-29 14:27:42 -04:00
parent 1752bd0276
commit aaf9aa6d69
19 changed files with 627 additions and 847 deletions

View File

@ -45,14 +45,14 @@ public:
void enable_triclinic()
{
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("change_box all triclinic");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
}
void generate_dump(std::string dump_file, std::string dump_modify_options, int ntimesteps)
{
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command(fmt::format("dump id all {} 1 {}", dump_style, dump_file));
if (!dump_modify_options.empty()) {
@ -60,7 +60,7 @@ public:
}
command(fmt::format("run {}", ntimesteps));
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
}
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file,
@ -76,7 +76,7 @@ public:
std::string text_modify_options, std::string compressed_modify_options,
int ntimesteps)
{
if (!verbose) ::testing::internal::CaptureStdout();
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));
@ -89,17 +89,17 @@ public:
}
command(fmt::format("run {}", ntimesteps));
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
}
std::string convert_compressed_to_text(std::string compressed_file)
{
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
std::string converted_file = compressed_file.substr(0, compressed_file.find_last_of('.'));
std::string cmdline =
fmt::format("{} -d -c {} > {}", COMPRESS_BINARY, compressed_file, converted_file);
system(cmdline.c_str());
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
return converted_file;
}
};

File diff suppressed because it is too large Load Diff

View File

@ -32,14 +32,14 @@ class DumpAtomTest : public MeltTest {
public:
void enable_triclinic()
{
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("change_box all triclinic");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
}
void generate_dump(std::string dump_file, std::string dump_modify_options, int ntimesteps)
{
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command(fmt::format("dump id all {} 1 {}", dump_style, dump_file));
if (!dump_modify_options.empty()) {
@ -47,13 +47,13 @@ public:
}
command(fmt::format("run {}", ntimesteps));
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
}
void generate_text_and_binary_dump(std::string text_file, std::string binary_file,
std::string dump_modify_options, int ntimesteps)
{
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command(fmt::format("dump id0 all {} 1 {}", dump_style, text_file));
command(fmt::format("dump id1 all {} 1 {}", dump_style, binary_file));
@ -63,15 +63,15 @@ public:
}
command(fmt::format("run {}", ntimesteps));
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
}
std::string convert_binary_to_text(std::string binary_file)
{
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
std::string cmdline = fmt::format("{} {}", BINARY2TXT_BINARY, binary_file);
system(cmdline.c_str());
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
return fmt::format("{}.txt", binary_file);
}
};
@ -504,27 +504,27 @@ TEST_F(DumpAtomTest, per_processor_multi_file_run1)
TEST_F(DumpAtomTest, dump_modify_scale_invalid)
{
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("dump id all atom 1 dump.txt");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
TEST_FAILURE(".*Illegal dump_modify command.*", command("dump_modify id scale true"););
}
TEST_F(DumpAtomTest, dump_modify_image_invalid)
{
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("dump id all atom 1 dump.txt");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
TEST_FAILURE(".*Illegal dump_modify command.*", command("dump_modify id image true"););
}
TEST_F(DumpAtomTest, dump_modify_invalid)
{
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("dump id all atom 1 dump.txt");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
TEST_FAILURE(".*Illegal dump_modify command.*", command("dump_modify id true"););
}
@ -534,12 +534,12 @@ TEST_F(DumpAtomTest, write_dump)
auto reference = "dump_ref_run0.melt";
auto dump_file = "write_dump_atom_run0.melt";
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command(fmt::format("dump id all atom 1 {}", reference));
command("dump_modify id scale no units yes");
command("run 0");
command("write_dump all atom write_dump_atom_run*.melt modify scale no units yes");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
ASSERT_FILE_EXISTS(reference);
ASSERT_FILE_EXISTS(dump_file);
@ -556,12 +556,12 @@ TEST_F(DumpAtomTest, binary_write_dump)
auto reference = "dump_run0.melt.bin";
auto dump_file = "write_dump_atom_run0_p0.melt.bin";
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command(fmt::format("dump id all atom 1 {}", reference));
command("dump_modify id scale no units yes");
command("run 0");
command("write_dump all atom write_dump_atom_run*_p%.melt.bin modify scale no units yes");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
ASSERT_FILE_EXISTS(reference);
ASSERT_FILE_EXISTS(dump_file);

View File

@ -340,9 +340,9 @@ TEST_F(DumpAtomCompressTest, compressed_modify_bad_param)
{
if (compression_style != "atom/gz") GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command(fmt::format("dump id1 all {} 1 {}", compression_style, compressed_dump_filename("modify_bad_param_run0_*.melt")));
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
TEST_FAILURE(".*ERROR: Illegal dump_modify command: compression level must in the range of.*",
command("dump_modify id1 compression_level 12");
@ -353,9 +353,9 @@ TEST_F(DumpAtomCompressTest, compressed_modify_multi_bad_param)
{
if (compression_style != "atom/gz") GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command(fmt::format("dump id1 all {} 1 {}", compression_style, compressed_dump_filename("modify_multi_bad_param_run0_*.melt")));
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
TEST_FAILURE(".*ERROR: Illegal dump_modify command: compression level must in the range of.*",
command("dump_modify id1 pad 3 compression_level 12");

View File

@ -30,7 +30,7 @@ public:
void generate_dump(std::string dump_file, std::string fields, std::string dump_modify_options,
int ntimesteps)
{
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command(fmt::format("dump id all {} 1 {} {}", dump_style, dump_file, fields));
if (!dump_modify_options.empty()) {
@ -38,7 +38,7 @@ public:
}
command(fmt::format("run {}", ntimesteps));
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
}
};
@ -54,9 +54,9 @@ TEST_F(DumpCfgTest, require_multifile)
auto fields =
"mass type xs ys zs id proc procp1 x y z ix iy iz xu yu zu xsu ysu zsu vx vy vz fx fy fz";
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command(fmt::format("dump id all cfg 1 {} {}", dump_file, fields));
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
TEST_FAILURE(".*Dump cfg requires one snapshot per file.*", command("run 0"););
}

View File

@ -230,9 +230,9 @@ TEST_F(DumpCfgCompressTest, compressed_modify_bad_param)
if (compression_style != "cfg/gz") GTEST_SKIP();
auto fields = "mass type xs ys zs id proc procp1 x y z ix iy iz vx vy vz fx fy fz";
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_dump_filename("modify_bad_param_run0_*.melt.cfg"), fields));
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
TEST_FAILURE(".*ERROR: Illegal dump_modify command: compression level must in the range of.*",
command("dump_modify id1 compression_level 12");
@ -244,9 +244,9 @@ TEST_F(DumpCfgCompressTest, compressed_modify_multi_bad_param)
if (compression_style != "cfg/gz") GTEST_SKIP();
auto fields = "mass type xs ys zs id proc procp1 x y z ix iy iz vx vy vz fx fy fz";
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_dump_filename("modify_multi_bad_param_run0_*.melt.cfg"), fields));
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
TEST_FAILURE(".*ERROR: Illegal dump_modify command: compression level must in the range of.*",
command("dump_modify id1 pad 3 compression_level 12");

View File

@ -30,15 +30,15 @@ class DumpCustomTest : public MeltTest {
public:
void enable_triclinic()
{
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("change_box all triclinic");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
}
void generate_dump(std::string dump_file, std::string fields, std::string dump_modify_options,
int ntimesteps)
{
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command(fmt::format("dump id all {} 1 {} {}", dump_style, dump_file, fields));
if (!dump_modify_options.empty()) {
@ -46,14 +46,14 @@ public:
}
command(fmt::format("run {}", ntimesteps));
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
}
void generate_text_and_binary_dump(std::string text_file, std::string binary_file,
std::string fields, std::string dump_modify_options,
int ntimesteps)
{
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command(fmt::format("dump id0 all {} 1 {} {}", dump_style, text_file, fields));
command(fmt::format("dump id1 all {} 1 {} {}", dump_style, binary_file, fields));
@ -63,15 +63,15 @@ public:
}
command(fmt::format("run {}", ntimesteps));
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
}
std::string convert_binary_to_text(std::string binary_file)
{
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
std::string cmdline = fmt::format("{} {}", BINARY2TXT_BINARY, binary_file);
system(cmdline.c_str());
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
return fmt::format("{}.txt", binary_file);
}
};
@ -113,9 +113,9 @@ TEST_F(DumpCustomTest, thresh_run0)
TEST_F(DumpCustomTest, compute_run0)
{
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("compute comp all property/atom x y z");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
auto dump_file = "dump_custom_compute_run0.melt";
auto fields = "id type x y z c_comp[1] c_comp[2] c_comp[3]";
@ -134,9 +134,9 @@ TEST_F(DumpCustomTest, compute_run0)
TEST_F(DumpCustomTest, fix_run0)
{
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("fix numdiff all numdiff 1 0.0001");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
auto dump_file = "dump_custom_compute_run0.melt";
auto fields = "id x y z f_numdiff[1] f_numdiff[2] f_numdiff[3]";
@ -155,10 +155,10 @@ TEST_F(DumpCustomTest, fix_run0)
TEST_F(DumpCustomTest, custom_run0)
{
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("fix prop all property/atom i_flag1 d_flag2");
command("compute 1 all property/atom i_flag1 d_flag2");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
auto dump_file = "dump_custom_custom_run0.melt";
auto fields = "id x y z i_flag1 d_flag2";
@ -242,10 +242,10 @@ TEST_F(DumpCustomTest, binary_triclinic_run1)
TEST_F(DumpCustomTest, with_variable_run1)
{
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("compute 1 all property/atom proc");
command("variable p atom (c_1%10)+1");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
auto dump_file = "dump_custom_with_variable_run1.melt";
auto fields = "id type x y z v_p";

View File

@ -31,9 +31,9 @@ public:
void SetUp() override {
CompressedDumpTest::SetUp();
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("compute comp all pair/local dist eng");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
}
};
@ -205,9 +205,9 @@ TEST_F(DumpLocalCompressTest, compressed_modify_bad_param)
auto fields = "index c_comp[1]";
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_dump_filename("modify_bad_param_run0_*.melt.local"), fields));
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
TEST_FAILURE(".*ERROR: Illegal dump_modify command: compression level must in the range of.*",
command("dump_modify id1 compression_level 12");
@ -220,9 +220,9 @@ TEST_F(DumpLocalCompressTest, compressed_modify_multi_bad_param)
auto fields = "index c_comp[1]";
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_dump_filename("modify_multi_bad_param_run0_*.melt.local"), fields));
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
TEST_FAILURE(".*ERROR: Illegal dump_modify command: compression level must in the range of.*",
command("dump_modify id1 pad 3 compression_level 12");

View File

@ -191,9 +191,9 @@ TEST_F(DumpXYZCompressTest, compressed_modify_bad_param)
{
if (compression_style != "xyz/gz") GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command(fmt::format("dump id1 all {} 1 {}", compression_style, compressed_dump_filename("modify_bad_param_run0_*.melt.xyz")));
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
TEST_FAILURE(".*ERROR: Illegal dump_modify command: compression level must in the range of.*",
command("dump_modify id1 compression_level 12");
@ -204,9 +204,9 @@ TEST_F(DumpXYZCompressTest, compressed_modify_multi_bad_param)
{
if (compression_style != "xyz/gz") GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command(fmt::format("dump id1 all {} 1 {}", compression_style, compressed_dump_filename("modify_multi_bad_param_run0_*.melt.xyz")));
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
TEST_FAILURE(".*ERROR: Illegal dump_modify command: compression level must in the range of.*",
command("dump_modify id1 pad 3 compression_level 12");

View File

@ -18,6 +18,7 @@
#include "utils.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "../testing/core.h"
#include <cstring>
#include <mpi.h>
@ -28,28 +29,23 @@ using utils::split_words;
// whether to print verbose output (i.e. not capturing LAMMPS screen output).
bool verbose = false;
class EIMPotentialFileReaderTest : public ::testing::Test {
class EIMPotentialFileReaderTest : public LAMMPSTest {
protected:
LAMMPS *lmp;
PairEIM::Setfl setfl;
static const int nelements = 9;
void SetUp() override
{
const char *args[] = {
"PotentialFileReaderTest", "-log", "none", "-echo", "screen", "-nocite"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
if (!verbose) ::testing::internal::CaptureStdout();
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
lmp->input->one("units metal");
if (!verbose) ::testing::internal::GetCapturedStdout();
testbinary = "EIMPotentialFileReaderTest";
LAMMPSTest::SetUp();
ASSERT_NE(lmp, nullptr);
BEGIN_HIDE_OUTPUT();
command("units metal");
END_HIDE_OUTPUT();
// check if the prerequisite eim pair style is available
Info *info = new Info(lmp);
ASSERT_TRUE(info->has_style("pair", "eim"));
delete info;
int npair = nelements * (nelements + 1) / 2;
setfl.ielement = new int[nelements];
@ -99,17 +95,15 @@ protected:
delete[] setfl.rs;
delete[] setfl.tp;
if (!verbose) ::testing::internal::CaptureStdout();
delete lmp;
if (!verbose) ::testing::internal::GetCapturedStdout();
LAMMPSTest::TearDown();
}
};
TEST_F(EIMPotentialFileReaderTest, global_line)
{
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
EIMPotentialFileReader reader(lmp, "ffield.eim");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
reader.get_global(&setfl);
ASSERT_DOUBLE_EQ(setfl.division, 2.0);
@ -119,9 +113,9 @@ TEST_F(EIMPotentialFileReaderTest, global_line)
TEST_F(EIMPotentialFileReaderTest, element_line_sequential)
{
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
EIMPotentialFileReader reader(lmp, "ffield.eim");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
reader.get_element(&setfl, 0, "Li");
ASSERT_EQ(setfl.ielement[0], 3);
@ -144,9 +138,9 @@ TEST_F(EIMPotentialFileReaderTest, element_line_sequential)
TEST_F(EIMPotentialFileReaderTest, element_line_random)
{
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
EIMPotentialFileReader reader(lmp, "ffield.eim");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
reader.get_element(&setfl, 0, "Id");
ASSERT_EQ(setfl.ielement[0], 53);
@ -160,9 +154,9 @@ TEST_F(EIMPotentialFileReaderTest, element_line_random)
TEST_F(EIMPotentialFileReaderTest, pair_line)
{
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
EIMPotentialFileReader reader(lmp, "ffield.eim");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
reader.get_pair(&setfl, 0, "Li", "Li");
ASSERT_DOUBLE_EQ(setfl.rcutphiA[0], 6.0490e+00);
@ -183,9 +177,9 @@ TEST_F(EIMPotentialFileReaderTest, pair_line)
TEST_F(EIMPotentialFileReaderTest, pair_identical)
{
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
EIMPotentialFileReader reader(lmp, "ffield.eim");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
reader.get_pair(&setfl, 0, "Li", "Na");
reader.get_pair(&setfl, 1, "Na", "Li");

View File

@ -17,6 +17,7 @@
#include "utils.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "../testing/core.h"
#include <cstdio>
#include <mpi.h>
@ -31,43 +32,17 @@ using utils::sfgets;
using utils::sfread;
using utils::split_words;
#if defined(OMPI_MAJOR_VERSION)
const bool have_openmpi = true;
#else
const bool have_openmpi = false;
#endif
#define TEST_FAILURE(errmsg, ...) \
if (Info::has_exceptions()) { \
::testing::internal::CaptureStdout(); \
ASSERT_ANY_THROW({__VA_ARGS__}); \
auto mesg = ::testing::internal::GetCapturedStdout(); \
ASSERT_THAT(mesg, MatchesRegex(errmsg)); \
} else { \
if (!have_openmpi) { \
::testing::internal::CaptureStdout(); \
ASSERT_DEATH({__VA_ARGS__}, ""); \
auto mesg = ::testing::internal::GetCapturedStdout(); \
ASSERT_THAT(mesg, MatchesRegex(errmsg)); \
} \
}
// whether to print verbose output (i.e. not capturing LAMMPS screen output).
bool verbose = false;
class FileOperationsTest : public ::testing::Test {
class FileOperationsTest : public LAMMPSTest {
protected:
LAMMPS *lmp;
void SetUp() override
{
const char *args[] = {"FileOperationsTest", "-log", "none", "-echo", "screen", "-nocite"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
if (!verbose) ::testing::internal::CaptureStdout();
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
if (!verbose) ::testing::internal::GetCapturedStdout();
testbinary = "FileOperationsTest";
LAMMPSTest::SetUp();
ASSERT_NE(lmp, nullptr);
FILE *fp = fopen("safe_file_read_test.txt", "wb");
ASSERT_NE(fp, nullptr);
fputs("one line\n", fp);
@ -79,13 +54,9 @@ protected:
void TearDown() override
{
if (!verbose) ::testing::internal::CaptureStdout();
delete lmp;
if (!verbose) ::testing::internal::GetCapturedStdout();
LAMMPSTest::TearDown();
remove("safe_file_read_test.txt");
}
void command(const std::string &cmd) { lmp->input->one(cmd); }
};
#define MAX_BUF_SIZE 128
@ -179,7 +150,7 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv);
if (have_openmpi && !LAMMPS_NS::Info::has_exceptions())
if (Info::get_mpi_vendor() == "Open MPI" && !LAMMPS_NS::Info::has_exceptions())
std::cout << "Warning: using OpenMPI without exceptions. "
"Death tests will be skipped\n";

View File

@ -15,6 +15,7 @@
#include "input.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "../testing/core.h"
#include <cmath>
#include <cstring>
@ -28,20 +29,14 @@ using LAMMPS_NS::utils::split_words;
namespace LAMMPS_NS {
using ::testing::Eq;
class ImageFlagsTest : public ::testing::Test {
class ImageFlagsTest : public LAMMPSTest {
protected:
LAMMPS *lmp;
void SetUp() override
{
const char *args[] = {"ImageFlagsTest", "-log", "none", "-echo", "screen", "-nocite"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
if (!verbose) ::testing::internal::CaptureStdout();
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
if (!verbose) ::testing::internal::GetCapturedStdout();
testbinary = "ImageFlagsTest";
LAMMPSTest::SetUp();
ASSERT_NE(lmp, nullptr);
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("units real");
command("dimension 3");
command("region box block -2 2 -2 2 -2 2");
@ -54,18 +49,14 @@ protected:
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();
END_HIDE_OUTPUT();
}
void TearDown() override
{
if (!verbose) ::testing::internal::CaptureStdout();
delete lmp;
if (!verbose) ::testing::internal::GetCapturedStdout();
LAMMPSTest::TearDown();
remove("test_image_flags.data");
}
void command(const std::string &cmd) { lmp->input->one(cmd); }
};
TEST_F(ImageFlagsTest, change_box)
@ -87,9 +78,9 @@ TEST_F(ImageFlagsTest, change_box)
ASSERT_EQ(imy, 1);
ASSERT_EQ(imz, -1);
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("change_box all boundary f p p");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
image = lmp->atom->image;
imx = (image[0] & IMGMASK) - IMGMAX;
@ -108,9 +99,9 @@ TEST_F(ImageFlagsTest, change_box)
ASSERT_EQ(imy, 1);
ASSERT_EQ(imz, -1);
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("change_box all boundary f s p");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
image = lmp->atom->image;
imx = (image[0] & IMGMASK) - IMGMAX;
@ -129,9 +120,9 @@ TEST_F(ImageFlagsTest, change_box)
ASSERT_EQ(imy, 0);
ASSERT_EQ(imz, -1);
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("change_box all boundary p p m");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
image = lmp->atom->image;
imx = (image[0] & IMGMASK) - IMGMAX;
@ -153,14 +144,14 @@ TEST_F(ImageFlagsTest, change_box)
TEST_F(ImageFlagsTest, read_data)
{
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
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();
END_HIDE_OUTPUT();
auto image = lmp->atom->image;
int imx = (image[0] & IMGMASK) - IMGMAX;
@ -179,14 +170,14 @@ TEST_F(ImageFlagsTest, read_data)
ASSERT_EQ(imy, 1);
ASSERT_EQ(imz, -1);
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
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();
END_HIDE_OUTPUT();
image = lmp->atom->image;
imx = (image[0] & IMGMASK) - IMGMAX;
@ -205,14 +196,14 @@ TEST_F(ImageFlagsTest, read_data)
ASSERT_EQ(imy, 1);
ASSERT_EQ(imz, -1);
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
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();
END_HIDE_OUTPUT();
image = lmp->atom->image;
imx = (image[0] & IMGMASK) - IMGMAX;
@ -231,14 +222,14 @@ TEST_F(ImageFlagsTest, read_data)
ASSERT_EQ(imy, 0);
ASSERT_EQ(imz, -1);
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
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();
END_HIDE_OUTPUT();
image = lmp->atom->image;
imx = (image[0] & IMGMASK) - IMGMAX;

View File

@ -19,6 +19,7 @@
#include "utils.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "../testing/core.h"
#include <cstdio>
#include <mpi.h>
@ -33,26 +34,6 @@ using utils::split_words;
#define test_name test_info_->name()
#if defined(OMPI_MAJOR_VERSION)
const bool have_openmpi = true;
#else
const bool have_openmpi = false;
#endif
#define TEST_FAILURE(errmsg, ...) \
if (Info::has_exceptions()) { \
::testing::internal::CaptureStdout(); \
ASSERT_ANY_THROW({__VA_ARGS__}); \
auto mesg = ::testing::internal::GetCapturedStdout(); \
ASSERT_THAT(mesg, MatchesRegex(errmsg)); \
} else { \
if (!have_openmpi) { \
::testing::internal::CaptureStdout(); \
ASSERT_DEATH({__VA_ARGS__}, ""); \
auto mesg = ::testing::internal::GetCapturedStdout(); \
ASSERT_THAT(mesg, MatchesRegex(errmsg)); \
} \
}
static void create_molecule_files()
{
@ -96,27 +77,21 @@ static void create_molecule_files()
// whether to print verbose output (i.e. not capturing LAMMPS screen output).
bool verbose = false;
class MoleculeFileTest : public ::testing::Test {
class MoleculeFileTest : public LAMMPSTest {
protected:
LAMMPS *lmp;
void SetUp() override
{
const char *args[] = {"MoleculeFileTest", "-log", "none", "-echo", "screen", "-nocite"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
if (!verbose) ::testing::internal::CaptureStdout();
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
create_molecule_files();
if (!verbose) ::testing::internal::GetCapturedStdout();
testbinary = "MoleculeFileTest";
LAMMPSTest::SetUp();
ASSERT_NE(lmp, nullptr);
BEGIN_HIDE_OUTPUT();
create_molecule_files();
END_HIDE_OUTPUT();
}
void TearDown() override
{
if (!verbose) ::testing::internal::CaptureStdout();
delete lmp;
if (!verbose) ::testing::internal::GetCapturedStdout();
LAMMPSTest::TearDown();
remove("h2o.mol");
remove("co2.mol");
}
@ -128,11 +103,9 @@ protected:
fputs(content.c_str(), fp);
fclose(fp);
lmp->input->one(fmt::format("molecule {} {} {}", name, file, args));
command(fmt::format("molecule {} {} {}", name, file, args));
remove(file.c_str());
}
void command(const std::string &cmd) { lmp->input->one(cmd); }
};
TEST_F(MoleculeFileTest, nofile)
@ -292,7 +265,7 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv);
if (have_openmpi && !LAMMPS_NS::Info::has_exceptions())
if (Info::get_mpi_vendor() == "Open MPI" && !LAMMPS_NS::Info::has_exceptions())
std::cout << "Warning: using OpenMPI without exceptions. "
"Death tests will be skipped\n";

View File

@ -20,6 +20,7 @@
#include "thermo.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "../testing/core.h"
#include <cmath>
#include <cstring>
@ -42,23 +43,17 @@ const double p_convert = 1.01325;
// of data in update.cpp. could be 1.0e-12
const double rel_error = 5.0e-7;
class PairUnitConvertTest : public ::testing::Test {
class PairUnitConvertTest : public LAMMPSTest {
protected:
LAMMPS *lmp;
Info *info;
double fold[4][3];
void SetUp() override
{
const char *args[] = {"PairUnitConvertTest", "-log", "none", "-echo", "screen", "-nocite"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
if (!verbose) ::testing::internal::CaptureStdout();
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
if (!verbose) ::testing::internal::GetCapturedStdout();
testbinary = "PairUnitConvertTest";
LAMMPSTest::SetUp();
ASSERT_NE(lmp, nullptr);
if (!verbose) ::testing::internal::CaptureStdout();
info = new Info(lmp);
BEGIN_HIDE_OUTPUT();
command("units metal");
command("dimension 3");
command("region box block -4 4 -4 4 -4 4");
@ -72,19 +67,14 @@ protected:
command("mass * 1.0");
command("write_data test_pair_unit_convert.data nocoeff");
command("clear");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
}
void TearDown() override
{
if (!verbose) ::testing::internal::CaptureStdout();
delete info;
delete lmp;
if (!verbose) ::testing::internal::GetCapturedStdout();
LAMMPSTest::TearDown();
remove("test_pair_unit_convert.data");
}
void command(const std::string &cmd) { lmp->input->one(cmd); }
};
TEST_F(PairUnitConvertTest, zero)
@ -92,13 +82,13 @@ TEST_F(PairUnitConvertTest, zero)
// check if the prerequisite pair style is available
if (!info->has_style("pair", "zero")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style zero 6.0");
command("pair_coeff * *");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
// copy pressure, energy, and force from first step
double pold;
@ -109,14 +99,14 @@ TEST_F(PairUnitConvertTest, zero)
for (int j = 0; j < 3; ++j)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style zero 6.0");
command("pair_coeff * *");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
double pnew;
lmp->output->thermo->evaluate_keyword("press", &pnew);
@ -135,7 +125,7 @@ TEST_F(PairUnitConvertTest, lj_cut)
// check if the prerequisite pair style is available
if (!info->has_style("pair", "lj/cut")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style lj/cut 6.0");
@ -145,7 +135,7 @@ TEST_F(PairUnitConvertTest, lj_cut)
command("pair_write 1 2 1000 r 0.1 6.0 test.table.metal lj_1_2");
command("pair_write 2 2 1000 r 0.1 6.0 test.table.metal lj_2_2");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
// copy pressure, energy, and force from first step
double pold;
@ -156,7 +146,7 @@ TEST_F(PairUnitConvertTest, lj_cut)
for (int j = 0; j < 3; ++j)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
@ -167,7 +157,7 @@ TEST_F(PairUnitConvertTest, lj_cut)
command("pair_write 1 2 1000 r 0.1 6.0 test.table.real lj_1_2");
command("pair_write 2 2 1000 r 0.1 6.0 test.table.real lj_2_2");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
double pnew;
lmp->output->thermo->evaluate_keyword("press", &pnew);
@ -186,13 +176,13 @@ TEST_F(PairUnitConvertTest, eam)
// check if the prerequisite pair style is available
if (!info->has_style("pair", "eam")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style eam");
command("pair_coeff * * Cu_u3.eam");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
// copy pressure, energy, and force from first step
double pold;
@ -203,14 +193,14 @@ TEST_F(PairUnitConvertTest, eam)
for (int j = 0; j < 3; ++j)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style eam");
command("pair_coeff * * Cu_u3.eam");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
double pnew;
lmp->output->thermo->evaluate_keyword("press", &pnew);
@ -229,13 +219,13 @@ TEST_F(PairUnitConvertTest, eam_alloy)
// check if the prerequisite pair style is available
if (!info->has_style("pair", "eam/alloy")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style eam/alloy");
command("pair_coeff * * AlCu.eam.alloy Al Cu");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
// copy pressure, energy, and force from first step
double pold;
@ -246,14 +236,14 @@ TEST_F(PairUnitConvertTest, eam_alloy)
for (int j = 0; j < 3; ++j)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style eam/alloy");
command("pair_coeff * * AlCu.eam.alloy Al Cu");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
double pnew;
lmp->output->thermo->evaluate_keyword("press", &pnew);
@ -272,13 +262,13 @@ TEST_F(PairUnitConvertTest, eam_fs)
// check if the prerequisite pair style is available
if (!info->has_style("pair", "eam/fs")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style eam/fs");
command("pair_coeff * * FeP_mm.eam.fs Fe P");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
// copy pressure, energy, and force from first step
double pold;
@ -289,14 +279,14 @@ TEST_F(PairUnitConvertTest, eam_fs)
for (int j = 0; j < 3; ++j)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style eam/fs");
command("pair_coeff * * FeP_mm.eam.fs Fe P");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
double pnew;
lmp->output->thermo->evaluate_keyword("press", &pnew);
@ -315,13 +305,13 @@ TEST_F(PairUnitConvertTest, eam_cd)
// check if the prerequisite pair style is available
if (!info->has_style("pair", "eam/cd")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style eam/cd");
command("pair_coeff * * FeCr.cdeam Cr Fe");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
// copy pressure, energy, and force from first step
double pold;
@ -332,14 +322,14 @@ TEST_F(PairUnitConvertTest, eam_cd)
for (int j = 0; j < 3; ++j)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style eam/cd");
command("pair_coeff * * FeCr.cdeam Cr Fe");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
double pnew;
lmp->output->thermo->evaluate_keyword("press", &pnew);
@ -358,13 +348,13 @@ TEST_F(PairUnitConvertTest, eim)
// check if the prerequisite pair style is available
if (!info->has_style("pair", "eim")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style eim");
command("pair_coeff * * Na Cl ffield.eim Na Cl");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
// copy pressure, energy, and force from first step
double pold;
@ -375,14 +365,14 @@ TEST_F(PairUnitConvertTest, eim)
for (int j = 0; j < 3; ++j)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style eim");
command("pair_coeff * * Na Cl ffield.eim Na Cl");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
double pnew;
lmp->output->thermo->evaluate_keyword("press", &pnew);
@ -401,13 +391,13 @@ TEST_F(PairUnitConvertTest, gw)
// check if the prerequisite pair style is available
if (!info->has_style("pair", "gw")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style gw");
command("pair_coeff * * SiC.gw Si C");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
// copy pressure, energy, and force from first step
double pold;
@ -418,14 +408,14 @@ TEST_F(PairUnitConvertTest, gw)
for (int j = 0; j < 3; ++j)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style gw");
command("pair_coeff * * SiC.gw Si C");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
double pnew;
lmp->output->thermo->evaluate_keyword("press", &pnew);
@ -444,13 +434,13 @@ TEST_F(PairUnitConvertTest, gw_zbl)
// check if the prerequisite pair style is available
if (!info->has_style("pair", "gw/zbl")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style gw/zbl");
command("pair_coeff * * SiC.gw.zbl Si C");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
// copy pressure, energy, and force from first step
double pold;
@ -461,14 +451,14 @@ TEST_F(PairUnitConvertTest, gw_zbl)
for (int j = 0; j < 3; ++j)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style gw/zbl");
command("pair_coeff * * SiC.gw.zbl Si C");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
double pnew;
lmp->output->thermo->evaluate_keyword("press", &pnew);
@ -487,13 +477,13 @@ TEST_F(PairUnitConvertTest, nb3b_harmonic)
// check if the prerequisite pair style is available
if (!info->has_style("pair", "nb3b/harmonic")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style nb3b/harmonic");
command("pair_coeff * * MOH.nb3b.harmonic M O");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
// copy pressure, energy, and force from first step
double pold;
@ -504,14 +494,14 @@ TEST_F(PairUnitConvertTest, nb3b_harmonic)
for (int j = 0; j < 3; ++j)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style nb3b/harmonic");
command("pair_coeff * * MOH.nb3b.harmonic M O");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
double pnew;
lmp->output->thermo->evaluate_keyword("press", &pnew);
@ -530,13 +520,13 @@ TEST_F(PairUnitConvertTest, sw)
// check if the prerequisite pair style is available
if (!info->has_style("pair", "sw")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style sw");
command("pair_coeff * * GaN.sw Ga N");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
// copy pressure, energy, and force from first step
double pold;
@ -547,14 +537,14 @@ TEST_F(PairUnitConvertTest, sw)
for (int j = 0; j < 3; ++j)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style sw");
command("pair_coeff * * GaN.sw Ga N");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
double pnew;
lmp->output->thermo->evaluate_keyword("press", &pnew);
@ -573,7 +563,7 @@ TEST_F(PairUnitConvertTest, table_metal2real)
// check if the prerequisite pair style is available
if (!info->has_style("pair", "table")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style table linear 1000");
@ -581,7 +571,7 @@ TEST_F(PairUnitConvertTest, table_metal2real)
command("pair_coeff 1 2 test.table.metal lj_1_2");
command("pair_coeff 2 2 test.table.metal lj_2_2");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
// copy pressure, energy, and force from first step
double pold;
@ -592,7 +582,7 @@ TEST_F(PairUnitConvertTest, table_metal2real)
for (int j = 0; j < 3; ++j)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
@ -601,7 +591,7 @@ TEST_F(PairUnitConvertTest, table_metal2real)
command("pair_coeff 1 2 test.table.metal lj_1_2");
command("pair_coeff 2 2 test.table.metal lj_2_2");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
double pnew;
lmp->output->thermo->evaluate_keyword("press", &pnew);
@ -620,7 +610,7 @@ TEST_F(PairUnitConvertTest, table_real2metal)
// check if the prerequisite pair style is available
if (!info->has_style("pair", "table")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style table linear 1000");
@ -628,7 +618,7 @@ TEST_F(PairUnitConvertTest, table_real2metal)
command("pair_coeff 1 2 test.table.real lj_1_2");
command("pair_coeff 2 2 test.table.real lj_2_2");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
// copy pressure, energy, and force from first step
double pold;
@ -639,7 +629,7 @@ TEST_F(PairUnitConvertTest, table_real2metal)
for (int j = 0; j < 3; ++j)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("clear");
command("units metal");
command("read_data test_pair_unit_convert.data");
@ -648,7 +638,7 @@ TEST_F(PairUnitConvertTest, table_real2metal)
command("pair_coeff 1 2 test.table.real lj_1_2");
command("pair_coeff 2 2 test.table.real lj_2_2");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
double pnew;
lmp->output->thermo->evaluate_keyword("press", &pnew);
@ -667,13 +657,13 @@ TEST_F(PairUnitConvertTest, tersoff)
// check if the prerequisite pair style is available
if (!info->has_style("pair", "tersoff")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style tersoff");
command("pair_coeff * * SiC.tersoff Si C");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
// copy pressure, energy, and force from first step
double pold;
@ -684,14 +674,14 @@ TEST_F(PairUnitConvertTest, tersoff)
for (int j = 0; j < 3; ++j)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style tersoff");
command("pair_coeff * * SiC.tersoff Si C");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
double pnew;
lmp->output->thermo->evaluate_keyword("press", &pnew);
@ -710,13 +700,13 @@ TEST_F(PairUnitConvertTest, tersoff_mod)
// check if the prerequisite pair style is available
if (!info->has_style("pair", "tersoff/mod")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style tersoff/mod");
command("pair_coeff * * Si.tersoff.mod Si Si");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
// copy pressure, energy, and force from first step
double pold;
@ -727,14 +717,14 @@ TEST_F(PairUnitConvertTest, tersoff_mod)
for (int j = 0; j < 3; ++j)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style tersoff/mod");
command("pair_coeff * * Si.tersoff.mod Si Si");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
double pnew;
lmp->output->thermo->evaluate_keyword("press", &pnew);
@ -753,13 +743,13 @@ TEST_F(PairUnitConvertTest, tersoff_mod_c)
// check if the prerequisite pair style is available
if (!info->has_style("pair", "tersoff/mod/c")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style tersoff/mod/c");
command("pair_coeff * * Si.tersoff.modc Si Si");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
// copy pressure, energy, and force from first step
double pold;
@ -770,14 +760,14 @@ TEST_F(PairUnitConvertTest, tersoff_mod_c)
for (int j = 0; j < 3; ++j)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style tersoff/mod/c");
command("pair_coeff * * Si.tersoff.modc Si Si");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
double pnew;
lmp->output->thermo->evaluate_keyword("press", &pnew);
@ -796,13 +786,13 @@ TEST_F(PairUnitConvertTest, tersoff_table)
// check if the prerequisite pair style is available
if (!info->has_style("pair", "tersoff/table")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style tersoff/table");
command("pair_coeff * * SiC.tersoff Si C");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
// copy pressure, energy, and force from first step
double pold;
@ -813,14 +803,14 @@ TEST_F(PairUnitConvertTest, tersoff_table)
for (int j = 0; j < 3; ++j)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style tersoff/table");
command("pair_coeff * * SiC.tersoff Si C");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
double pnew;
lmp->output->thermo->evaluate_keyword("press", &pnew);
@ -839,13 +829,13 @@ TEST_F(PairUnitConvertTest, tersoff_zbl)
// check if the prerequisite pair style is available
if (!info->has_style("pair", "tersoff/zbl")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style tersoff/zbl");
command("pair_coeff * * SiC.tersoff.zbl Si C");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
// copy pressure, energy, and force from first step
double pold;
@ -856,14 +846,14 @@ TEST_F(PairUnitConvertTest, tersoff_zbl)
for (int j = 0; j < 3; ++j)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style tersoff/zbl");
command("pair_coeff * * SiC.tersoff.zbl Si C");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
double pnew;
lmp->output->thermo->evaluate_keyword("press", &pnew);
@ -882,14 +872,14 @@ TEST_F(PairUnitConvertTest, tersoff_zbl_omp)
// check if the prerequisite pair style is available
if (!info->has_style("pair", "tersoff/zbl/omp")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("package omp 4");
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style tersoff/zbl/omp");
command("pair_coeff * * SiC.tersoff.zbl Si C");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
// copy pressure, energy, and force from first step
double pold;
@ -900,7 +890,7 @@ TEST_F(PairUnitConvertTest, tersoff_zbl_omp)
for (int j = 0; j < 3; ++j)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("clear");
command("package omp 4");
command("units real");
@ -908,7 +898,7 @@ TEST_F(PairUnitConvertTest, tersoff_zbl_omp)
command("pair_style tersoff/zbl/omp");
command("pair_coeff * * SiC.tersoff.zbl Si C");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
double pnew;
lmp->output->thermo->evaluate_keyword("press", &pnew);
@ -927,13 +917,13 @@ TEST_F(PairUnitConvertTest, vashishta)
// check if the prerequisite pair style is available
if (!info->has_style("pair", "vashishta")) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("units metal");
command("read_data test_pair_unit_convert.data");
command("pair_style vashishta");
command("pair_coeff * * SiC.vashishta Si C");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
// copy pressure, energy, and force from first step
double pold;
@ -944,14 +934,14 @@ TEST_F(PairUnitConvertTest, vashishta)
for (int j = 0; j < 3; ++j)
fold[i][j] = f[i][j];
if (!verbose) ::testing::internal::CaptureStdout();
BEGIN_HIDE_OUTPUT();
command("clear");
command("units real");
command("read_data test_pair_unit_convert.data");
command("pair_style vashishta");
command("pair_coeff * * SiC.vashishta Si C");
command("run 0 post no");
if (!verbose) ::testing::internal::GetCapturedStdout();
END_HIDE_OUTPUT();
double pnew;
lmp->output->thermo->evaluate_keyword("press", &pnew);