avoid global namespace import in header, more consistency

This commit is contained in:
Axel Kohlmeyer 2022-08-28 17:22:26 -04:00
parent 634496b509
commit bb6ea422b7
No known key found for this signature in database
GPG Key ID: D9B44E93BF0C375A
19 changed files with 50 additions and 63 deletions

View File

@ -26,8 +26,6 @@
// whether to print verbose output (i.e. not capturing LAMMPS screen output).
bool verbose = false;
using LAMMPS_NS::utils::split_words;
namespace LAMMPS_NS {
#define STRINGIFY(val) XSTR(val)
@ -296,7 +294,6 @@ TEST_F(ComputeGlobalTest, Reduction)
EXPECT_DOUBLE_EQ(rep[2], 26);
EXPECT_DOUBLE_EQ(rep[3], max[0]);
}
} // namespace LAMMPS_NS
int main(int argc, char **argv)
@ -304,12 +301,12 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv);
if (platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
if (LAMMPS_NS::platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
std::cout << "Warning: using OpenMPI without exceptions. Death tests will be skipped\n";
// handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = split_words(var);
std::vector<std::string> env = LAMMPS_NS::utils::split_words(var);
for (auto arg : env) {
if (arg == "-v") {
verbose = true;

View File

@ -31,9 +31,6 @@
// whether to print verbose output (i.e. not capturing LAMMPS screen output).
bool verbose = false;
using LAMMPS_NS::MathConst::MY_PI;
using LAMMPS_NS::utils::split_words;
namespace LAMMPS_NS {
using ::testing::ContainsRegex;
using ::testing::ExitedWithCode;
@ -164,12 +161,12 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv);
if (platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
if (LAMMPS_NS::platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
std::cout << "Warning: using OpenMPI without exceptions. Death tests will be skipped\n";
// handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = split_words(var);
std::vector<std::string> env = LAMMPS_NS::utils::split_words(var);
for (auto arg : env) {
if (arg == "-v") {
verbose = true;

View File

@ -316,12 +316,12 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv);
if (platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
if (LAMMPS_NS::platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
std::cout << "Warning: using OpenMPI without exceptions. Death tests will be skipped\n";
// handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = split_words(var);
std::vector<std::string> env = LAMMPS_NS::utils::split_words(var);
for (auto arg : env) {
if (arg == "-v") {
verbose = true;

View File

@ -683,12 +683,12 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv);
if (platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
if (LAMMPS_NS::platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
std::cout << "Warning: using OpenMPI without exceptions. Death tests will be skipped\n";
// handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = split_words(var);
std::vector<std::string> env = LAMMPS_NS::utils::split_words(var);
for (auto arg : env) {
if (arg == "-v") {
verbose = true;

View File

@ -32,8 +32,6 @@
// whether to print verbose output (i.e. not capturing LAMMPS screen output).
bool verbose = false;
using LAMMPS_NS::utils::split_words;
namespace LAMMPS_NS {
using ::testing::ContainsRegex;
using ::testing::ExitedWithCode;
@ -634,12 +632,12 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv);
if (platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
if (LAMMPS_NS::platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
std::cout << "Warning: using OpenMPI without exceptions. Death tests will be skipped\n";
// handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = split_words(var);
std::vector<std::string> env = LAMMPS_NS::utils::split_words(var);
for (auto arg : env) {
if (arg == "-v") {
verbose = true;

View File

@ -30,8 +30,6 @@
// whether to print verbose output (i.e. not capturing LAMMPS screen output).
bool verbose = false;
using LAMMPS_NS::utils::split_words;
namespace LAMMPS_NS {
using ::testing::ExitedWithCode;
using ::testing::StrEq;
@ -279,12 +277,12 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv);
if (platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
if (LAMMPS_NS::platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
std::cout << "Warning: using OpenMPI without exceptions. Death tests will be skipped\n";
// handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = split_words(var);
std::vector<std::string> env = LAMMPS_NS::utils::split_words(var);
for (auto arg : env) {
if (arg == "-v") {
verbose = true;

View File

@ -29,8 +29,6 @@
// whether to print verbose output (i.e. not capturing LAMMPS screen output).
bool verbose = false;
using LAMMPS_NS::utils::split_words;
namespace LAMMPS_NS {
#define GETIDX(i) lmp->atom->map(i)
@ -677,7 +675,6 @@ TEST_F(ResetMolIDsTest, FailOnlyMolecular)
END_HIDE_OUTPUT();
TEST_FAILURE(".*ERROR: Can only use reset_mol_ids.*", command("reset_mol_ids all"););
}
} // namespace LAMMPS_NS
int main(int argc, char **argv)
@ -685,12 +682,12 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv);
if (platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
if (LAMMPS_NS::platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
std::cout << "Warning: using OpenMPI without exceptions. Death tests will be skipped\n";
// handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = split_words(var);
std::vector<std::string> env = LAMMPS_NS::utils::split_words(var);
for (auto arg : env) {
if (arg == "-v") {
verbose = true;

View File

@ -25,14 +25,11 @@
// whether to print verbose output (i.e. not capturing LAMMPS screen output).
bool verbose = false;
using LAMMPS_NS::MathConst::MY_PI;
using LAMMPS_NS::utils::split_words;
namespace LAMMPS_NS {
using ::testing::ContainsRegex;
using ::testing::ExitedWithCode;
using ::testing::StrEq;
namespace LAMMPS_NS {
class SetTest : public LAMMPSTest {
protected:
Atom *atom;
@ -172,12 +169,12 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv);
if (platform::mpi_vendor() == "Open MPI" && !LAMMPS_NS::Info::has_exceptions())
if (LAMMPS_NS::platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
std::cout << "Warning: using OpenMPI without exceptions. Death tests will be skipped\n";
// handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = split_words(var);
std::vector<std::string> env = LAMMPS_NS::utils::split_words(var);
for (auto arg : env) {
if (arg == "-v") {
verbose = true;

View File

@ -36,8 +36,6 @@
// whether to print verbose output (i.e. not capturing LAMMPS screen output).
bool verbose = false;
using LAMMPS_NS::utils::split_words;
namespace LAMMPS_NS {
using ::testing::ContainsRegex;
using ::testing::ExitedWithCode;
@ -552,12 +550,12 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv);
if (platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
if (LAMMPS_NS::platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
std::cout << "Warning: using OpenMPI without exceptions. Death tests will be skipped\n";
// handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = split_words(var);
std::vector<std::string> env = LAMMPS_NS::utils::split_words(var);
for (auto arg : env) {
if (arg == "-v") {
verbose = true;

View File

@ -32,13 +32,11 @@
// whether to print verbose output (i.e. not capturing LAMMPS screen output).
bool verbose = false;
using LAMMPS_NS::MathConst::MY_PI;
using LAMMPS_NS::utils::split_words;
namespace LAMMPS_NS {
using ::testing::ContainsRegex;
using ::testing::ExitedWithCode;
using ::testing::StrEq;
using MathConst::MY_PI;
class VariableTest : public LAMMPSTest {
protected:
@ -585,12 +583,12 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv);
if (platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
if (LAMMPS_NS::platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
std::cout << "Warning: using OpenMPI without exceptions. Death tests will be skipped\n";
// handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = split_words(var);
std::vector<std::string> env = LAMMPS_NS::utils::split_words(var);
for (auto arg : env) {
if (arg == "-v") {
verbose = true;

View File

@ -16,7 +16,6 @@
bool verbose = false;
namespace LAMMPS_NS {
class Advanced_utils : public LAMMPSTest {
protected:
Error *error;
@ -218,7 +217,6 @@ TEST_F(Advanced_utils, expand_args)
delete[] args[i];
delete[] args;
}
} // namespace LAMMPS_NS
int main(int argc, char **argv)
@ -226,12 +224,12 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv);
if (platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
if (LAMMPS_NS::platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
std::cout << "Warning: using OpenMPI without exceptions. Death tests will be skipped\n";
// handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = utils::split_words(var);
std::vector<std::string> env = LAMMPS_NS::utils::split_words(var);
for (auto arg : env) {
if (arg == "-v") {
verbose = true;

View File

@ -16,9 +16,7 @@
bool verbose = false;
namespace LAMMPS_NS {
using ::testing::ContainsRegex;
using utils::split_words;
class Error_class : public LAMMPSTest {
protected:
@ -120,7 +118,6 @@ TEST_F(Error_class, all)
{
TEST_FAILURE("ERROR: one error.*test_error_class.cpp:.*", error->all(FLERR, "one error"););
};
} // namespace LAMMPS_NS
int main(int argc, char **argv)
@ -128,12 +125,12 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv);
if (platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
if (LAMMPS_NS::platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
std::cout << "Warning: using OpenMPI without exceptions. Death tests will be skipped\n";
// handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = split_words(var);
std::vector<std::string> env = LAMMPS_NS::utils::split_words(var);
for (auto arg : env) {
if (arg == "-v") {
verbose = true;

View File

@ -50,7 +50,7 @@ int main(int argc, char **argv)
// handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = utils::split_words(var);
std::vector<std::string> env = LAMMPS_NS::utils::split_words(var);
for (auto arg : env) {
if (arg == "-v") {
verbose = true;

View File

@ -28,6 +28,8 @@ using ::testing::Eq;
char *BINARY2TXT_EXECUTABLE = nullptr;
bool verbose = false;
namespace LAMMPS_NS {
class DumpAtomTest : public MeltTest {
std::string dump_style = "atom";
@ -678,6 +680,7 @@ TEST_F(DumpAtomTest, binary_write_dump)
delete_file(reference);
delete_file(dump_file);
}
}
int main(int argc, char **argv)
{
@ -686,7 +689,7 @@ int main(int argc, char **argv)
// handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = utils::split_words(var);
std::vector<std::string> env = LAMMPS_NS::utils::split_words(var);
for (auto arg : env) {
if (arg == "-v") {
verbose = true;

View File

@ -23,6 +23,7 @@ using ::testing::Eq;
bool verbose = false;
namespace LAMMPS_NS {
class DumpCfgTest : public MeltTest {
std::string dump_style = "cfg";
@ -143,6 +144,7 @@ TEST_F(DumpCfgTest, no_unwrap_no_buffer_run0)
ASSERT_THAT(lines[0], Eq("Number of particles = 32"));
delete_file("dump_cfg_no_unwrap_no_buffer_run0.melt.cfg");
}
}
int main(int argc, char **argv)
{
@ -151,7 +153,7 @@ int main(int argc, char **argv)
// handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = utils::split_words(var);
std::vector<std::string> env = LAMMPS_NS::utils::split_words(var);
for (auto arg : env) {
if (arg == "-v") {
verbose = true;

View File

@ -26,6 +26,7 @@ using ::testing::Eq;
char *BINARY2TXT_EXECUTABLE = nullptr;
bool verbose = false;
namespace LAMMPS_NS {
class DumpCustomTest : public MeltTest {
std::string dump_style = "custom";
@ -383,7 +384,7 @@ TEST_F(DumpCustomTest, rerun_bin)
ASSERT_NEAR(pe_2, pe_rerun, 1.0e-14);
delete_file(dump_file);
}
}
int main(int argc, char **argv)
{
MPI_Init(&argc, &argv);
@ -391,7 +392,7 @@ int main(int argc, char **argv)
// handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = utils::split_words(var);
std::vector<std::string> env = LAMMPS_NS::utils::split_words(var);
for (auto arg : env) {
if (arg == "-v") {
verbose = true;

View File

@ -28,6 +28,7 @@ using ::testing::Eq;
char *BINARY2TXT_EXECUTABLE = nullptr;
bool verbose = false;
namespace LAMMPS_NS {
class DumpLocalTest : public MeltTest {
std::string dump_style = "local";
@ -237,6 +238,7 @@ TEST_F(DumpLocalTest, triclinic_run0)
ASSERT_EQ(utils::split_words(lines[7]).size(), 3);
delete_file(dump_file);
}
}
int main(int argc, char **argv)
{
@ -245,7 +247,7 @@ int main(int argc, char **argv)
// handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = utils::split_words(var);
std::vector<std::string> env = LAMMPS_NS::utils::split_words(var);
for (auto arg : env) {
if (arg == "-v") {
verbose = true;

View File

@ -31,6 +31,7 @@ using ::testing::Eq;
char *NCDUMP_EXECUTABLE = nullptr;
bool verbose = false;
namespace LAMMPS_NS {
class DumpNetCDFTest : public MeltTest {
std::string dump_style = "netcdf";
@ -386,6 +387,7 @@ TEST_F(DumpNetCDFTest, run0_mpi)
}
delete_file(dump_file);
}
}
int main(int argc, char **argv)
{
@ -394,7 +396,7 @@ int main(int argc, char **argv)
// handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = utils::split_words(var);
std::vector<std::string> env = LAMMPS_NS::utils::split_words(var);
for (auto arg : env) {
if (arg == "-v") {
verbose = true;

View File

@ -26,7 +26,9 @@
#include <string>
#include <vector>
using namespace LAMMPS_NS;
using LAMMPS_NS::Info;
using LAMMPS_NS::LAMMPS;
using LAMMPS_NS::LAMMPSException;
using ::testing::ContainsRegex;
@ -37,7 +39,7 @@ using ::testing::ContainsRegex;
auto mesg = ::testing::internal::GetCapturedStdout(); \
ASSERT_THAT(mesg, ContainsRegex(errmsg)); \
} else { \
if (platform::mpi_vendor() != "Open MPI") { \
if (LAMMPS_NS::platform::mpi_vendor() != "Open MPI") { \
::testing::internal::CaptureStdout(); \
ASSERT_DEATH({__VA_ARGS__}, ""); \
auto mesg = ::testing::internal::GetCapturedStdout(); \
@ -101,7 +103,7 @@ public:
double get_variable_value(const std::string &name)
{
char *str = utils::strdup(fmt::format("v_{}", name));
char *str = LAMMPS_NS::utils::strdup(fmt::format("v_{}", name));
double value = lmp->input->variable->compute_equal(str);
delete[] str;
return value;
@ -122,9 +124,9 @@ protected:
{
int argc = args.size() + 1;
char **argv = new char *[argc];
argv[0] = utils::strdup(testbinary);
argv[0] = LAMMPS_NS::utils::strdup(testbinary);
for (int i = 1; i < argc; i++) {
argv[i] = utils::strdup(args[i - 1]);
argv[i] = LAMMPS_NS::utils::strdup(args[i - 1]);
}
HIDE_OUTPUT([&] {