Fix various trivial formatting issues.

Change-Id: Ifa2a2dd2aa26dab178ec1334376db42fc3ebb355
Reviewed-on: http://codereview.qt.nokia.com/4029
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
This commit is contained in:
Jason McDonald 2011-09-01 14:24:53 +10:00 committed by Qt by Nokia
parent d90da5d991
commit 9c51bd4fc8
19 changed files with 96 additions and 101 deletions

View File

@ -119,7 +119,6 @@ QBenchmarkTestMethodData *QBenchmarkTestMethodData::current;
QBenchmarkTestMethodData::QBenchmarkTestMethodData() QBenchmarkTestMethodData::QBenchmarkTestMethodData()
:resultAccepted(false), runOnce(false), iterationCount(-1) :resultAccepted(false), runOnce(false), iterationCount(-1)
{ {
} }
QBenchmarkTestMethodData::~QBenchmarkTestMethodData() QBenchmarkTestMethodData::~QBenchmarkTestMethodData()
@ -134,7 +133,6 @@ void QBenchmarkTestMethodData::beginDataRun()
void QBenchmarkTestMethodData::endDataRun() void QBenchmarkTestMethodData::endDataRun()
{ {
} }
int QBenchmarkTestMethodData::adjustIterationCount(int suggestion) int QBenchmarkTestMethodData::adjustIterationCount(int suggestion)

View File

