summaryrefslogtreecommitdiffstats
path: root/tests/auto/quuid
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@nokia.com>2011-05-20 12:12:57 (GMT)
committerLiang Qi <liang.qi@nokia.com>2011-05-20 12:12:57 (GMT)
commit4e9286880fd2686e61de2c4be3c317e01f0d9989 (patch)
tree3644c5f147547090ea12d327b3b17e6506e0d59f /tests/auto/quuid
parent0ccf01368adcabbb25958a55976083f72116a2d5 (diff)
downloadQt-4e9286880fd2686e61de2c4be3c317e01f0d9989.zip
Qt-4e9286880fd2686e61de2c4be3c317e01f0d9989.tar.gz
Qt-4e9286880fd2686e61de2c4be3c317e01f0d9989.tar.bz2
Add some autotests and benchmarks for QUuid
Missing those functions for optimization. Reviewed-by: joao
Diffstat (limited to 'tests/auto/quuid')
-rw-r--r--tests/auto/quuid/tst_quuid.cpp65
1 files changed, 63 insertions, 2 deletions
diff --git a/tests/auto/quuid/tst_quuid.cpp b/tests/auto/quuid/tst_quuid.cpp
index 50e48c9..f24c893 100644
--- a/tests/auto/quuid/tst_quuid.cpp
+++ b/tests/auto/quuid/tst_quuid.cpp
@@ -60,7 +60,10 @@ public:
tst_QUuid();
private slots:
+ void fromChar();
void toString();
+ void fromString();
+ void check_QDataStream();
void isNull();
void equal();
void notEqual();
@@ -83,16 +86,74 @@ public:
tst_QUuid::tst_QUuid()
{
- uuidA = "{fc69b59e-cc34-4436-a43c-ee95d128b8c5}";
- uuidB = "{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}";
+ //"{fc69b59e-cc34-4436-a43c-ee95d128b8c5}";
+ 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);
}
+void tst_QUuid::fromChar()
+{
+ QCOMPARE(uuidA, QUuid("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}"));
+ QCOMPARE(uuidA, QUuid("fc69b59e-cc34-4436-a43c-ee95d128b8c5}"));
+ QCOMPARE(uuidA, QUuid("{fc69b59e-cc34-4436-a43c-ee95d128b8c5"));
+ QCOMPARE(uuidA, QUuid("fc69b59e-cc34-4436-a43c-ee95d128b8c5"));
+ QCOMPARE(QUuid(), QUuid("{fc69b59e-cc34-4436-a43c-ee95d128b8c"));
+ QCOMPARE(QUuid(), QUuid("{fc69b59e-cc34"));
+ QCOMPARE(QUuid(), QUuid("fc69b59e-cc34-"));
+ QCOMPARE(QUuid(), QUuid("fc69b59e-cc34"));
+ QCOMPARE(QUuid(), QUuid("cc34"));
+ QCOMPARE(QUuid(), QUuid(NULL));
+
+ QCOMPARE(uuidB, QUuid(QString("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}")));
+}
void tst_QUuid::toString()
{
QCOMPARE(uuidA.toString(), QString("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}"));
+
+ QCOMPARE(uuidB.toString(), QString("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}"));
}
+void tst_QUuid::fromString()
+{
+ QCOMPARE(uuidA, QUuid(QString("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}")));
+ QCOMPARE(uuidA, QUuid(QString("fc69b59e-cc34-4436-a43c-ee95d128b8c5}")));
+ QCOMPARE(uuidA, QUuid(QString("{fc69b59e-cc34-4436-a43c-ee95d128b8c5")));
+ QCOMPARE(uuidA, QUuid(QString("fc69b59e-cc34-4436-a43c-ee95d128b8c5")));
+ QCOMPARE(QUuid(), QUuid(QString("{fc69b59e-cc34-4436-a43c-ee95d128b8c")));
+
+ QCOMPARE(uuidB, QUuid(QString("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}")));
+}
+
+void tst_QUuid::check_QDataStream()
+{
+ QUuid tmp;
+ QByteArray ar;
+ {
+ QDataStream out(&ar,QIODevice::WriteOnly);
+ out.setByteOrder(QDataStream::BigEndian);
+ out << uuidA;
+ }
+ {
+ QDataStream in(&ar,QIODevice::ReadOnly);
+ in.setByteOrder(QDataStream::BigEndian);
+ in >> tmp;
+ QCOMPARE(uuidA, tmp);
+ }
+ {
+ QDataStream out(&ar,QIODevice::WriteOnly);
+ out.setByteOrder(QDataStream::LittleEndian);
+ out << uuidA;
+ }
+ {
+ QDataStream in(&ar,QIODevice::ReadOnly);
+ in.setByteOrder(QDataStream::LittleEndian);
+ in >> tmp;
+ QCOMPARE(uuidA, tmp);
+ }
+}
void tst_QUuid::isNull()
{