Use HasSubstr since output order is dependent on buffering

This commit is contained in:
Richard Berger 2021-03-23 20:13:39 -04:00
parent 359a369573
commit 23c8d8ccfb
No known key found for this signature in database
GPG Key ID: A9E83994E0BA0CAB
1 changed files with 4 additions and 3 deletions

View File

@ -34,6 +34,7 @@ using LAMMPS_NS::utils::split_words;
namespace LAMMPS_NS {
using ::testing::MatchesRegex;
using ::testing::StrEq;
using ::testing::HasSubstr;
class PythonPackageTest : public ::testing::Test {
protected:
@ -86,7 +87,7 @@ TEST_F(PythonPackageTest, python_invoke)
command("python printnum invoke");
std::string output = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << output;
ASSERT_THAT(output, MatchesRegex("python.*2.25.*"));
ASSERT_THAT(output, HasSubstr("2.25\n"));
// execute another python function from same file
if (!verbose) ::testing::internal::CaptureStdout();
@ -96,7 +97,7 @@ TEST_F(PythonPackageTest, python_invoke)
command("python printtxt invoke");
output = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << output;
ASSERT_THAT(output, MatchesRegex("python.*sometext.*"));
ASSERT_THAT(output, HasSubstr("sometext\n"));
// execute python function that uses the LAMMPS python module
if (!verbose) ::testing::internal::CaptureStdout();
@ -107,7 +108,7 @@ TEST_F(PythonPackageTest, python_invoke)
command("python getidxvar invoke");
output = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << output;
ASSERT_THAT(output, MatchesRegex("python.*2.25.*"));
ASSERT_THAT(output, HasSubstr("2.25\n"));
}
TEST_F(PythonPackageTest, python_variable)