reformat unittest sources with clang-format
This commit is contained in:
committed by
Richard Berger
parent
a8b60848c3
commit
569a000e6b
@ -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:");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user