@@ -84,6 +84,33 @@ public:
8484 triangulator .smooth_after_generating () = false;
8585 }
8686
87+ void testExceptionBase (MeshBase & mesh ,
88+ TriangulatorInterface & triangulator ,
89+ const char * re )
90+ {
91+ #ifdef LIBMESH_ENABLE_EXCEPTIONS
92+ // We can't just CPPUNIT_ASSERT_THROW, because we want to make
93+ // sure we were thrown from the right place with the right error
94+ // message!
95+ bool threw_desired_exception = false;
96+ try {
97+ this -> testTriangulatorBase (mesh , triangulator );
98+ }
99+ catch (libMesh ::LogicError & e ) {
100+ std ::regex msg_regex (re );
101+ CPPUNIT_ASSERT (std ::regex_search (e .what (), msg_regex ));
102+ threw_desired_exception = true;
103+ }
104+ catch (CppUnit ::Exception & e ) {
105+ throw e ;
106+ }
107+ catch (...) {
108+ CPPUNIT_ASSERT_MESSAGE ("Unexpected exception type thrown" , false);
109+ }
110+ CPPUNIT_ASSERT (threw_desired_exception );
111+ #endif
112+ }
113+
87114 void testTriangleHoleArea ()
88115 {
89116 LOG_UNIT_TEST ;
@@ -561,24 +588,7 @@ public:
561588
562589 mesh .prepare_for_use ();
563590
564- #ifdef LIBMESH_ENABLE_EXCEPTIONS
565- // We can't just CPPUNIT_ASSERT_THROW, because we want to make
566- // sure we were thrown from the right place with the right error
567- // message!
568- bool threw_desired_exception = false;
569- try {
570- this -> testTriangulatorBase (mesh , triangulator );
571- }
572- catch (libMesh ::LogicError & e ) {
573- std ::regex msg_regex ("Bad edge topology" );
574- CPPUNIT_ASSERT (std ::regex_search (e .what (), msg_regex ));
575- threw_desired_exception = true;
576- }
577- catch (...) {
578- CPPUNIT_ASSERT_MESSAGE ("Unexpected exception type thrown" , false);
579- }
580- CPPUNIT_ASSERT (threw_desired_exception );
581- #endif
591+ testExceptionBase (mesh , triangulator , "Bad edge topology" );
582592 }
583593
584594
@@ -620,24 +630,7 @@ public:
620630
621631 mesh .prepare_for_use ();
622632
623- #ifdef LIBMESH_ENABLE_EXCEPTIONS
624- // We can't just CPPUNIT_ASSERT_THROW, because we want to make
625- // sure we were thrown from the right place with the right error
626- // message!
627- bool threw_desired_exception = false;
628- try {
629- this -> testTriangulatorBase (mesh , triangulator );
630- }
631- catch (libMesh ::LogicError & e ) {
632- std ::regex msg_regex ("multiple loops of Edge" );
633- CPPUNIT_ASSERT (std ::regex_search (e .what (), msg_regex ));
634- threw_desired_exception = true;
635- }
636- catch (...) {
637- CPPUNIT_ASSERT_MESSAGE ("Unexpected exception type thrown" , false);
638- }
639- CPPUNIT_ASSERT (threw_desired_exception );
640- #endif
633+ testExceptionBase (mesh , triangulator , "multiple loops of Edge" );
641634 }
642635
643636 void testPoly2TriBad2DMultiBoundary ()
@@ -667,27 +660,7 @@ public:
667660
668661 mesh .prepare_for_use ();
669662
670- #ifdef LIBMESH_ENABLE_EXCEPTIONS
671- // We can't just CPPUNIT_ASSERT_THROW, because we want to make
672- // sure we were thrown from the right place with the right error
673- // message!
674- bool threw_desired_exception = false;
675- try {
676- this -> testTriangulatorBase (mesh , triangulator );
677- }
678- catch (libMesh ::LogicError & e ) {
679- std ::regex msg_regex ("cannot choose one" );
680- CPPUNIT_ASSERT (std ::regex_search (e .what (), msg_regex ));
681- threw_desired_exception = true;
682- }
683- catch (CppUnit ::Exception & e ) {
684- throw e ;
685- }
686- catch (...) {
687- CPPUNIT_ASSERT_MESSAGE ("Unexpected exception type thrown" , false);
688- }
689- CPPUNIT_ASSERT (threw_desired_exception );
690- #endif
663+ testExceptionBase (mesh , triangulator , "cannot choose one" );
691664 }
692665
693666
0 commit comments