2004-08-28 16:21:25 +00:00
|
|
|
/** @file
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
|
|
|
|
$Date$
|
|
|
|
$Author$
|
|
|
|
|
|
|
|
@copy © Marc Wäckerlin
|
|
|
|
@license LGPL, see file <a href="license.html">COPYING</a>
|
|
|
|
|
|
|
|
$Log$
|
2005-01-28 07:51:24 +00:00
|
|
|
Revision 1.6 2005/01/28 07:51:24 marc
|
|
|
|
improved and corrected trace formatting
|
|
|
|
|
2004-10-13 10:49:12 +00:00
|
|
|
Revision 1.5 2004/10/13 10:49:12 marc
|
|
|
|
check whether shared libraries are evaluated
|
|
|
|
|
2004-08-28 16:21:25 +00:00
|
|
|
Revision 1.4 2004/08/28 16:21:25 marc
|
|
|
|
mrw-c++-0.92 (mrw)
|
|
|
|
- new file: version.cpp
|
|
|
|
- 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
|
|
|
|
|
|
|
|
*/
|
2004-04-21 06:39:20 +00:00
|
|
|
#include <mrw/stacktrace.hpp>
|
|
|
|
#include <cppunit/TestFixture.h>
|
|
|
|
#include <cppunit/ui/text/TestRunner.h>
|
|
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
#include <cppunit/extensions/TestFactoryRegistry.h>
|
|
|
|
|
2004-04-21 19:03:38 +00:00
|
|
|
namespace mrw {
|
|
|
|
class StackTraceTest: public CppUnit::TestFixture {
|
|
|
|
public:
|
|
|
|
/// test if symbols are correctely evaluated
|
|
|
|
void StackTrace() {
|
|
|
|
mrw::StackTrace::createSymtable();
|
|
|
|
mrw::StackTrace s; int l(__LINE__); std::string f(__FILE__);
|
|
|
|
std::stringstream ss;
|
|
|
|
ss<<f<<':'<<l;
|
|
|
|
std::string st(s);
|
2005-01-28 07:51:24 +00:00
|
|
|
std::string::size_type pos(st.find("mrw::StackTraceTest::StackTrace()"));
|
2004-05-05 06:13:29 +00:00
|
|
|
CPPUNIT_ASSERT(pos!=std::string::npos);
|
2005-01-28 07:51:24 +00:00
|
|
|
CPPUNIT_ASSERT(st.find(ss.str(), pos) < st.size());
|
2004-10-13 10:49:12 +00:00
|
|
|
CPPUNIT_ASSERT(st.find("CppUnit::TestCase::run")
|
|
|
|
< st.size());
|
|
|
|
CPPUNIT_ASSERT(st.find("????:0 ????")
|
|
|
|
>= st.size());
|
2004-04-21 19:03:38 +00:00
|
|
|
}
|
|
|
|
CPPUNIT_TEST_SUITE(StackTraceTest);
|
|
|
|
CPPUNIT_TEST(StackTrace);
|
|
|
|
CPPUNIT_TEST_SUITE_END();
|
|
|
|
};
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION(StackTraceTest);
|
|
|
|
}
|
2004-04-21 06:39:20 +00:00
|
|
|
|
|
|
|
int main() {
|
|
|
|
CppUnit::TextUi::TestRunner runner;
|
|
|
|
runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
|
|
|
|
return runner.run() ? 0 : 1;
|
|
|
|
}
|