[cig-commits] r18453 - cs/spatialdata/trunk/tests/libtests/units

brad at geodynamics.org brad at geodynamics.org
Tue May 24 14:50:22 PDT 2011


Author: brad
Date: 2011-05-24 14:50:21 -0700 (Tue, 24 May 2011)
New Revision: 18453

Modified:
   cs/spatialdata/trunk/tests/libtests/units/TestParser.cc
Log:
Switch to use of macro for testing throw of exception.

Modified: cs/spatialdata/trunk/tests/libtests/units/TestParser.cc
===================================================================
--- cs/spatialdata/trunk/tests/libtests/units/TestParser.cc	2011-05-24 21:49:26 UTC (rev 18452)
+++ cs/spatialdata/trunk/tests/libtests/units/TestParser.cc	2011-05-24 21:50:21 UTC (rev 18453)
@@ -20,6 +20,8 @@
 
 #include "spatialdata/units/Parser.hh" // USES Parser
 
+#include <stdexcept> // USES std::runtime_error
+
 // ----------------------------------------------------------------------
 CPPUNIT_TEST_SUITE_REGISTRATION( spatialdata::units::TestParser );
 
@@ -107,14 +109,7 @@
 { // testError
   Parser parser;
 
-  bool caught = false;
-  try {
-    parser.parse("abc");
-  } catch (const std::exception& err) {
-    caught = true; // assume caught correct error
-  } // try/catch
-
-  CPPUNIT_ASSERT(caught);
+  CPPUNIT_ASSERT_THROW(parser.parse("abc"), std::runtime_error);
 } // testError
 
 



More information about the CIG-COMMITS mailing list