upgraded to C++17 compatibility

This commit is contained in:
Marc Wäckerlin
2018-11-21 15:24:07 +00:00
parent 4528cd8d78
commit 80c80e9cc4
50 changed files with 1893 additions and 1231 deletions

View File

@@ -101,7 +101,7 @@ public:
CPPUNIT_ASSERT_THROW(throw, mrw::ExecutionFailedExc);
}
}
void unexpectedExc2() throw(std::bad_exception) {
void unexpectedExc2() {
try {
mrw::PartialExec exec = (mrw::Cmd("/bin/false")).start();
while (!exec.finished()) exec.read();

View File

@@ -26,9 +26,7 @@ if HAVE_LOG4CXX
endif
if HAVE_STACKTRACE
NO_VALGRIND_CHECKS += stacktrace_test
VALGRIND_CHECKS += mrwexcstderr_test
if HAVE_LOG4CXX
VALGRIND_CHECKS += mrwexclog4cxx_test
if AUTOFNTRACE
# @bug Actually, the following test fails; to be repaired, see
#
@@ -140,17 +138,7 @@ if HAVE_STACKTRACE
stacktrace_test_CXXFLAGS = -g3 -O0
stacktrace_test_LDFLAGS = @CPPUNIT_LIBS@ -L${top_builddir}/src
stacktrace_test_LDADD = -lmrw -lmrwexcstderr
mrwexcstderr_test_SOURCES = mrwexcstderr_test.cxx
mrwexcstderr_test_CPPFLAGS = -I ${top_srcdir}/src @CPPUNIT_CFLAGS@ -g3 -O0
mrwexcstderr_test_CXXFLAGS = -g3 -O0
mrwexcstderr_test_LDFLAGS = @CPPUNIT_LIBS@ -L${top_builddir}/src
mrwexcstderr_test_LDADD = -lmrw -lmrwexcstderr
if HAVE_LOG4CXX
mrwexclog4cxx_test_SOURCES = mrwexclog4cxx_test.cxx
mrwexclog4cxx_test_CPPFLAGS = -I ${top_srcdir}/src @CPPUNIT_CFLAGS@ -g3 -O0
mrwexclog4cxx_test_CXXFLAGS = -g3 -O0
mrwexclog4cxx_test_LDFLAGS = @CPPUNIT_LIBS@ -L${top_builddir}/src
mrwexclog4cxx_test_LDADD = -lmrw -lmrwexclog4cxx -llog4cxx
if AUTOFNTRACE
# @bug Actually, the following test fails; to be repaired, see
#
@@ -195,6 +183,6 @@ TESTS = $(check_PROGRAMS) $(dist_check_SCRIPTS)
endif
check_PROGRAMS = $(VALGRIND_CHECKS) $(NO_VALGRIND_CHECKS)
CLEANFILES =
CLEANFILES = ${VALGRIND_CHECKS:%=%.xml} ${NO_VALGRIND_CHECKS:%=%.xml}
DISTCLEANFILES = configfile2.ini
MAINTAINERCLEANFILES = makefile.in

View File

@@ -1,100 +0,0 @@
/** @file
$Id$
$Date$
$Author$
@copy © Marc Wäckerlin
@license LGPL, see file <a href="license.html">COPYING</a>
$Log$
Revision 1.2 2004/08/28 16:21:25 marc
mrw-c++-0.92 (mrw)
- new file: version.cxx
- new file header for all sources
- work around warning in mrw::auto<T>
- possibility to compile without log4cxx
- work around bugs in demangle.h and libiberty.h
- corrections in documentation
- added simple tracing mechanism
- more warnings
- small corrections in Auto<>::Free and a new test for it
- possibility to compile without stack trace
*/
#include <mrw/exception.hxx>
#include <log4cxx/basicconfigurator.h>
#include <cppunit/TestFixture.h>
#include <cppunit/ui/text/TestRunner.h>
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/XmlOutputter.h>
#include <fstream>
namespace mrw {
class AutoExcLog4CxxTest: public CppUnit::TestFixture {
private:
bool enter_unexpectedThrow;
bool exit_unexpectedThrow;
bool enter_passUnexpected;
bool exit_passUnexpected;
bool enter_catchUnexpected;
bool exit_catchUnexpected;
public:
void setUp() {
enter_unexpectedThrow = false;
exit_unexpectedThrow = false;
enter_passUnexpected = false;
exit_passUnexpected = false;
enter_catchUnexpected = false;
exit_catchUnexpected = false;
}
void unexpectedThrow() throw(std::bad_exception) {
enter_unexpectedThrow = true;
throw mrw::exception();
exit_unexpectedThrow = true;
}
void passUnexpected() throw(std::bad_exception) {
enter_passUnexpected = true;
unexpectedThrow();
exit_passUnexpected = true;
}
void catchUnexpected() throw() {
enter_catchUnexpected = true;
bool caught(false);
try {
passUnexpected();
} catch (std::bad_exception&) {
caught = true;
}
CPPUNIT_ASSERT(caught);
exit_catchUnexpected = true;
}
void testcase() {
std::set_unexpected([]{throw std::bad_exception();});
catchUnexpected();
CPPUNIT_ASSERT(enter_catchUnexpected &&
enter_passUnexpected &&
enter_unexpectedThrow &&
exit_catchUnexpected &&
!exit_passUnexpected &&
!exit_unexpectedThrow);
}
CPPUNIT_TEST_SUITE(AutoExcLog4CxxTest);
CPPUNIT_TEST(testcase);
CPPUNIT_TEST_SUITE_END();
};
CPPUNIT_TEST_SUITE_REGISTRATION(AutoExcLog4CxxTest);
}
int main(int argc, char** argv) try {
std::ofstream ofs((*argv+std::string(".xml")).c_str());
CppUnit::TextUi::TestRunner runner;
runner.setOutputter(new CppUnit::XmlOutputter(&runner.result(), ofs));
runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
return runner.run() ? 0 : 1;
} catch (std::exception& e) {
std::cerr<<"***Exception: "<<e.what()<<std::endl;
return 1;
}

View File

@@ -1,99 +0,0 @@
/** @file
$Id$
$Date$
$Author$
@copy &copy; Marc W&auml;ckerlin
@license LGPL, see file <a href="license.html">COPYING</a>
$Log$
Revision 1.2 2004/08/28 16:21:25 marc
mrw-c++-0.92 (mrw)
- new file: version.cxx
- new file header for all sources
- work around warning in mrw::auto<T>
- possibility to compile without log4cxx
- work around bugs in demangle.h and libiberty.h
- corrections in documentation
- added simple tracing mechanism
- more warnings
- small corrections in Auto<>::Free and a new test for it
- possibility to compile without stack trace
*/
#include <mrw/exception.hxx>
#include <cppunit/TestFixture.h>
#include <cppunit/ui/text/TestRunner.h>
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/XmlOutputter.h>
#include <fstream>
namespace mrw {
class AutoExcStderrTest: public CppUnit::TestFixture {
private:
bool enter_unexpectedThrow;
bool exit_unexpectedThrow;
bool enter_passUnexpected;
bool exit_passUnexpected;
bool enter_catchUnexpected;
bool exit_catchUnexpected;
public:
void setUp() {
enter_unexpectedThrow = false;
exit_unexpectedThrow = false;
enter_passUnexpected = false;
exit_passUnexpected = false;
enter_catchUnexpected = false;
exit_catchUnexpected = false;
}
void unexpectedThrow() throw(std::bad_exception) {
enter_unexpectedThrow = true;
throw mrw::exception();
exit_unexpectedThrow = true;
}
void passUnexpected() throw(std::bad_exception) {
enter_passUnexpected = true;
unexpectedThrow();
exit_passUnexpected = true;
}
void catchUnexpected() throw() {
enter_catchUnexpected = true;
bool caught(false);
try {
passUnexpected();
} catch (std::bad_exception&) {
caught = true;
}
CPPUNIT_ASSERT(caught);
exit_catchUnexpected = true;
}
void testcase() {
std::set_unexpected([]{throw std::bad_exception();});
catchUnexpected();
CPPUNIT_ASSERT(enter_catchUnexpected &&
enter_passUnexpected &&
enter_unexpectedThrow &&
exit_catchUnexpected &&
!exit_passUnexpected &&
!exit_unexpectedThrow);
}
CPPUNIT_TEST_SUITE(AutoExcStderrTest);
CPPUNIT_TEST(testcase);
CPPUNIT_TEST_SUITE_END();
};
CPPUNIT_TEST_SUITE_REGISTRATION(AutoExcStderrTest);
}
int main(int argc, char** argv) try {
std::ofstream ofs((*argv+std::string(".xml")).c_str());
CppUnit::TextUi::TestRunner runner;
runner.setOutputter(new CppUnit::XmlOutputter(&runner.result(), ofs));
runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
return runner.run() ? 0 : 1;
} catch (std::exception& e) {
std::cerr<<"***Exception: "<<e.what()<<std::endl;
return 1;
}