From 8c72dc5907a97fce718f6810d446ecf6ea41b588 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Wed, 4 Jan 2012 11:15:20 +0100 Subject: Add V3(md5) and V5(sha1) version for DCE in QUuid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add the above versions based on RFC4122 standard. Done-with: Hagen Rother Task-number: QTBUG-23071 Change-Id: Ieb90925374d1e3c85011b899b8dd3bb1a608c561 Reviewed-by: João Abecasis Reviewed-by: Denis Dzyubenko --- tests/auto/corelib/plugin/quuid/tst_quuid.cpp | 28 +++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp index b7c4130236..789659cd04 100644 --- a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp +++ b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp @@ -59,6 +59,7 @@ private slots: void fromByteArray(); void toRfc4122(); void fromRfc4122(); + void createUuidV3OrV5(); void check_QDataStream(); void isNull(); void equal(); @@ -81,21 +82,34 @@ private slots: public: // Variables + QUuid uuidNS; QUuid uuidA; QUuid uuidB; + QUuid uuidC; + QUuid uuidD; }; void tst_QUuid::initTestCase() { + //It's NameSpace_DNS in RFC4122 + //"{6ba7b810-9dad-11d1-80b4-00c04fd430c8}"; + uuidNS = QUuid(0x6ba7b810, 0x9dad, 0x11d1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8); + //"{fc69b59e-cc34-4436-a43c-ee95d128b8c5}"; - uuidA = QUuid(0xfc69b59e, 0xcc34 ,0x4436 ,0xa4 ,0x3c ,0xee ,0x95 ,0xd1 ,0x28 ,0xb8 ,0xc5); + uuidA = QUuid(0xfc69b59e, 0xcc34, 0x4436, 0xa4, 0x3c, 0xee, 0x95, 0xd1, 0x28, 0xb8, 0xc5); //"{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}"; - uuidB = QUuid(0x1ab6e93a ,0xb1cb ,0x4a87 ,0xba ,0x47 ,0xec ,0x7e ,0x99 ,0x03 ,0x9a ,0x7b); + uuidB = QUuid(0x1ab6e93a, 0xb1cb, 0x4a87, 0xba, 0x47, 0xec, 0x7e, 0x99, 0x03, 0x9a, 0x7b); // chdir to the directory containing our testdata, then refer to it with relative paths QString testdata_dir = QFileInfo(QFINDTESTDATA("testProcessUniqueness")).absolutePath(); QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir)); + + //"{3d813cbb-47fb-32ba-91df-831e1593ac29}"; http://www.rfc-editor.org/errata_search.php?rfc=4122&eid=1352 + uuidC = QUuid(0x3d813cbb, 0x47fb, 0x32ba, 0x91, 0xdf, 0x83, 0x1e, 0x15, 0x93, 0xac, 0x29); + + //"{21f7f8de-8051-5b89-8680-0195ef798b6a}"; + uuidD = QUuid(0x21f7f8de, 0x8051, 0x5b89, 0x86, 0x80, 0x01, 0x95, 0xef, 0x79, 0x8b, 0x6a); } void tst_QUuid::fromChar() @@ -164,6 +178,16 @@ void tst_QUuid::fromRfc4122() QCOMPARE(uuidB, QUuid::fromRfc4122(QByteArray::fromHex("1ab6e93ab1cb4a87ba47ec7e99039a7b"))); } +void tst_QUuid::createUuidV3OrV5() +{ + //"www.widgets.com" is also from RFC4122 + QCOMPARE(uuidC, QUuid::createUuidV3(uuidNS, QByteArray("www.widgets.com"))); + QCOMPARE(uuidC, QUuid::createUuidV3(uuidNS, QString("www.widgets.com"))); + + QCOMPARE(uuidD, QUuid::createUuidV5(uuidNS, QByteArray("www.widgets.com"))); + QCOMPARE(uuidD, QUuid::createUuidV5(uuidNS, QString("www.widgets.com"))); +} + void tst_QUuid::check_QDataStream() { QUuid tmp; -- cgit v1.2.3