[Development] [autotests] Why the objects are used in 'heap' instead of 'stack'

Denis Shienkov denis.shienkov at gmail.com
Sat Jan 9 15:30:37 CET 2016


Hi all,

Is there are any reasons why the tested objects are created in 'heap' 
instead of 'stack' (in the majority of cases)?

E.g. we can look on 
\qtbase\tests\auto\network\socket\qtcpsocket\tst_qtcpsocket.cpp as example,
where in each test are used the new/delete:

void tst_QTcpSocket::foo()
{
     QTcpSocket *socket = new QTcpSocket;
     // make tests
     delete socket;
}

instead of

void tst_QTcpSocket::foo()
{
     QTcpSocket socket;
    // make tests
}

BR,
Denis




More information about the Development mailing list