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,30 +11,33 @@
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"
#include <string>
char * GZIP_BINARY = nullptr;
char *GZIP_BINARY = nullptr;
using ::testing::Eq;
class DumpAtomGZTest : public MeltTest {
std::string dump_style = "atom";
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 dump_modify_options, int ntimesteps) {
void generate_dump(std::string dump_file, std::string dump_modify_options, int ntimesteps)
{
if (!verbose) ::testing::internal::CaptureStdout();
command(fmt::format("dump id all {} 1 {}", dump_style, dump_file));
@ -46,7 +49,10 @@ public:
if (!verbose) ::testing::internal::GetCapturedStdout();
}
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file, std::string compression_style, std::string dump_modify_options, int ntimesteps) {
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file,
std::string compression_style,
std::string dump_modify_options, int ntimesteps)
{
if (!verbose) ::testing::internal::CaptureStdout();
command(fmt::format("dump id0 all {} 1 {}", dump_style, text_file));
command(fmt::format("dump id1 all {} 1 {}", compression_style, compressed_file));
@ -60,26 +66,27 @@ public:
if (!verbose) ::testing::internal::GetCapturedStdout();
}
std::string convert_compressed_to_text(std::string compressed_file) {
std::string convert_compressed_to_text(std::string compressed_file)
{
if (!verbose) ::testing::internal::CaptureStdout();
std::string converted_file = compressed_file.substr(0, compressed_file.find_last_of('.'));
std::string cmdline = fmt::format("{} -d -c {} > {}", GZIP_BINARY, compressed_file, converted_file);
std::string cmdline =
fmt::format("{} -d -c {} > {}", GZIP_BINARY, compressed_file, converted_file);
system(cmdline.c_str());
if (!verbose) ::testing::internal::GetCapturedStdout();
return converted_file;
}
};
//-------------------------------------------------------------------------------------------------
// GZ compressed files
//-------------------------------------------------------------------------------------------------
TEST_F(DumpAtomGZTest, compressed_run0)
{
if(!GZIP_BINARY) GTEST_SKIP();
if (!GZIP_BINARY) GTEST_SKIP();
auto text_file = "dump_gz_text_run0.melt";
auto text_file = "dump_gz_text_run0.melt";
auto compressed_file = "dump_gz_compressed_run0.melt.gz";
generate_text_and_compressed_dump(text_file, compressed_file, "atom/gz", "", 0);
@ -101,12 +108,13 @@ TEST_F(DumpAtomGZTest, compressed_run0)
TEST_F(DumpAtomGZTest, compressed_with_units_run0)
{
if(!GZIP_BINARY) GTEST_SKIP();
if (!GZIP_BINARY) GTEST_SKIP();
auto text_file = "dump_gz_text_with_units_run0.melt";
auto text_file = "dump_gz_text_with_units_run0.melt";
auto compressed_file = "dump_gz_compressed_with_units_run0.melt.gz";
generate_text_and_compressed_dump(text_file, compressed_file, "atom/gz", "scale no units yes", 0);
generate_text_and_compressed_dump(text_file, compressed_file, "atom/gz", "scale no units yes",
0);
TearDown();
@ -124,12 +132,13 @@ TEST_F(DumpAtomGZTest, compressed_with_units_run0)
TEST_F(DumpAtomGZTest, compressed_with_time_run0)
{
if(!GZIP_BINARY) GTEST_SKIP();
if (!GZIP_BINARY) GTEST_SKIP();
auto text_file = "dump_gz_text_with_time_run0.melt";
auto text_file = "dump_gz_text_with_time_run0.melt";
auto compressed_file = "dump_gz_compressed_with_time_run0.melt.gz";
generate_text_and_compressed_dump(text_file, compressed_file, "atom/gz", "scale no time yes", 0);
generate_text_and_compressed_dump(text_file, compressed_file, "atom/gz", "scale no time yes",
0);
TearDown();
@ -147,9 +156,9 @@ TEST_F(DumpAtomGZTest, compressed_with_time_run0)
TEST_F(DumpAtomGZTest, compressed_triclinic_run0)
{
if(!GZIP_BINARY) GTEST_SKIP();
if (!GZIP_BINARY) GTEST_SKIP();
auto text_file = "dump_gz_text_tri_run0.melt";
auto text_file = "dump_gz_text_tri_run0.melt";
auto compressed_file = "dump_gz_compressed_tri_run0.melt.gz";
enable_triclinic();
@ -171,13 +180,14 @@ TEST_F(DumpAtomGZTest, compressed_triclinic_run0)
TEST_F(DumpAtomGZTest, compressed_triclinic_with_units_run0)
{
if(!GZIP_BINARY) GTEST_SKIP();
if (!GZIP_BINARY) GTEST_SKIP();
auto text_file = "dump_gz_text_tri_with_units_run0.melt";
auto text_file = "dump_gz_text_tri_with_units_run0.melt";
auto compressed_file = "dump_gz_compressed_tri_with_units_run0.melt.gz";
enable_triclinic();
generate_text_and_compressed_dump(text_file, compressed_file, "atom/gz", "scale no units yes", 0);
generate_text_and_compressed_dump(text_file, compressed_file, "atom/gz", "scale no units yes",
0);
TearDown();
@ -195,13 +205,14 @@ TEST_F(DumpAtomGZTest, compressed_triclinic_with_units_run0)
TEST_F(DumpAtomGZTest, compressed_triclinic_with_time_run0)
{
if(!GZIP_BINARY) GTEST_SKIP();
if (!GZIP_BINARY) GTEST_SKIP();
auto text_file = "dump_gz_text_tri_with_time_run0.melt";
auto text_file = "dump_gz_text_tri_with_time_run0.melt";
auto compressed_file = "dump_gz_compressed_tri_with_time_run0.melt.gz";
enable_triclinic();
generate_text_and_compressed_dump(text_file, compressed_file, "atom/gz", "scale no time yes", 0);
generate_text_and_compressed_dump(text_file, compressed_file, "atom/gz", "scale no time yes",
0);
TearDown();
@ -219,9 +230,9 @@ TEST_F(DumpAtomGZTest, compressed_triclinic_with_time_run0)
TEST_F(DumpAtomGZTest, compressed_triclinic_with_image_run0)
{
if(!GZIP_BINARY) GTEST_SKIP();
if (!GZIP_BINARY) GTEST_SKIP();
auto text_file = "dump_gz_text_tri_with_image_run0.melt";
auto text_file = "dump_gz_text_tri_with_image_run0.melt";
auto compressed_file = "dump_gz_compressed_tri_with_image_run0.melt.gz";
enable_triclinic();