@ -50,9 +50,9 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Test) QT_MODULE(Test)
#define QTEST_ASSERT(cond) do {if(!(cond))qt_assert(#cond,__FILE__,__LINE__);} while (0) #define QTEST_ASSERT(cond) do { if (!(cond)) qt_assert(#cond,__FILE__,__LINE__); } while (0)
#define QTEST_ASSERT_X(cond, where, what) do {if(!(cond))qt_assert_x(where, what,__FILE__,__LINE__);} while (0) #define QTEST_ASSERT_X(cond, where, what) do { if (!(cond)) qt_assert_x(where, what,__FILE__,__LINE__); } while (0)
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -1059,7 +1059,7 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
qPrintTestSlots(stdout); qPrintTestSlots(stdout);
exit(0); exit(0);
} }
} else if(strcmp(argv[i], "-xunitxml") == 0){ } else if (strcmp(argv[i], "-xunitxml") == 0) {
QTestLog::setLogMode(QTestLog::XunitXML); QTestLog::setLogMode(QTestLog::XunitXML);
} else if (strcmp(argv[i], "-xml") == 0) { } else if (strcmp(argv[i], "-xml") == 0) {
QTestLog::setLogMode(QTestLog::XML); QTestLog::setLogMode(QTestLog::XML);
@ -1189,7 +1189,7 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
// we load the QML files. So just store the data for now. // we load the QML files. So just store the data for now.
int colon = -1; int colon = -1;
int offset; int offset;
for(offset = 0; *(argv[i]+offset); ++offset) { for (offset = 0; *(argv[i]+offset); ++offset) {
if (*(argv[i]+offset) == ':') { if (*(argv[i]+offset) == ':') {
if (*(argv[i]+offset+1) == ':') { if (*(argv[i]+offset+1) == ':') {
// "::" is used as a test name separator. // "::" is used as a test name separator.
@ -1218,13 +1218,13 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
int colon = -1; int colon = -1;
char buf[512], *data=0; char buf[512], *data=0;
int off; int off;
for(off = 0; *(argv[i]+off); ++off) { for (off = 0; *(argv[i]+off); ++off) {
if (*(argv[i]+off) == ':') { if (*(argv[i]+off) == ':') {
colon = off; colon = off;
break; break;
} }
} }
if(colon != -1) { if (colon != -1) {
data = qstrdup(argv[i]+colon+1); data = qstrdup(argv[i]+colon+1);
} }
QTest::qt_snprintf(buf, qMin(512, off + 1), "%s", argv[i]); // copy text before the ':' into buf QTest::qt_snprintf(buf, qMin(512, off + 1), "%s", argv[i]); // copy text before the ':' into buf
@ -1425,7 +1425,7 @@ static bool qInvokeTestMethod(const char *slotName, const char *data=0)
if (data && !foundFunction) { if (data && !foundFunction) {
fprintf(stderr, "Unknown testdata for function %s: '%s'\n", slotName, data); fprintf(stderr, "Unknown testdata for function %s: '%s'\n", slotName, data);
fprintf(stderr, "Available testdata:\n"); fprintf(stderr, "Available testdata:\n");
for(int i = 0; i < table.dataCount(); ++i) for (int i = 0; i < table.dataCount(); ++i)
fprintf(stderr, "%s\n", table.testData(i)->dataTag()); fprintf(stderr, "%s\n", table.testData(i)->dataTag());
return false; return false;
} }
@ -1476,7 +1476,7 @@ void *fetchData(QTestData *data, const char *tagName, int typeId)
*/ */
char *toHexRepresentation(const char *ba, int length) char *toHexRepresentation(const char *ba, int length)
{ {
if(length == 0) if (length == 0)
return qstrdup(""); return qstrdup("");
/* We output at maximum about maxLen characters in order to avoid /* We output at maximum about maxLen characters in order to avoid
@ -1490,7 +1490,7 @@ char *toHexRepresentation(const char *ba, int length)
const int len = qMin(maxLen, length); const int len = qMin(maxLen, length);
char *result = 0; char *result = 0;
if(length > maxLen) { if (length > maxLen) {
const int size = len * 3 + 4; const int size = len * 3 + 4;
result = new char[size]; result = new char[size];
@ -1511,7 +1511,7 @@ char *toHexRepresentation(const char *ba, int length)
int i = 0; int i = 0;
int o = 0; int o = 0;
while(true) { while (true) {
const char at = ba[i]; const char at = ba[i];
result[o] = toHex[(at >> 4) & 0x0F]; result[o] = toHex[(at >> 4) & 0x0F];
@ -1520,7 +1520,7 @@ char *toHexRepresentation(const char *ba, int length)
++i; ++i;
++o; ++o;
if(i == len) if (i == len)
break; break;
else { else {
result[o] = ' '; result[o] = ' ';
@ -1549,7 +1549,7 @@ static void qInvokeTestMethods(QObject *testObject)
const bool previousFailed = QTestResult::testFailed(); const bool previousFailed = QTestResult::testFailed();
QTestResult::finishedCurrentTestFunction(); QTestResult::finishedCurrentTestFunction();
if(!QTestResult::skipCurrentTest() && !previousFailed) { if (!QTestResult::skipCurrentTest() && !previousFailed) {
if (QTest::testFuncs) { if (QTest::testFuncs) {
for (int i = 0; i != QTest::testFuncCount; i++) { for (int i = 0; i != QTest::testFuncCount; i++) {
@ -1731,9 +1731,9 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
try { try {
#endif #endif
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
SetErrorMode(SetErrorMode(0) | SEM_NOGPFAULTERRORBOX); SetErrorMode(SetErrorMode(0) | SEM_NOGPFAULTERRORBOX);
#endif #endif
#ifdef Q_WS_MAC #ifdef Q_WS_MAC
// Starting with Qt 4.4, applications launched from the command line // Starting with Qt 4.4, applications launched from the command line
@ -1742,13 +1742,13 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
if (macNeedsActivate) { if (macNeedsActivate) {
ProcessSerialNumber psn = { 0, kCurrentProcess }; ProcessSerialNumber psn = { 0, kCurrentProcess };
SetFrontProcess(&psn); SetFrontProcess(&psn);
# ifdef QT_MAC_USE_COCOA #ifdef QT_MAC_USE_COCOA
IOReturn ok = IOPMAssertionCreate(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, &powerID); IOReturn ok = IOPMAssertionCreate(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, &powerID);
if (ok != kIOReturnSuccess) if (ok != kIOReturnSuccess)
macNeedsActivate = false; // no need to release the assertion on exit. macNeedsActivate = false; // no need to release the assertion on exit.
# else #else
UpdateSystemActivity(1); // Wake the display. UpdateSystemActivity(1); // Wake the display.
# endif #endif
} }
#endif #endif
@ -1810,7 +1810,7 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
throw; throw;
return 1; return 1;
} }
# endif #endif
currentTestObject = 0; currentTestObject = 0;
#ifdef QT_MAC_USE_COCOA #ifdef QT_MAC_USE_COCOA
@ -1843,7 +1843,7 @@ int QTest::qExec(QObject *testObject, const QStringList &arguments)
QVector<QByteArray> args; QVector<QByteArray> args;
args.reserve(argc); args.reserve(argc);
for(int i = 0; i < argc; ++i) for (int i = 0; i < argc; ++i)
{ {
args.append(arguments.at(i).toLocal8Bit().constData()); args.append(arguments.at(i).toLocal8Bit().constData());
argv[i] = args.last().data(); argv[i] = args.last().data();

View File

@ -87,10 +87,7 @@ QTestCoreElement<ElementType>::~QTestCoreElement()
template <class ElementType> template <class ElementType>
void QTestCoreElement<ElementType>::addAttribute(const QTest::AttributeIndex attributeIndex, const char *value) void QTestCoreElement<ElementType>::addAttribute(const QTest::AttributeIndex attributeIndex, const char *value)
{ {
if(attributeIndex == -1) if (attributeIndex == -1 || attribute(attributeIndex))
return;
if (attribute(attributeIndex))
return; return;
QTestElementAttribute *testAttribute = new QTestElementAttribute; QTestElementAttribute *testAttribute = new QTestElementAttribute;
@ -108,7 +105,7 @@ template <class ElementType>
const char *QTestCoreElement<ElementType>::attributeValue(QTest::AttributeIndex index) const const char *QTestCoreElement<ElementType>::attributeValue(QTest::AttributeIndex index) const
{ {
const QTestElementAttribute *attrb = attribute(index); const QTestElementAttribute *attrb = attribute(index);
if(attrb) if (attrb)
return attrb->value(); return attrb->value();
return 0; return 0;
@ -118,7 +115,7 @@ template <class ElementType>
const char *QTestCoreElement<ElementType>::attributeName(QTest::AttributeIndex index) const const char *QTestCoreElement<ElementType>::attributeName(QTest::AttributeIndex index) const
{ {
const QTestElementAttribute *attrb = attribute(index); const QTestElementAttribute *attrb = attribute(index);
if(attrb) if (attrb)
return attrb->name(); return attrb->name();
return 0; return 0;
@ -139,7 +136,7 @@ const char *QTestCoreElement<ElementType>::elementName() const
"system-err" "system-err"
}; };
if(type != QTest::LET_Undefined) if (type != QTest::LET_Undefined)
return xmlElementNames[type]; return xmlElementNames[type];
return 0; return 0;
@ -155,8 +152,8 @@ template <class ElementType>
const QTestElementAttribute *QTestCoreElement<ElementType>::attribute(QTest::AttributeIndex index) const const QTestElementAttribute *QTestCoreElement<ElementType>::attribute(QTest::AttributeIndex index) const
{ {
QTestElementAttribute *iterator = listOfAttributes; QTestElementAttribute *iterator = listOfAttributes;
while(iterator){ while (iterator) {
if(iterator->index() == index) if (iterator->index() == index)
return iterator; return iterator;
iterator = iterator->nextElement(); iterator = iterator->nextElement();

View File

@ -70,8 +70,8 @@ class QTestCoreList
template <class T> template <class T>
QTestCoreList<T>::QTestCoreList() QTestCoreList<T>::QTestCoreList()
:next(0) : next(0)
,prev(0) , prev(0)
{ {
} }
@ -121,7 +121,7 @@ int QTestCoreList<T>::count()
int numOfElements = 0; int numOfElements = 0;
T *it = next; T *it = next;
while(it){ while (it) {
++numOfElements; ++numOfElements;
it = it->nextElement(); it = it->nextElement();
} }

View File

@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE
class QTestDataPrivate class QTestDataPrivate
{ {
public: public:
QTestDataPrivate(): tag(0), parent(0), data(0), dataCount(0) {} QTestDataPrivate() : tag(0), parent(0), data(0), dataCount(0) {}
char *tag; char *tag;
QTestTable *parent; QTestTable *parent;

View File

@ -44,9 +44,9 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
QTestElement::QTestElement(int type) QTestElement::QTestElement(int type)
:QTestCoreElement<QTestElement>(type), : QTestCoreElement<QTestElement>(type)
listOfChildren(0), , listOfChildren(0)
parent(0) , parent(0)
{ {
} }
@ -57,10 +57,10 @@ QTestElement::~QTestElement()
bool QTestElement::addLogElement(QTestElement *element) bool QTestElement::addLogElement(QTestElement *element)
{ {
if(!element) if (!element)
return false; return false;
if(element->elementType() != QTest::LET_Undefined){ if (element->elementType() != QTest::LET_Undefined) {
element->addToList(&listOfChildren); element->addToList(&listOfChildren);
element->setParent(this); element->setParent(this);
return true; return true;

View File

@ -144,7 +144,7 @@ const char *QTestElementAttribute::name() const
"iterations" "iterations"
}; };
if(attributeIndex != QTest::AI_Undefined) if (attributeIndex != QTest::AI_Undefined)
return AttributeNames[attributeIndex]; return AttributeNames[attributeIndex];
return 0; return 0;
@ -162,7 +162,7 @@ bool QTestElementAttribute::isNull() const
bool QTestElementAttribute::setPair(QTest::AttributeIndex index, const char *value) bool QTestElementAttribute::setPair(QTest::AttributeIndex index, const char *value)
{ {
if(!value) if (!value)
return false; return false;
delete[] attributeValue; delete[] attributeValue;

View File

@ -75,7 +75,7 @@ namespace QTest
if (delay == -1 || delay < defaultKeyDelay()) if (delay == -1 || delay < defaultKeyDelay())
delay = defaultKeyDelay(); delay = defaultKeyDelay();
if(delay > 0) if (delay > 0)
QTest::qWait(delay); QTest::qWait(delay);
QKeyEvent a(press ? QEvent::KeyPress : QEvent::KeyRelease, code, modifier, text, repeat); QKeyEvent a(press ? QEvent::KeyPress : QEvent::KeyRelease, code, modifier, text, repeat);

View File

@ -76,7 +76,7 @@ namespace QTest
if (delay == -1 || delay < defaultMouseDelay()) if (delay == -1 || delay < defaultMouseDelay())
delay = defaultMouseDelay(); delay = defaultMouseDelay();
if(delay > 0) if (delay > 0)
QTest::qWait(delay); QTest::qWait(delay);
if (pos.isNull()) if (pos.isNull())

View File

@ -80,7 +80,7 @@ void QTestXunitStreamer::indentForElement(const QTestElement* element, char* buf
void QTestXunitStreamer::formatStart(const QTestElement *element, QTestCharBuffer *formatted) const void QTestXunitStreamer::formatStart(const QTestElement *element, QTestCharBuffer *formatted) const
{ {
if(!element || !formatted ) if (!element || !formatted )
return; return;
char indent[20]; char indent[20];
@ -104,7 +104,7 @@ void QTestXunitStreamer::formatEnd(const QTestElement *element, QTestCharBuffer
if (!element || !formatted ) if (!element || !formatted )
return; return;
if (!element->childElements()){ if (!element->childElements()) {
formatted->data()[0] = '\0'; formatted->data()[0] = '\0';
return; return;
} }
@ -117,7 +117,7 @@ void QTestXunitStreamer::formatEnd(const QTestElement *element, QTestCharBuffer
void QTestXunitStreamer::formatAttributes(const QTestElement* element, const QTestElementAttribute *attribute, QTestCharBuffer *formatted) const void QTestXunitStreamer::formatAttributes(const QTestElement* element, const QTestElementAttribute *attribute, QTestCharBuffer *formatted) const
{ {
if(!attribute || !formatted ) if (!attribute || !formatted )
return; return;
QTest::AttributeIndex attrindex = attribute->index(); QTest::AttributeIndex attrindex = attribute->index();
@ -149,7 +149,7 @@ void QTestXunitStreamer::formatAttributes(const QTestElement* element, const QTe
void QTestXunitStreamer::formatAfterAttributes(const QTestElement *element, QTestCharBuffer *formatted) const void QTestXunitStreamer::formatAfterAttributes(const QTestElement *element, QTestCharBuffer *formatted) const
{ {
if(!element || !formatted ) if (!element || !formatted )
return; return;
// Errors are written as CDATA within system-err, comments elsewhere // Errors are written as CDATA within system-err, comments elsewhere
@ -162,7 +162,7 @@ void QTestXunitStreamer::formatAfterAttributes(const QTestElement *element, QTes
return; return;
} }
if(!element->childElements()) if (!element->childElements())
QTest::qt_asprintf(formatted, "/>\n"); QTest::qt_asprintf(formatted, "/>\n");
else else
QTest::qt_asprintf(formatted, ">\n"); QTest::qt_asprintf(formatted, ">\n");
@ -190,7 +190,7 @@ void QTestXunitStreamer::outputElements(QTestElement *element, bool) const
while (element) { while (element) {
hasChildren = element->childElements(); hasChildren = element->childElements();
if(element->elementType() != QTest::LET_Benchmark){ if (element->elementType() != QTest::LET_Benchmark) {
formatStart(element, &buf); formatStart(element, &buf);
outputString(buf.data()); outputString(buf.data());
@ -199,7 +199,7 @@ void QTestXunitStreamer::outputElements(QTestElement *element, bool) const
formatAfterAttributes(element, &buf); formatAfterAttributes(element, &buf);
outputString(buf.data()); outputString(buf.data());
if(hasChildren) if (hasChildren)
outputElements(element->childElements(), true); outputElements(element->childElements(), true);
formatEnd(element, &buf); formatEnd(element, &buf);
@ -212,7 +212,7 @@ void QTestXunitStreamer::outputElements(QTestElement *element, bool) const
void QTestXunitStreamer::outputElementAttributes(const QTestElement* element, QTestElementAttribute *attribute) const void QTestXunitStreamer::outputElementAttributes(const QTestElement* element, QTestElementAttribute *attribute) const
{ {
QTestCharBuffer buf; QTestCharBuffer buf;
while(attribute){ while (attribute) {
formatAttributes(element, attribute, &buf); formatAttributes(element, attribute, &buf);
outputString(buf.data()); outputString(buf.data());
attribute = attribute->nextElement(); attribute = attribute->nextElement();

View File

@ -169,7 +169,7 @@ void QXunitTestLogger::addIncident(IncidentTypes type, const char *description,
if (type == QAbstractTestLogger::Fail || type == QAbstractTestLogger::XPass) { if (type == QAbstractTestLogger::Fail || type == QAbstractTestLogger::XPass) {
QTestElement *failureElement = new QTestElement(QTest::LET_Failure); QTestElement *failureElement = new QTestElement(QTest::LET_Failure);
failureElement->addAttribute(QTest::AI_Result, typeBuf); failureElement->addAttribute(QTest::AI_Result, typeBuf);
if(file) if (file)
failureElement->addAttribute(QTest::AI_File, file); failureElement->addAttribute(QTest::AI_File, file);
else else
failureElement->addAttribute(QTest::AI_File, ""); failureElement->addAttribute(QTest::AI_File, "");
@ -207,7 +207,7 @@ void QXunitTestLogger::addIncident(IncidentTypes type, const char *description,
currentLogElement->addAttribute(QTest::AI_Result, typeBuf); currentLogElement->addAttribute(QTest::AI_Result, typeBuf);
} }
if(file) if (file)
currentLogElement->addAttribute(QTest::AI_File, file); currentLogElement->addAttribute(QTest::AI_File, file);
else else
currentLogElement->addAttribute(QTest::AI_File, ""); currentLogElement->addAttribute(QTest::AI_File, "");
@ -297,7 +297,7 @@ void QXunitTestLogger::addMessage(MessageTypes type, const char *message, const
errorElement->addAttribute(QTest::AI_Description, message); errorElement->addAttribute(QTest::AI_Description, message);
addTag(errorElement); addTag(errorElement);
if(file) if (file)
errorElement->addAttribute(QTest::AI_File, file); errorElement->addAttribute(QTest::AI_File, file);
else else
errorElement->addAttribute(QTest::AI_File, ""); errorElement->addAttribute(QTest::AI_File, "");