Utils: Add backtrace to exception message in SENF_DEBUG builds
[senf.git] / Utils / Exception.test.cc
index 5b2b95f..9a29f71 100644 (file)
@@ -41,7 +41,7 @@ BOOST_AUTO_UNIT_TEST(errnoException)
 {
     try {
         try {
-            throw senf::SystemException("::open()", ENOENT);
+            throw senf::SystemException("::open()", ENOENT) << "\nmore";
         }
         catch(senf::Exception & e) {
             e << "\nx=" << 1 << boost::format("\ny=%d") % 2;
@@ -50,7 +50,12 @@ BOOST_AUTO_UNIT_TEST(errnoException)
     }
     catch (senf::SystemException & e) {
         BOOST_CHECK_EQUAL( e.errorNumber(), ENOENT );
-        BOOST_CHECK_EQUAL( e.what(), "::open(): (2) No such file or directory\nx=1\ny=2" );
+        BOOST_CHECK_EQUAL( e.errorString(), "No such file or directory" );
+        std::string what (e.what());
+        std::string::size_type pos (what.find("-- \n"));
+        if (pos != std::string::npos)
+            what = std::string(what, pos+4);
+        BOOST_CHECK_EQUAL( what, "[No such file or directory] ::open()\nmore\nx=1\ny=2" );
     }
 }