From 832574066399cd9e38c91b9d1e9f8dd05ec96bd2 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 11 Mar 2021 06:46:53 -0500 Subject: [PATCH] add test for partition command --- unittest/commands/test_simple_commands.cpp | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/unittest/commands/test_simple_commands.cpp b/unittest/commands/test_simple_commands.cpp index 4fce58c668..5fdc1e912b 100644 --- a/unittest/commands/test_simple_commands.cpp +++ b/unittest/commands/test_simple_commands.cpp @@ -192,6 +192,29 @@ TEST_F(SimpleCommandsTest, Newton) ASSERT_EQ(lmp->force->newton_bond, 1); } +TEST_F(SimpleCommandsTest, Partition) +{ + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("echo none"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + TEST_FAILURE(".*ERROR: Illegal partition command .*", + lmp->input->one("partition xxx 1 echo none");); + TEST_FAILURE(".*ERROR: Numeric index 2 is out of bounds.*", + lmp->input->one("partition yes 2 echo none");); + + ::testing::internal::CaptureStdout(); + lmp->input->one("partition yes 1 print 'test'"); + auto text = ::testing::internal::GetCapturedStdout(); + if (verbose) std::cout << text; + ASSERT_THAT(text, StrEq("test\n")); + + ::testing::internal::CaptureStdout(); + lmp->input->one("partition no 1 print 'test'"); + text = ::testing::internal::GetCapturedStdout(); + if (verbose) std::cout << text; + ASSERT_THAT(text, StrEq("")); +} + TEST_F(SimpleCommandsTest, Quit) { ::testing::internal::CaptureStdout();