Fix assertions in Release.

Do not catch all exception in main.
This commit is contained in:
vng 2011-05-29 20:30:46 +03:00 committed by Alex Zolotarev
parent 5db477d1f2
commit d226b5726d
4 changed files with 34 additions and 10 deletions

View file

@ -1,8 +1,11 @@
#include "SRC_FIRST.hpp"
#include "assert.hpp"
#include "../std/target_os.hpp"
#include "../std/iostream.hpp"
#include <cassert>
#include <exception>
#ifdef OMIM_OS_BADA
#include <FBaseSys.h>
@ -15,10 +18,17 @@ namespace my
#ifdef OMIM_OS_BADA
AppLog("ASSERT FAILED%s:%d:%s", srcPoint.FileName(), srcPoint.Line(), msg.c_str());
AppAssert(false);
#else
std::cerr << "ASSERT FAILED\n" << srcPoint.FileName() << ":" << srcPoint.Line() << "\n"
<< msg << endl;
#ifdef DEBUG
assert(false);
#else
throw std::exception(msg.c_str());
#endif
#endif
}

View file

@ -0,0 +1,20 @@
#include "../../base/SRC_FIRST.hpp"
#include "../../testing/testing.hpp"
#include "../../base/base.hpp"
UNIT_TEST(Assert_Smoke)
{
int x = 5;
ASSERT_EQUAL ( x, 5, () );
ASSERT_NOT_EQUAL ( x, 6, () );
//ASSERT_EQUAL ( x, 666, ("Skip this to continue test") );
}
UNIT_TEST(Check_Smoke)
{
int x = 5;
CHECK_EQUAL ( x, 5, () );
CHECK_NOT_EQUAL ( x, 6, () );
//CHECK_EQUAL ( x, 666, ("Skip this to continue test") );
}

View file

@ -29,5 +29,6 @@ SOURCES += \
matrix_test.cpp \
commands_queue_test.cpp \
buffer_vector_test.cpp \
assert_test.cpp \
HEADERS +=

View file

@ -98,21 +98,15 @@ int main(int argc, char *argv[])
eulaAccepted = (eulaDialog.exec() == 1);
Settings::Set(SETTING_EULA_ACCEPTED, eulaAccepted);
}
int returnCode = -1;
if (eulaAccepted)
if (eulaAccepted) // User has accepted EULA
{
// User has accepted EULA
qt::MainWindow w;
w.show();
try {
returnCode = a.exec();
} catch (std::exception const & e)
{
LOG(LERROR, (e.what()));
}
}
// QTBUG: Fix memory leaks. Nobody delete created plugins.
//#ifdef OMIM_OS_WINDOWS
// QFactoryLoader * arr[] = { imageLoader(), bearerLoader() };
@ -126,6 +120,5 @@ int main(int argc, char *argv[])
//#endif
LOG(LINFO, ("MapsWithMe finished with code : ", returnCode));
return returnCode;
}