diff options
author | Liang Qi <liang.qi@nokia.com> | 2011-05-20 09:36:01 (GMT) |
---|---|---|
committer | Liang Qi <liang.qi@nokia.com> | 2011-05-20 12:28:12 (GMT) |
commit | 71f923f29e2c60444a85fc765fc582e06cb7eca4 (patch) | |
tree | d226463c2128c084ef83fcaf304912cb03934867 /tests | |
parent | 7ce566ed82666ac08f137f4d8590ce589d42c82a (diff) | |
download | Qt-71f923f29e2c60444a85fc765fc582e06cb7eca4.zip Qt-71f923f29e2c60444a85fc765fc582e06cb7eca4.tar.gz Qt-71f923f29e2c60444a85fc765fc582e06cb7eca4.tar.bz2 |
Add QUuid::toByteArray() and relevant
Add QUuid::toByteArray() and QUuid(const QByteArray &). Same
behavior with QUuid::toString() and QUuid(const QString &).
Task-number: QTBUG-19419
Reviewed-by: joao
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quuid/tst_quuid.cpp | 20 | ||||
-rw-r--r-- | tests/benchmarks/corelib/plugin/quuid/tst_quuid.cpp | 18 |
2 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/quuid/tst_quuid.cpp b/tests/auto/quuid/tst_quuid.cpp index f24c893..1b65abb 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 47a3d3f..608423a 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; |