Changeset 561 for trunk/src/testlib/qplaintestlogger.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/testlib/qplaintestlogger.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtTest module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 53 53 #ifdef Q_OS_WIN 54 54 #include "windows.h" 55 #endif 56 57 #if defined(Q_OS_SYMBIAN) 58 #include <e32debug.h> 55 59 #endif 56 60 … … 126 130 static const char *messageType2String(QAbstractTestLogger::MessageTypes type) 127 131 { 132 #ifdef Q_OS_WIN 128 133 static bool colored = (!qgetenv("QTEST_COLORED").isEmpty()); 134 #else 135 static bool colored = ::getenv("QTEST_COLORED"); 136 #endif 129 137 switch (type) { 130 138 case QAbstractTestLogger::Skip: … … 149 157 { 150 158 #if defined(Q_OS_WINCE) 151 int length = strlen(str); 152 for (int pos = 0; pos < length; pos +=255) { 153 QString uniText = QString::fromLatin1(str + pos, 255); 154 OutputDebugStringW((const LPCWSTR) uniText.utf16()); 155 } 159 QString strUtf16 = QString::fromLatin1(str); 160 const int maxOutputLength = 255; 161 do { 162 QString tmp = strUtf16.left(maxOutputLength); 163 OutputDebugString((wchar_t*)tmp.utf16()); 164 strUtf16.remove(0, maxOutputLength); 165 } while (!strUtf16.isEmpty()); 156 166 if (QTestLog::outputFileName()) 157 167 #elif defined(Q_OS_WIN) … … 160 170 OutputDebugStringA(str); 161 171 LeaveCriticalSection(&outputCriticalSection); 172 #elif defined(Q_OS_SYMBIAN) 173 // RDebug::Print has a cap of 256 characters so break it up 174 TPtrC8 ptr(reinterpret_cast<const TUint8*>(str)); 175 _LIT(format, "[QTestLib] %S"); 176 const int maxBlockSize = 256 - ((const TDesC &)format).Length(); 177 HBufC* hbuffer = HBufC::New(maxBlockSize); 178 if(hbuffer) { 179 for (int i = 0; i < ptr.Length(); i += maxBlockSize) { 180 int size = Min(maxBlockSize, ptr.Length() - i); 181 hbuffer->Des().Copy(ptr.Mid(i, size)); 182 RDebug::Print(format, hbuffer); 183 } 184 } 185 else { 186 // fast, no allocations, but truncates silently 187 RDebug::RawPrint(format); 188 TPtrC8 ptr(reinterpret_cast<const TUint8*>(str)); 189 RDebug::RawPrint(ptr); 190 RDebug::RawPrint(_L8("\n")); 191 } 162 192 #endif 163 193 QAbstractTestLogger::outputString(str); … … 169 199 QTEST_ASSERT(msg); 170 200 171 char buf[1024];201 QTestCharBuffer buf; 172 202 173 203 const char *fn = QTestResult::currentTestFunction() ? QTestResult::currentTestFunction() … … 179 209 const char *filler = (tag[0] && gtag[0]) ? ":" : ""; 180 210 if (file) { 181 QTest::qt_ snprintf(buf, sizeof(buf), "%s: %s::%s(%s%s%s)%s%s\n"211 QTest::qt_asprintf(&buf, "%s: %s::%s(%s%s%s)%s%s\n" 182 212 #ifdef Q_OS_WIN 183 213 "%s(%d) : failure location\n" … … 188 218 msg[0] ? " " : "", msg, file, line); 189 219 } else { 190 QTest::qt_ snprintf(buf, sizeof(buf), "%s: %s::%s(%s%s%s)%s%s\n",220 QTest::qt_asprintf(&buf, "%s: %s::%s(%s%s%s)%s%s\n", 191 221 type, QTestResult::currentTestObjectName(), fn, gtag, filler, tag, 192 222 msg[0] ? " " : "", msg); 193 223 } 194 memcpy(buf, type, strlen(type)); 195 outputMessage(buf); 224 // In colored mode, printf above stripped our nonprintable control characters. 225 // Put them back. 226 memcpy(buf.data(), type, strlen(type)); 227 outputMessage(buf.data()); 196 228 } 197 229 … … 204 236 int digits = 0; 205 237 qreal divisor = 1; 206 238 207 239 while (num / divisor >= 1) { 208 240 divisor *= 10; … … 217 249 { 218 250 if (number < T(0)) 219 return Q String(QLatin1String("NAN"));251 return QLatin1String("NAN"); 220 252 if (number == T(0)) 221 return Q String(QLatin1String("0"));253 return QLatin1String("0"); 222 254 223 255 QString beforeDecimalPoint = QString::number(qint64(number), 'f', 0); 224 256 QString afterDecimalPoint = QString::number(number, 'f', 20); 225 257 afterDecimalPoint.remove(0, beforeDecimalPoint.count() + 1); 226 258 227 259 int beforeUse = qMin(beforeDecimalPoint.count(), significantDigits); 228 260 int beforeRemove = beforeDecimalPoint.count() - beforeUse; 229 261 230 262 // Replace insignificant digits before the decimal point with zeros. 231 263 beforeDecimalPoint.chop(beforeRemove); … … 265 297 if (afterUse > 0) 266 298 print.append(decimalPoint); 267 299 268 300 print += afterDecimalPoint; 269 301 270 302 271 303 return print; 272 304 } … … 289 321 QTest::qt_snprintf( 290 322 buf1, sizeof(buf1), "%s: %s::%s", 291 bmtag, 323 bmtag, 292 324 QTestResult::currentTestObjectName(), 293 325 result.context.slotName.toAscii().data()); … … 300 332 QTest::qt_snprintf(bufTag, sizeof(bufTag), ":\"%s\"", tag.data()); 301 333 } 302 334 303 335 304 336 char fillFormat[8];
Note:
See TracChangeset
for help on using the changeset viewer.