summaryrefslogtreecommitdiff
path: root/tests/test-resource.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test-resource.cpp')
-rw-r--r--tests/test-resource.cpp116
1 files changed, 8 insertions, 108 deletions
diff --git a/tests/test-resource.cpp b/tests/test-resource.cpp
index afccc16..e5c60bd 100644
--- a/tests/test-resource.cpp
+++ b/tests/test-resource.cpp
@@ -74,7 +74,7 @@ void TestResource::testShared_data()
QTest::addColumn<bool>("expected");
QTest::newRow("Resource is shared") << true << true;
- QTest::newRow("Resource is not hhared") << false << false;
+ QTest::newRow("Resource is not shared") << false << false;
}
void TestResource::testShared()
@@ -89,27 +89,6 @@ void TestResource::testShared()
QCOMPARE(result, expected);
}
-void TestResource::testIdentifier_data()
-{
- QTest::addColumn<quint32>("identifier");
- QTest::addColumn<quint32>("expected");
-
- QTest::newRow("Set identifier") << (quint32)this << (quint32)this;
- QTest::newRow("Set to 0") << 0U << 0U;
-}
-
-void TestResource::testIdentifier()
-{
- QFETCH(quint32, identifier);
- QFETCH(quint32, expected);
-
- resource->setType(AudioPlaybackResource);
- resource->setId(identifier);
- quint32 result = resource->id();
-
- QCOMPARE(result, expected);
-}
-
void TestResource::testCopy()
{
Resource copy;
@@ -118,7 +97,6 @@ void TestResource::testCopy()
copy = *resource;
- QCOMPARE(copy.id(), resource->id());
QCOMPARE(copy.isOptional(), resource->isOptional());
QCOMPARE(copy.isShared(), resource->isShared());
QCOMPARE(copy.type(), resource->type());
@@ -130,7 +108,6 @@ void TestResource::testCopyConstructor()
resource->setOptional();
Resource copy(*resource);
- QCOMPARE(copy.id(), resource->id());
QCOMPARE(copy.isOptional(), resource->isOptional());
QCOMPARE(copy.isShared(), resource->isShared());
QCOMPARE(copy.type(), resource->type());
@@ -140,102 +117,25 @@ void TestResource::testEqualsOperator()
{
Resource copy;
resource->setType(AudioPlaybackResource);
- resource->setOptional();
-
copy = *resource;
- QVERIFY(copy == *resource);
-}
-
-void TestResource::testHashFunctionWithCopies()
-{
- resource->setType(AudioPlaybackResource);
resource->setOptional();
resource->setShared();
- Resource copy(*resource);
- uint originalHash = qHash(*resource);
- uint copyHash = qHash(copy);
-
- QCOMPARE(originalHash, copyHash);
-}
-
-void TestResource::testHashFunctionWithDifferentResources()
-{
- resource->setType(AudioPlaybackResource);
- resource->setOptional();
- resource->setShared();
- Resource copy(*resource);
- copy.setType(VideoPlaybackResource);
-
- uint originalHash = qHash(*resource);
- uint copyHash = qHash(copy);
-
- QEXPECT_FAIL("", "Expecting to fail since they are different resources", Continue);
- QCOMPARE(originalHash, copyHash);
-}
-
-void TestResource::testHashFunctionWithDifferentOptionality()
-{
- resource->setType(AudioPlaybackResource);
- resource->setOptional();
- resource->setShared();
- Resource copy(*resource);
- copy.setOptional(false);
-
- uint originalHash = qHash(*resource);
- uint copyHash = qHash(copy);
-
- QEXPECT_FAIL("", "Expecting to fail since one isOptional, the other isn't", Continue);
- QCOMPARE(originalHash, copyHash);
+ QVERIFY(copy == *resource);
}
-void TestResource::testHashFunctionWithDifferentSharedness()
+void TestResource::testEqualsOperatorWithDifferentTypes()
{
+ Resource copy;
resource->setType(AudioPlaybackResource);
- resource->setOptional();
- resource->setShared();
- Resource copy(*resource);
- copy.setShared(false);
-
- uint originalHash = qHash(*resource);
- uint copyHash = qHash(copy);
-
- QEXPECT_FAIL("", "Expecting to fail since one isShared , the other isn't", Continue);
- QCOMPARE(originalHash, copyHash);
-}
+ copy = *resource;
-void TestResource::testHashFunctionWithIdentical()
-{
- resource->setType(AudioPlaybackResource);
resource->setOptional();
- resource->setShared();
- Resource copy;
- copy.setOptional();
- copy.setShared();
- copy.setType(AudioPlaybackResource);
-
- uint originalHash = qHash(*resource);
- uint copyHash = qHash(copy);
-
- QCOMPARE(originalHash, copyHash);
-}
+ copy.setType(VideoPlaybackResource);
-void TestResource::testQSetOfResource()
-{
- Resource a,b,c;
- a.setType(AudioPlaybackResource);
- b.setType(VideoPlaybackResource);
- c.setType(AudioRecorderResource);
-
- QSet<Resource> set;
- set.insert(a);
- set.insert(b);
- set.insert(c);
-
- QVERIFY(set.contains(a));
- QVERIFY(set.contains(b));
- QVERIFY(set.contains(c));
+ QEXPECT_FAIL("", "Expecting to fail since different types.", Continue);
+ QVERIFY(copy == *resource);
}
QTEST_MAIN(TestResource)