From 2a8cc331e76b3bc7aaa0275031c45bf2b6b14104 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 23 Nov 2020 11:19:27 -0500 Subject: [PATCH] add test for "newton" command to match the c-library interface tests --- unittest/commands/test_simple_commands.cpp | 34 ++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/unittest/commands/test_simple_commands.cpp b/unittest/commands/test_simple_commands.cpp index 7abe5cc957..644f7071ad 100644 --- a/unittest/commands/test_simple_commands.cpp +++ b/unittest/commands/test_simple_commands.cpp @@ -11,13 +11,16 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#include "fmt/format.h" +#include "lammps.h" + +#include "force.h" #include "info.h" #include "input.h" -#include "lammps.h" #include "output.h" #include "update.h" #include "utils.h" + +#include "fmt/format.h" #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -161,6 +164,33 @@ TEST_F(SimpleCommandsTest, Log) TEST_FAILURE(".*ERROR: Illegal log command.*", lmp->input->one("log");); } +TEST_F(SimpleCommandsTest, Newton) +{ + // default setting is "on" for both + ASSERT_EQ(lmp->force->newton_pair, 1); + ASSERT_EQ(lmp->force->newton_bond, 1); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("newton off"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_EQ(lmp->force->newton_pair, 0); + ASSERT_EQ(lmp->force->newton_bond, 0); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("newton on off"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_EQ(lmp->force->newton_pair, 1); + ASSERT_EQ(lmp->force->newton_bond, 0); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("newton off on"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_EQ(lmp->force->newton_pair, 0); + ASSERT_EQ(lmp->force->newton_bond, 1); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("newton on"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_EQ(lmp->force->newton_pair, 1); + ASSERT_EQ(lmp->force->newton_bond, 1); +} + TEST_F(SimpleCommandsTest, Quit) { ::testing::internal::CaptureStdout();