QTest: add toString(QBitArray)
Change-Id: Ife213d861bb14c1787e1fffd15b70598cda8baf3 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>bb10
parent
19a9d3517b
commit
bbff70181f
|
|
@ -46,6 +46,7 @@
|
|||
#include <QtTest/qtestdata.h>
|
||||
#include <QtTest/qbenchmark.h>
|
||||
|
||||
#include <QtCore/qbitarray.h>
|
||||
#include <QtCore/qbytearray.h>
|
||||
#include <QtCore/qstring.h>
|
||||
#include <QtCore/qstringlist.h>
|
||||
|
|
@ -91,6 +92,16 @@ template<> inline char *toString(const QByteArray &ba)
|
|||
return QTest::toPrettyCString(ba.constData(), ba.length());
|
||||
}
|
||||
|
||||
template<> inline char *toString(const QBitArray &ba)
|
||||
{
|
||||
qsizetype size = ba.size();
|
||||
char *str = static_cast<char *>(malloc(size + 1));
|
||||
for (qsizetype i = 0; i < size; ++i)
|
||||
str[i] = "01"[ba.testBit(i)];
|
||||
str[size] = '\0';
|
||||
return str;
|
||||
}
|
||||
|
||||
#if QT_CONFIG(datestring)
|
||||
template<> inline char *toString(const QTime &time)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue