summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quuid/tst_quuid.cpp20
-rw-r--r--tests/benchmarks/corelib/plugin/quuid/tst_quuid.cpp18
2 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/quuid/tst_quuid.cpp b/tests/auto/quuid/tst_quuid.cpp
index 6e067b7d24..3abc8af4c0 100644
--- a/tests/auto/quuid/tst_quuid.cpp
+++ b/tests/auto/quuid/tst_quuid.cpp
@@ -63,6 +63,8 @@ private slots:
void fromChar();
void toString();
void fromString();
+ void toByteArray();
+ void fromByteArray();
void check_QDataStream();
void isNull();
void equal();
@@ -127,6 +129,24 @@ void tst_QUuid::fromString()
QCOMPARE(uuidB, QUuid(QString("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}")));
}
+void tst_QUuid::toByteArray()
+{
+ QCOMPARE(uuidA.toByteArray(), QByteArray("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}"));
+
+ QCOMPARE(uuidB.toByteArray(), QByteArray("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}"));
+}
+
+void tst_QUuid::fromByteArray()
+{
+ QCOMPARE(uuidA, QUuid(QByteArray("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}")));
+ QCOMPARE(uuidA, QUuid(QByteArray("fc69b59e-cc34-4436-a43c-ee95d128b8c5}")));
+ QCOMPARE(uuidA, QUuid(QByteArray("{fc69b59e-cc34-4436-a43c-ee95d128b8c5")));
+ QCOMPARE(uuidA, QUuid(QByteArray("fc69b59e-cc34-4436-a43c-ee95d128b8c5")));
+ QCOMPARE(QUuid(), QUuid(QByteArray("{fc69b59e-cc34-4436-a43c-ee95d128b8c")));
+
+ QCOMPARE(uuidB, QUuid(QByteArray("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}")));
+}
+
void tst_QUuid::check_QDataStream()
{
QUuid tmp;
diff --git a/tests/benchmarks/corelib/plugin/quuid/tst_quuid.cpp b/tests/benchmarks/corelib/plugin/quuid/tst_quuid.cpp
index 61876e5816..24754ab370 100644
--- a/tests/benchmarks/corelib/plugin/quuid/tst_quuid.cpp
+++ b/tests/benchmarks/corelib/plugin/quuid/tst_quuid.cpp
@@ -56,6 +56,8 @@ private slots:
void fromChar();
void toString();
void fromString();
+ void toByteArray();
+ void fromByteArray();
void toDataStream();
void fromDataStream();
void isNull();
@@ -93,6 +95,22 @@ void tst_bench_QUuid::fromString()
}
}
+void tst_bench_QUuid::toByteArray()
+{
+ QUuid uuid = QUuid::createUuid();
+ QBENCHMARK {
+ uuid.toByteArray();
+ }
+}
+
+void tst_bench_QUuid::fromByteArray()
+{
+ QByteArray string = "{67C8770B-44F1-410A-AB9A-F9B5446F13EE}";
+ QBENCHMARK {
+ QUuid uuid(string);
+ }
+}
+
void tst_bench_QUuid::toDataStream()
{
QUuid uuid1, uuid2;