Unit teste help
-
I am creating a unit test to test the return a function. How do I test whether the function is returning an object of type QWidget?
@#include "LoadUiTest.hpp"
void LoadUiTest::avalReturn()
{
LoadUi loader;
QString url = "Forms/MainWindow.ui";
QWidget wid_test;
QCOMPARE(wid_test, *loader.createForm(&url));
}
@
unsuccessfully -
Hi,
You can't compare widgets like that. Your createForm function should return NULL if it fails.
On a side note, why are you giving the address of url to createForm ?
-
"isWidgetType()":http://qt-project.org/doc/qt-5/qobject.html#isWidgetType "Returns true if the object is a widget; otherwise returns false."
-
Worked with:
@void LoadUiTest::avalReturn()
{
LoadUi loader;
QString url = "Forms/MainWindow.ui";
QVERIFY(loader.createForm(&url)->isWidgetType());
}
@SGaist, I created a class to generate forms with QUiLoader. url is the location of the ui file
Thanks people.
-
That I understood, the question is why use a pointer to a QString ? It's as implicitly shared class, you should rather pass a const reference.