On Windows the Regex matcher for '.' does not match '\n'
Thus we have to use ContainsRegex instead of MatchesRegex
This commit is contained in:
@ -40,7 +40,7 @@ using LAMMPS_NS::utils::split_words;
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
using ::testing::ExitedWithCode;
|
||||
using ::testing::MatchesRegex;
|
||||
using ::testing::ContainsRegex;
|
||||
using ::testing::StrEq;
|
||||
|
||||
class SimpleCommandsTest : public LAMMPSTest {
|
||||
@ -394,62 +394,62 @@ TEST_F(SimpleCommandsTest, Plugin)
|
||||
lmp->input->one(fmt::format(loadfmt, "hello"));
|
||||
auto text = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << text;
|
||||
ASSERT_THAT(text, MatchesRegex(".*Loading plugin: Hello world command.*"));
|
||||
ASSERT_THAT(text, ContainsRegex(".*Loading plugin: Hello world command.*"));
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp->input->one(fmt::format(loadfmt, "xxx"));
|
||||
text = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << text;
|
||||
ASSERT_THAT(text, MatchesRegex(".*Open of file .*xxx.* failed.*"));
|
||||
ASSERT_THAT(text, ContainsRegex(".*Open of file .*xxx.* failed.*"));
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp->input->one(fmt::format(loadfmt, "nve2"));
|
||||
text = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << text;
|
||||
ASSERT_THAT(text, MatchesRegex(".*Loading plugin: NVE2 variant fix style.*"));
|
||||
ASSERT_THAT(text, ContainsRegex(".*Loading plugin: NVE2 variant fix style.*"));
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp->input->one("plugin list");
|
||||
text = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << text;
|
||||
ASSERT_THAT(text, MatchesRegex(".*1: command style plugin hello"
|
||||
ASSERT_THAT(text, ContainsRegex(".*1: command style plugin hello"
|
||||
".*2: fix style plugin nve2.*"));
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp->input->one(fmt::format(loadfmt, "hello"));
|
||||
text = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << text;
|
||||
ASSERT_THAT(text, MatchesRegex(".*Ignoring load of command style hello: "
|
||||
ASSERT_THAT(text, ContainsRegex(".*Ignoring load of command style hello: "
|
||||
"must unload existing hello plugin.*"));
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp->input->one("plugin unload command hello");
|
||||
text = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << text;
|
||||
ASSERT_THAT(text, MatchesRegex(".*Unloading command style hello.*"));
|
||||
ASSERT_THAT(text, ContainsRegex(".*Unloading command style hello.*"));
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp->input->one("plugin unload pair nve2");
|
||||
text = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << text;
|
||||
ASSERT_THAT(text, MatchesRegex(".*Ignoring unload of pair style nve2: not from a plugin.*"));
|
||||
ASSERT_THAT(text, ContainsRegex(".*Ignoring unload of pair style nve2: not from a plugin.*"));
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp->input->one("plugin unload fix nve2");
|
||||
text = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << text;
|
||||
ASSERT_THAT(text, MatchesRegex(".*Unloading fix style nve2.*"));
|
||||
ASSERT_THAT(text, ContainsRegex(".*Unloading fix style nve2.*"));
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp->input->one("plugin unload fix nve");
|
||||
text = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << text;
|
||||
ASSERT_THAT(text, MatchesRegex(".*Ignoring unload of fix style nve: not from a plugin.*"));
|
||||
ASSERT_THAT(text, ContainsRegex(".*Ignoring unload of fix style nve: not from a plugin.*"));
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp->input->one("plugin list");
|
||||
text = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << text;
|
||||
ASSERT_THAT(text, MatchesRegex(".*Currently loaded plugins.*"));
|
||||
ASSERT_THAT(text, ContainsRegex(".*Currently loaded plugins.*"));
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -495,8 +495,8 @@ TEST_F(SimpleCommandsTest, CiteMe)
|
||||
std::string text = END_CAPTURE_OUTPUT();
|
||||
|
||||
// find the two unique citations, but not the third
|
||||
ASSERT_THAT(text, MatchesRegex(".*one.*two.*"));
|
||||
ASSERT_THAT(text, Not(MatchesRegex(".*one.*two.*one.*")));
|
||||
ASSERT_THAT(text, ContainsRegex(".*one.*two.*"));
|
||||
ASSERT_THAT(text, Not(ContainsRegex(".*one.*two.*one.*")));
|
||||
|
||||
BEGIN_CAPTURE_OUTPUT();
|
||||
lmp->citeme->add("test citation one:\n 0\n");
|
||||
@ -507,8 +507,8 @@ TEST_F(SimpleCommandsTest, CiteMe)
|
||||
text = END_CAPTURE_OUTPUT();
|
||||
|
||||
// find the forth (only differs in long citation) and sixth added citation
|
||||
ASSERT_THAT(text, MatchesRegex(".*one.*three.*"));
|
||||
ASSERT_THAT(text, Not(MatchesRegex(".*two.*")));
|
||||
ASSERT_THAT(text, ContainsRegex(".*one.*three.*"));
|
||||
ASSERT_THAT(text, Not(ContainsRegex(".*two.*")));
|
||||
|
||||
BEGIN_CAPTURE_OUTPUT();
|
||||
lmp->citeme->add("test citation one:\n 1\n");
|
||||
@ -521,7 +521,7 @@ TEST_F(SimpleCommandsTest, CiteMe)
|
||||
text = END_CAPTURE_OUTPUT();
|
||||
|
||||
// no new citation. no CITE-CITE-CITE- lines
|
||||
ASSERT_THAT(text, Not(MatchesRegex(".*CITE-CITE-CITE-CITE.*")));
|
||||
ASSERT_THAT(text, Not(ContainsRegex(".*CITE-CITE-CITE-CITE.*")));
|
||||
}
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
|
||||
Reference in New Issue
Block a user