From 5e33f94ace72c01802befcdcf0d07fdcbf0aeaf4 Mon Sep 17 00:00:00 2001 From: mread Date: Tue, 4 Aug 2009 10:05:45 +0100 Subject: deleteing test objects for improved memory leak tracking. added test start parameter for easier tweaking --- .../tst_exceptionsafety_objects.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'tests/auto/exceptionsafety_objects') diff --git a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp index c867899640..c2c06851b3 100644 --- a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp +++ b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp @@ -165,9 +165,9 @@ void tst_ExceptionSafetyObjects::objects_data() // create and destructs an object, and lets each and every allocation // during construction and destruction fail. -static void doOOMTest(AbstractObjectCreator *creator, QObject *parent) +static void doOOMTest(AbstractObjectCreator *creator, QObject *parent, int start=0) { - int currentOOMIndex = 0; + int currentOOMIndex = start; bool caught = false; bool done = false; @@ -278,7 +278,9 @@ void tst_ExceptionSafetyObjects::initTestCase() (void) std::set_new_handler(nh_func); #endif - doOOMTest(new ObjectCreator, 0); + ObjectCreator *selfTest = new ObjectCreator; + doOOMTest(selfTest, 0); + delete selfTest; QCOMPARE(alloc1Failed, 1); QCOMPARE(alloc2Failed, 1); QCOMPARE(alloc3Failed, 2); @@ -292,6 +294,8 @@ void tst_ExceptionSafetyObjects::objects() QFETCH(AbstractObjectCreator *, objectCreator); doOOMTest(objectCreator, 0); + + delete objectCreator; } template @@ -391,10 +395,12 @@ void tst_ExceptionSafetyObjects::widgets() { QFETCH(AbstractObjectCreator *, widgetCreator); - doOOMTest(widgetCreator, 0); + doOOMTest(widgetCreator, 0, 00000); QWidget parent; - doOOMTest(widgetCreator, &parent); + doOOMTest(widgetCreator, &parent, 00000); + + delete widgetCreator; // if the test reaches here without crashing, we passed :) QVERIFY(true); -- cgit v1.2.3