apply consistent naming scheme for tester source files and executables

This commit is contained in:
Axel Kohlmeyer
2020-09-01 20:16:39 -04:00
parent 2ffb5ddd5a
commit c50a82af78
12 changed files with 21 additions and 21 deletions

View File

@ -0,0 +1,97 @@
// unit tests for the LAMMPS base class
#include "lammps.h"
#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();
}
TEST(open_no_mpi, no_args) {
::testing::internal::CaptureStdout();
int mpi_init=0;
MPI_Initialized(&mpi_init);
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");
LAMMPS_NS::LAMMPS *lmp = (LAMMPS_NS::LAMMPS *)handle;
MPI_Initialized(&mpi_init);
EXPECT_NE(mpi_init,0);
EXPECT_EQ(lmp->world, MPI_COMM_WORLD);
EXPECT_EQ(lmp->infile, stdin);
EXPECT_EQ(lmp->screen, stdout);
EXPECT_NE(lmp->citeme, nullptr);
::testing::internal::CaptureStdout();
f_lammps_close();
output = ::testing::internal::GetCapturedStdout();
EXPECT_STREQ(output.substr(0,16).c_str(), "Total wall time:");
}
TEST(open_no_mpi, with_args) {
::testing::internal::CaptureStdout();
void *handle = f_lammps_no_mpi_with_args();
std::string output = ::testing::internal::GetCapturedStdout();
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);
EXPECT_EQ(lmp->logfile, nullptr);
EXPECT_EQ(lmp->citeme, nullptr);
EXPECT_EQ(lmp->world, MPI_COMM_WORLD);
::testing::internal::CaptureStdout();
f_lammps_close();
output = ::testing::internal::GetCapturedStdout();
EXPECT_STREQ(output.substr(0,16).c_str(), "Total wall time:");
}
TEST(fortran_open, no_args) {
::testing::internal::CaptureStdout();
void *handle = f_lammps_open_no_args();
std::string output = ::testing::internal::GetCapturedStdout();
EXPECT_STREQ(output.substr(0,6).c_str(),"LAMMPS");
LAMMPS_NS::LAMMPS *lmp = (LAMMPS_NS::LAMMPS *)handle;
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);
EXPECT_EQ(lmp->screen, stdout);
EXPECT_NE(lmp->citeme, nullptr);
::testing::internal::CaptureStdout();
f_lammps_close();
output = ::testing::internal::GetCapturedStdout();
EXPECT_STREQ(output.substr(0,16).c_str(), "Total wall time:");
}
TEST(fortran_open, with_args) {
::testing::internal::CaptureStdout();
void *handle = f_lammps_open_with_args();
std::string output = ::testing::internal::GetCapturedStdout();
EXPECT_STREQ(output.substr(0,6).c_str(),"LAMMPS");
LAMMPS_NS::LAMMPS *lmp = (LAMMPS_NS::LAMMPS *)handle;
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);
EXPECT_EQ(lmp->screen, stdout);
EXPECT_EQ(lmp->logfile, nullptr);
EXPECT_EQ(lmp->citeme, nullptr);
::testing::internal::CaptureStdout();
f_lammps_close();
output = ::testing::internal::GetCapturedStdout();
EXPECT_STREQ(output.substr(0,16).c_str(), "Total wall time:");
}