summaryrefslogtreecommitdiffstats
path: root/src/testlib
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2014-11-18 13:46:21 -0800
committerThiago Macieira <thiago.macieira@intel.com>2014-12-13 05:10:20 +0100
commitcfe12f716b0e138b51e3d8f5e481c4d9624459dc (patch)
tree26232a23b4985ba8984a139e03ac30403a38089d /src/testlib
parent0bc6c4f7ecfa332de57500fe722872eff4009b9b (diff)
Merge the different implementations of toHex in one central place
It's a simple enough function, but we don't need to duplicate those 17 bytes all over the place. Now they'll be duplicated at most once per library. Change-Id: Ic995e2a934b005e7e996e70f2ee644bfa948eb38 Reviewed-by: Jason McDonald <macadder1@gmail.com>
Diffstat (limited to 'src/testlib')
-rw-r--r--src/testlib/qtestcase.cpp21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index 24d563045b..61b0a13259 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -47,6 +47,7 @@
#include <QtCore/qprocess.h>
#include <QtCore/qdebug.h>
#include <QtCore/qlibraryinfo.h>
+#include <QtCore/private/qtools_p.h>
#include <QtTest/private/qtestlog_p.h>
#include <QtTest/private/qtesttable_p.h>
@@ -84,6 +85,8 @@
QT_BEGIN_NAMESPACE
+using QtMiscUtils::toHexUpper;
+
/*!
\namespace QTest
\inmodule QtTest
@@ -2060,12 +2063,6 @@ void *fetchData(QTestData *data, const char *tagName, int typeId)
return data->data(idx);
}
-static char toHex(ushort value)
-{
- static const char hexdigits[] = "0123456789ABCDEF";
- return hexdigits[value & 0xF];
-}
-
/*!
\fn char* QTest::toHexRepresentation(const char *ba, int length)
@@ -2115,9 +2112,9 @@ char *toHexRepresentation(const char *ba, int length)
while (true) {
const char at = ba[i];
- result[o] = toHex(at >> 4);
+ result[o] = toHexUpper(at >> 4);
++o;
- result[o] = toHex(at);
+ result[o] = toHexUpper(at);
++i;
++o;
@@ -2183,10 +2180,10 @@ char *toPrettyUnicode(const ushort *p, int length)
break;
default:
*dst++ = 'u';
- *dst++ = toHex(*p >> 12);
- *dst++ = toHex(*p >> 8);
- *dst++ = toHex(*p >> 4);
- *dst++ = toHex(*p);
+ *dst++ = toHexUpper(*p >> 12);
+ *dst++ = toHexUpper(*p >> 8);
+ *dst++ = toHexUpper(*p >> 4);
+ *dst++ = toHexUpper(*p);
}
}