From 687dc7fac7fec6c2f77aa1d130119a8bc1fd368b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 24 Jan 2018 14:09:08 -0800 Subject: QUuid: add a way to get the string form without the braces While we're at it, add a way to get it without the dashes too. I'm calling it "id128", as in "128-bit ID", as seen in journald's sd_id128_t type and the sd_id128_xxx() API. [ChangeLog][QtCore][QUuid] Added a parameter to both toString() and toByteArray() to allow controlling the use or not of the braces and dashes in the string form. Change-Id: I56b444f9d6274221a3b7fffd150cde706cfc5098 Reviewed-by: Lars Knoll Reviewed-by: Olivier Goffart (Woboq GmbH) --- tests/auto/corelib/plugin/quuid/tst_quuid.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests/auto/corelib/plugin/quuid/tst_quuid.cpp') diff --git a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp index 9e3edc96ec..bad72c081b 100644 --- a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp +++ b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp @@ -124,8 +124,16 @@ void tst_QUuid::fromChar() void tst_QUuid::toString() { QCOMPARE(uuidA.toString(), QString("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}")); + QCOMPARE(uuidA.toString(QUuid::WithoutBraces), + QString("fc69b59e-cc34-4436-a43c-ee95d128b8c5")); + QCOMPARE(uuidA.toString(QUuid::Id128), + QString("fc69b59ecc344436a43cee95d128b8c5")); QCOMPARE(uuidB.toString(), QString("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}")); + QCOMPARE(uuidB.toString(QUuid::WithoutBraces), + QString("1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b")); + QCOMPARE(uuidB.toString(QUuid::Id128), + QString("1ab6e93ab1cb4a87ba47ec7e99039a7b")); } void tst_QUuid::fromString_data() @@ -185,8 +193,16 @@ void tst_QUuid::fromString() void tst_QUuid::toByteArray() { QCOMPARE(uuidA.toByteArray(), QByteArray("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}")); + QCOMPARE(uuidA.toByteArray(QUuid::WithoutBraces), + QByteArray("fc69b59e-cc34-4436-a43c-ee95d128b8c5")); + QCOMPARE(uuidA.toByteArray(QUuid::Id128), + QByteArray("fc69b59ecc344436a43cee95d128b8c5")); QCOMPARE(uuidB.toByteArray(), QByteArray("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}")); + QCOMPARE(uuidB.toByteArray(QUuid::WithoutBraces), + QByteArray("1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b")); + QCOMPARE(uuidB.toByteArray(QUuid::Id128), + QByteArray("1ab6e93ab1cb4a87ba47ec7e99039a7b")); } void tst_QUuid::fromByteArray() -- cgit v1.2.3