X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FException.test.cc;h=9a29f71301cb8114b26e5b63bd55c81ed8d690fb;hb=8ec0b7ed2df36144b52df5aa40497fc5409c31f7;hp=314cc41eafb4e9c278b867ec6a2b133784aacf54;hpb=d6abda313f70c8a849c5e3f3bbfc12ce301789f1;p=senf.git diff --git a/Utils/Exception.test.cc b/Utils/Exception.test.cc index 314cc41..9a29f71 100644 --- a/Utils/Exception.test.cc +++ b/Utils/Exception.test.cc @@ -1,8 +1,8 @@ // $Id$ // -// Copyright (C) 2007 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) +// Copyright (C) 2007 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY // Stefan Bund // // This program is free software; you can redistribute it and/or modify @@ -31,12 +31,33 @@ #include "../Utils/auto_unit_test.hh" #include +#include +#include #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// BOOST_AUTO_UNIT_TEST(errnoException) -{} +{ + try { + try { + throw senf::SystemException("::open()", ENOENT) << "\nmore"; + } + catch(senf::Exception & e) { + e << "\nx=" << 1 << boost::format("\ny=%d") % 2; + throw; + } + } + catch (senf::SystemException & e) { + BOOST_CHECK_EQUAL( e.errorNumber(), ENOENT ); + 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" ); + } +} ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_