diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2018-01-24 14:09:08 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2018-02-03 21:30:37 +0000 |
commit | 687dc7fac7fec6c2f77aa1d130119a8bc1fd368b (patch) | |
tree | 83f67123c1430067ae497f84a4153d0509f2c3a5 /tests/auto/corelib/plugin/quuid | |
parent | 017569f702b6dd0bc3aa077d85e4a7fc27562133 (diff) |
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 <lars.knoll@qt.io>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'tests/auto/corelib/plugin/quuid')
-rw-r--r-- | tests/auto/corelib/plugin/quuid/tst_quuid.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
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() |