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

@ -1,65 +1,70 @@
// unit tests for issuing command to a LAMMPS instance through the Fortran wrapper
#include "lammps.h"
#include <cstdio> // for stdin, stdout
#include <mpi.h>
#include <cstdio> // for stdin, stdout
#include <string>
#include "gtest/gtest.h"
// prototypes for fortran reverse wrapper functions
extern "C" {
void *f_lammps_with_args();
void f_lammps_close();
void f_lammps_file();
void f_lammps_command();
void f_lammps_commands_list();
void f_lammps_commands_string();
double f_lammps_get_natoms();
void *f_lammps_with_args();
void f_lammps_close();
void f_lammps_file();
void f_lammps_command();
void f_lammps_commands_list();
void f_lammps_commands_string();
double f_lammps_get_natoms();
}
class LAMMPS_commands : public ::testing::Test
{
class LAMMPS_commands : public ::testing::Test {
protected:
LAMMPS_NS::LAMMPS *lmp;
LAMMPS_commands() {};
~LAMMPS_commands() override {};
LAMMPS_commands(){};
~LAMMPS_commands() override{};
void SetUp() override {
void SetUp() override
{
::testing::internal::CaptureStdout();
lmp = (LAMMPS_NS::LAMMPS *)f_lammps_with_args();
lmp = (LAMMPS_NS::LAMMPS *)f_lammps_with_args();
std::string output = ::testing::internal::GetCapturedStdout();
EXPECT_STREQ(output.substr(0,8).c_str(), "LAMMPS (");
EXPECT_STREQ(output.substr(0, 8).c_str(), "LAMMPS (");
}
void TearDown() override {
void TearDown() override
{
::testing::internal::CaptureStdout();
f_lammps_close();
std::string output = ::testing::internal::GetCapturedStdout();
EXPECT_STREQ(output.substr(0,16).c_str(), "Total wall time:");
EXPECT_STREQ(output.substr(0, 16).c_str(), "Total wall time:");
lmp = nullptr;
}
};
TEST_F(LAMMPS_commands, from_file) {
EXPECT_EQ(f_lammps_get_natoms(),0);
TEST_F(LAMMPS_commands, from_file)
{
EXPECT_EQ(f_lammps_get_natoms(), 0);
f_lammps_file();
EXPECT_EQ(f_lammps_get_natoms(),2);
EXPECT_EQ(f_lammps_get_natoms(), 2);
};
TEST_F(LAMMPS_commands, from_line) {
EXPECT_EQ(f_lammps_get_natoms(),0);
TEST_F(LAMMPS_commands, from_line)
{
EXPECT_EQ(f_lammps_get_natoms(), 0);
f_lammps_command();
EXPECT_EQ(f_lammps_get_natoms(),1);
EXPECT_EQ(f_lammps_get_natoms(), 1);
};
TEST_F(LAMMPS_commands, from_list) {
EXPECT_EQ(f_lammps_get_natoms(),0);
TEST_F(LAMMPS_commands, from_list)
{
EXPECT_EQ(f_lammps_get_natoms(), 0);
f_lammps_commands_list();
EXPECT_EQ(f_lammps_get_natoms(),2);
EXPECT_EQ(f_lammps_get_natoms(), 2);
};
TEST_F(LAMMPS_commands, from_string) {
EXPECT_EQ(f_lammps_get_natoms(),0);
TEST_F(LAMMPS_commands, from_string)
{
EXPECT_EQ(f_lammps_get_natoms(), 0);
f_lammps_commands_string();
EXPECT_EQ(f_lammps_get_natoms(),2);
EXPECT_EQ(f_lammps_get_natoms(), 2);
};

View File

@ -1,33 +1,34 @@
// unit tests for the LAMMPS base class
#include "lammps.h"
#include <cstdio> // for stdin, stdout
#include <mpi.h>
#include <cstdio> // for stdin, stdout
#include <string>
#include "gtest/gtest.h"
// prototypes for fortran reverse wrapper functions
extern "C" {
void *f_lammps_open_no_args();
void *f_lammps_open_with_args();
void *f_lammps_no_mpi_no_args();
void *f_lammps_no_mpi_with_args();
void f_lammps_close();
int f_lammps_get_comm();
void *f_lammps_open_no_args();
void *f_lammps_open_with_args();
void *f_lammps_no_mpi_no_args();
void *f_lammps_no_mpi_with_args();
void f_lammps_close();
int f_lammps_get_comm();
}
TEST(open_no_mpi, no_args) {
TEST(open_no_mpi, no_args)
{
::testing::internal::CaptureStdout();
int mpi_init=0;
int mpi_init = 0;
MPI_Initialized(&mpi_init);
EXPECT_EQ(mpi_init,0);
void *handle = f_lammps_no_mpi_no_args();
EXPECT_EQ(mpi_init, 0);
void *handle = f_lammps_no_mpi_no_args();
std::string output = ::testing::internal::GetCapturedStdout();
EXPECT_STREQ(output.substr(0,6).c_str(),"LAMMPS");
EXPECT_STREQ(output.substr(0, 6).c_str(), "LAMMPS");
LAMMPS_NS::LAMMPS *lmp = (LAMMPS_NS::LAMMPS *)handle;
MPI_Initialized(&mpi_init);
EXPECT_NE(mpi_init,0);
EXPECT_NE(mpi_init, 0);
EXPECT_EQ(lmp->world, MPI_COMM_WORLD);
EXPECT_EQ(lmp->infile, stdin);
EXPECT_EQ(lmp->screen, stdout);
@ -35,14 +36,15 @@ TEST(open_no_mpi, no_args) {
::testing::internal::CaptureStdout();
f_lammps_close();
output = ::testing::internal::GetCapturedStdout();
EXPECT_STREQ(output.substr(0,16).c_str(), "Total wall time:");
EXPECT_STREQ(output.substr(0, 16).c_str(), "Total wall time:");
}
TEST(open_no_mpi, with_args) {
TEST(open_no_mpi, with_args)
{
::testing::internal::CaptureStdout();
void *handle = f_lammps_no_mpi_with_args();
void *handle = f_lammps_no_mpi_with_args();
std::string output = ::testing::internal::GetCapturedStdout();
EXPECT_STREQ(output.substr(0,6).c_str(),"LAMMPS");
EXPECT_STREQ(output.substr(0, 6).c_str(), "LAMMPS");
LAMMPS_NS::LAMMPS *lmp = (LAMMPS_NS::LAMMPS *)handle;
EXPECT_EQ(lmp->infile, stdin);
EXPECT_EQ(lmp->screen, stdout);
@ -53,17 +55,18 @@ TEST(open_no_mpi, with_args) {
::testing::internal::CaptureStdout();
f_lammps_close();
output = ::testing::internal::GetCapturedStdout();
EXPECT_STREQ(output.substr(0,16).c_str(), "Total wall time:");
EXPECT_STREQ(output.substr(0, 16).c_str(), "Total wall time:");
}
TEST(fortran_open, no_args) {
TEST(fortran_open, no_args)
{
::testing::internal::CaptureStdout();
void *handle = f_lammps_open_no_args();
void *handle = f_lammps_open_no_args();
std::string output = ::testing::internal::GetCapturedStdout();
EXPECT_STREQ(output.substr(0,6).c_str(),"LAMMPS");
EXPECT_STREQ(output.substr(0, 6).c_str(), "LAMMPS");
LAMMPS_NS::LAMMPS *lmp = (LAMMPS_NS::LAMMPS *)handle;
int f_comm = f_lammps_get_comm();
int f_comm = f_lammps_get_comm();
MPI_Comm mycomm = MPI_Comm_f2c(f_comm);
EXPECT_EQ(lmp->world, mycomm);
EXPECT_EQ(lmp->infile, stdin);
@ -72,17 +75,18 @@ TEST(fortran_open, no_args) {
::testing::internal::CaptureStdout();
f_lammps_close();
output = ::testing::internal::GetCapturedStdout();
EXPECT_STREQ(output.substr(0,16).c_str(), "Total wall time:");
EXPECT_STREQ(output.substr(0, 16).c_str(), "Total wall time:");
}
TEST(fortran_open, with_args) {
TEST(fortran_open, with_args)
{
::testing::internal::CaptureStdout();
void *handle = f_lammps_open_with_args();
void *handle = f_lammps_open_with_args();
std::string output = ::testing::internal::GetCapturedStdout();
EXPECT_STREQ(output.substr(0,6).c_str(),"LAMMPS");
EXPECT_STREQ(output.substr(0, 6).c_str(), "LAMMPS");
LAMMPS_NS::LAMMPS *lmp = (LAMMPS_NS::LAMMPS *)handle;
int f_comm = f_lammps_get_comm();
int f_comm = f_lammps_get_comm();
MPI_Comm mycomm = MPI_Comm_f2c(f_comm);
EXPECT_EQ(lmp->world, mycomm);
EXPECT_EQ(lmp->infile, stdin);
@ -93,5 +97,5 @@ TEST(fortran_open, with_args) {
::testing::internal::CaptureStdout();
f_lammps_close();
output = ::testing::internal::GetCapturedStdout();
EXPECT_STREQ(output.substr(0,16).c_str(), "Total wall time:");
EXPECT_STREQ(output.substr(0, 16).c_str(), "Total wall time:");
}