make multi-line regex checks compatible with googletests Windows regex syntax

This commit is contained in:
Axel Kohlmeyer
2022-01-29 18:52:49 -05:00
parent cd5d1f8a30
commit c420f804d9

View File

@ -173,7 +173,8 @@ TEST_F(MoleculeFileTest, minimal)
BEGIN_CAPTURE_OUTPUT(); BEGIN_CAPTURE_OUTPUT();
run_mol_cmd(test_name, "", "Comment\n1 atoms\n\n Coords\n\n 1 0.0 0.0 0.0\n"); run_mol_cmd(test_name, "", "Comment\n1 atoms\n\n Coords\n\n 1 0.0 0.0 0.0\n");
auto output = END_CAPTURE_OUTPUT(); auto output = END_CAPTURE_OUTPUT();
ASSERT_THAT(output, ContainsRegex(".*Read molecule template.*1 molecules.*1 atoms.*0 bonds.*")); ASSERT_THAT(output, ContainsRegex(".*Read molecule template.*\n.*1 molecules.*\n"
".*1 atoms.*\n.*0 bonds.*"));
} }
TEST_F(MoleculeFileTest, notype) TEST_F(MoleculeFileTest, notype)
@ -184,7 +185,8 @@ TEST_F(MoleculeFileTest, notype)
command("create_box 1 box"); command("create_box 1 box");
run_mol_cmd(test_name, "", "Comment\n1 atoms\n\n Coords\n\n 1 0.0 0.0 0.0\n"); run_mol_cmd(test_name, "", "Comment\n1 atoms\n\n Coords\n\n 1 0.0 0.0 0.0\n");
auto output = END_CAPTURE_OUTPUT(); auto output = END_CAPTURE_OUTPUT();
ASSERT_THAT(output, ContainsRegex(".*Read molecule template.*1 molecules.*1 atoms.*0 bonds.*")); ASSERT_THAT(output, ContainsRegex(".*Read molecule template.*\n.*1 molecules.*\n"
".*1 atoms.*\n.*0 bonds.*"));
TEST_FAILURE(".*ERROR: Create_atoms molecule must have atom types.*", TEST_FAILURE(".*ERROR: Create_atoms molecule must have atom types.*",
command("create_atoms 0 single 0.0 0.0 0.0 mol notype 542465");); command("create_atoms 0 single 0.0 0.0 0.0 mol notype 542465"););
} }
@ -211,8 +213,8 @@ TEST_F(MoleculeFileTest, twomols)
" Coords\n\n 1 0.0 0.0 0.0\n 2 0.0 0.0 1.0\n" " Coords\n\n 1 0.0 0.0 0.0\n 2 0.0 0.0 1.0\n"
" Molecules\n\n 1 1\n 2 2\n\n Types\n\n 1 1\n 2 2\n\n"); " Molecules\n\n 1 1\n 2 2\n\n Types\n\n 1 1\n 2 2\n\n");
auto output = END_CAPTURE_OUTPUT(); auto output = END_CAPTURE_OUTPUT();
ASSERT_THAT(output, ContainsRegex(".*Read molecule template.*2 molecules.*2 atoms " ASSERT_THAT(output, ContainsRegex(".*Read molecule template.*\n.*2 molecules.*\n"
"with max type 2.*0 bonds.*")); ".*2 atoms with max type 2.*\n.*0 bonds.*"));
} }
TEST_F(MoleculeFileTest, twofiles) TEST_F(MoleculeFileTest, twofiles)
@ -220,12 +222,12 @@ TEST_F(MoleculeFileTest, twofiles)
BEGIN_CAPTURE_OUTPUT(); BEGIN_CAPTURE_OUTPUT();
command("molecule twomols moltest.h2o.mol moltest.co2.mol offset 2 1 1 0 0"); command("molecule twomols moltest.h2o.mol moltest.co2.mol offset 2 1 1 0 0");
auto output = END_CAPTURE_OUTPUT(); auto output = END_CAPTURE_OUTPUT();
ASSERT_THAT(output, ContainsRegex(".*Read molecule template twomols:.*1 molecules.*3 atoms " ASSERT_THAT(output, ContainsRegex(".*Read molecule template twomols:.*\n.*1 molecules.*\n"
"with max type 2.*2 bonds with max type 1.*" ".*3 atoms with max type 2.*\n.*2 bonds with max type 1.*\n"
"1 angles with max type 1.*0 dihedrals.*" ".*1 angles with max type 1.*\n.*0 dihedrals.*\n"
".*Read molecule template twomols:.*1 molecules.*3 atoms " ".*Read molecule template twomols:.*\n.*1 molecules.*\n"
"with max type 4.*2 bonds with max type 2.*" ".*3 atoms with max type 4.*\n.*2 bonds with max type 2.*\n"
"1 angles with max type 2.*0 dihedrals.*")); ".*1 angles with max type 2.*\n.*0 dihedrals.*"));
} }
TEST_F(MoleculeFileTest, bonds) TEST_F(MoleculeFileTest, bonds)
@ -254,8 +256,9 @@ TEST_F(MoleculeFileTest, bonds)
" 1 1 1 2\n" " 1 1 1 2\n"
" 2 2 1 3\n\n"); " 2 2 1 3\n\n");
auto output = END_CAPTURE_OUTPUT(); auto output = END_CAPTURE_OUTPUT();
ASSERT_THAT(output, ContainsRegex(".*Read molecule template.*1 molecules.*4 atoms.*type.*2.*" ASSERT_THAT(output, ContainsRegex(".*Read molecule template.*\n.*1 molecules.*\n"
"2 bonds.*type.*2.*0 angles.*")); ".*4 atoms.*type.*2.*\n"
".*2 bonds.*type.*2.*\n.*0 angles.*"));
BEGIN_CAPTURE_OUTPUT(); BEGIN_CAPTURE_OUTPUT();
command("mass * 2.0"); command("mass * 2.0");