From c420f804d96e78a5d92db7ad56e33e8f2bf4f49c Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 29 Jan 2022 18:52:49 -0500 Subject: [PATCH] make multi-line regex checks compatible with googletests Windows regex syntax --- unittest/formats/test_molecule_file.cpp | 27 ++++++++++++++----------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/unittest/formats/test_molecule_file.cpp b/unittest/formats/test_molecule_file.cpp index b67ed746b9..0fe66e22c5 100644 --- a/unittest/formats/test_molecule_file.cpp +++ b/unittest/formats/test_molecule_file.cpp @@ -173,7 +173,8 @@ TEST_F(MoleculeFileTest, minimal) BEGIN_CAPTURE_OUTPUT(); 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(); - 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) @@ -184,7 +185,8 @@ TEST_F(MoleculeFileTest, notype) 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"); 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.*", 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" " 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(); - ASSERT_THAT(output, ContainsRegex(".*Read molecule template.*2 molecules.*2 atoms " - "with max type 2.*0 bonds.*")); + ASSERT_THAT(output, ContainsRegex(".*Read molecule template.*\n.*2 molecules.*\n" + ".*2 atoms with max type 2.*\n.*0 bonds.*")); } TEST_F(MoleculeFileTest, twofiles) @@ -220,12 +222,12 @@ TEST_F(MoleculeFileTest, twofiles) BEGIN_CAPTURE_OUTPUT(); command("molecule twomols moltest.h2o.mol moltest.co2.mol offset 2 1 1 0 0"); auto output = END_CAPTURE_OUTPUT(); - ASSERT_THAT(output, ContainsRegex(".*Read molecule template twomols:.*1 molecules.*3 atoms " - "with max type 2.*2 bonds with max type 1.*" - "1 angles with max type 1.*0 dihedrals.*" - ".*Read molecule template twomols:.*1 molecules.*3 atoms " - "with max type 4.*2 bonds with max type 2.*" - "1 angles with max type 2.*0 dihedrals.*")); + ASSERT_THAT(output, ContainsRegex(".*Read molecule template twomols:.*\n.*1 molecules.*\n" + ".*3 atoms with max type 2.*\n.*2 bonds with max type 1.*\n" + ".*1 angles with max type 1.*\n.*0 dihedrals.*\n" + ".*Read molecule template twomols:.*\n.*1 molecules.*\n" + ".*3 atoms with max type 4.*\n.*2 bonds with max type 2.*\n" + ".*1 angles with max type 2.*\n.*0 dihedrals.*")); } TEST_F(MoleculeFileTest, bonds) @@ -254,8 +256,9 @@ TEST_F(MoleculeFileTest, bonds) " 1 1 1 2\n" " 2 2 1 3\n\n"); auto output = END_CAPTURE_OUTPUT(); - ASSERT_THAT(output, ContainsRegex(".*Read molecule template.*1 molecules.*4 atoms.*type.*2.*" - "2 bonds.*type.*2.*0 angles.*")); + ASSERT_THAT(output, ContainsRegex(".*Read molecule template.*\n.*1 molecules.*\n" + ".*4 atoms.*type.*2.*\n" + ".*2 bonds.*type.*2.*\n.*0 angles.*")); BEGIN_CAPTURE_OUTPUT(); command("mass * 2.0");