reformat unittest sources with clang-format

This commit is contained in:
Axel Kohlmeyer
2020-11-18 18:27:20 -05:00
committed by Richard Berger
parent a8b60848c3
commit 569a000e6b
32 changed files with 2022 additions and 2071 deletions

View File

@ -11,28 +11,32 @@
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#include "gtest/gtest.h"
#include "gmock/gmock.h"
#include "fmt/format.h"
#include "utils.h"
#include "../testing/core.h"
#include "../testing/systems/melt.h"
#include "../testing/utils.h"
#include "fmt/format.h"
#include "utils.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
using ::testing::Eq;
char * BINARY2TXT_BINARY = nullptr;
char *BINARY2TXT_BINARY = nullptr;
class DumpCustomTest : public MeltTest {
std::string dump_style = "custom";
public:
void enable_triclinic() {
void enable_triclinic()
{
if (!verbose) ::testing::internal::CaptureStdout();
command("change_box all triclinic");
if (!verbose) ::testing::internal::GetCapturedStdout();
}
void generate_dump(std::string dump_file, std::string fields, std::string dump_modify_options, int ntimesteps) {
void generate_dump(std::string dump_file, std::string fields, std::string dump_modify_options,
int ntimesteps)
{
if (!verbose) ::testing::internal::CaptureStdout();
command(fmt::format("dump id all {} 1 {} {}", dump_style, dump_file, fields));
@ -44,8 +48,10 @@ public:
if (!verbose) ::testing::internal::GetCapturedStdout();
}
void generate_text_and_binary_dump(std::string text_file, std::string binary_file, std::string fields,
std::string dump_modify_options, int ntimesteps) {
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();
command(fmt::format("dump id0 all {} 1 {} {}", dump_style, text_file, fields));
command(fmt::format("dump id1 all {} 1 {} {}", dump_style, binary_file, fields));
@ -59,7 +65,8 @@ public:
if (!verbose) ::testing::internal::GetCapturedStdout();
}
std::string convert_binary_to_text(std::string binary_file) {
std::string convert_binary_to_text(std::string binary_file)
{
if (!verbose) ::testing::internal::CaptureStdout();
std::string cmdline = fmt::format("{} {}", BINARY2TXT_BINARY, binary_file);
system(cmdline.c_str());
@ -71,7 +78,8 @@ public:
TEST_F(DumpCustomTest, run1)
{
auto dump_file = "dump_custom_run1.melt";
auto fields = "id type proc procp1 mass x y z ix iy iz xs ys zs xu yu zu xsu ysu zsu vx vy vz fx fy fz";
auto fields =
"id type proc procp1 mass x y z ix iy iz xs ys zs xu yu zu xsu ysu zsu vx vy vz fx fy fz";
generate_dump(dump_file, fields, "units yes", 1);
@ -88,7 +96,7 @@ TEST_F(DumpCustomTest, run1)
TEST_F(DumpCustomTest, thresh_run0)
{
auto dump_file = "dump_custom_thresh_run0.melt";
auto fields = "id type x y z";
auto fields = "id type x y z";
generate_dump(dump_file, fields, "units yes thresh x < 1 thresh y < 1 thresh z < 1", 0);
@ -109,7 +117,7 @@ TEST_F(DumpCustomTest, compute_run0)
if (!verbose) ::testing::internal::GetCapturedStdout();
auto dump_file = "dump_custom_compute_run0.melt";
auto fields = "id type x y z c_comp[1] c_comp[2] c_comp[3]";
auto fields = "id type x y z c_comp[1] c_comp[2] c_comp[3]";
generate_dump(dump_file, fields, "units yes", 0);
@ -130,7 +138,7 @@ TEST_F(DumpCustomTest, fix_run0)
if (!verbose) ::testing::internal::GetCapturedStdout();
auto dump_file = "dump_custom_compute_run0.melt";
auto fields = "id x y z f_numdiff[1] f_numdiff[2] f_numdiff[3]";
auto fields = "id x y z f_numdiff[1] f_numdiff[2] f_numdiff[3]";
generate_dump(dump_file, fields, "units yes", 0);
@ -152,7 +160,7 @@ TEST_F(DumpCustomTest, custom_run0)
if (!verbose) ::testing::internal::GetCapturedStdout();
auto dump_file = "dump_custom_custom_run0.melt";
auto fields = "id x y z i_flag1 d_flag2";
auto fields = "id x y z i_flag1 d_flag2";
generate_dump(dump_file, fields, "units yes", 0);
@ -168,9 +176,9 @@ TEST_F(DumpCustomTest, custom_run0)
TEST_F(DumpCustomTest, binary_run1)
{
if(!BINARY2TXT_BINARY) GTEST_SKIP();
if (!BINARY2TXT_BINARY) GTEST_SKIP();
auto text_file = "dump_custom_text_run1.melt";
auto text_file = "dump_custom_text_run1.melt";
auto binary_file = "dump_custom_binary_run1.melt.bin";
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";
@ -191,7 +199,7 @@ TEST_F(DumpCustomTest, binary_run1)
TEST_F(DumpCustomTest, triclinic_run1)
{
auto dump_file = "dump_custom_tri_run1.melt";
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";
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";
enable_triclinic();
@ -209,12 +217,12 @@ TEST_F(DumpCustomTest, triclinic_run1)
TEST_F(DumpCustomTest, binary_triclinic_run1)
{
if(!BINARY2TXT_BINARY) GTEST_SKIP();
if (!BINARY2TXT_BINARY) GTEST_SKIP();
auto text_file = "dump_custom_tri_text_run1.melt";
auto text_file = "dump_custom_tri_text_run1.melt";
auto binary_file = "dump_custom_tri_binary_run1.melt.bin";
auto fields = "id type proc x y z xs ys zs xsu ysu zsu vx vy vz fx fy fz";
auto fields = "id type proc x y z xs ys zs xsu ysu zsu vx vy vz fx fy fz";
enable_triclinic();
generate_text_and_binary_dump(text_file, binary_file, fields, "units yes", 1);
@ -239,8 +247,8 @@ TEST_F(DumpCustomTest, with_variable_run1)
if (!verbose) ::testing::internal::GetCapturedStdout();
auto dump_file = "dump_custom_with_variable_run1.melt";
auto fields = "id type x y z v_p";
auto fields = "id type x y z v_p";
generate_dump(dump_file, fields, "units yes", 1);
ASSERT_FILE_EXISTS(dump_file);
@ -253,7 +261,6 @@ TEST_F(DumpCustomTest, with_variable_run1)
delete_file(dump_file);
}
int main(int argc, char **argv)
{
MPI_Init(&argc, &argv);