Playing around with qtestlibs data driven testing (Added MediaTypeTest
[emufront] / testing / EmuFrontTesting / platformtest.cpp
1 #include "platformtest.h"
2
3
4 void PlatformTest::init()
5 {
6 }
7
8 void PlatformTest::initTestCase()
9 {
10 }
11
12 void PlatformTest::cleanup()
13 {
14 }
15
16 void PlatformTest::cleanupTestCase()
17 {
18 }
19
20 /*void PlatformTest::equals_data()
21 {
22     qDebug() << "Arranging data for equals.";
23
24     QTest::addColumn<Platform>("platform1");
25     QTest::addColumn<Platform>("platform2");
26     qDebug() << "Done columns";
27     efA = new EmuFrontFile(1, "a", "qa", 1, 2);
28     efB = new EmuFrontFile(2, "b", "qaa", 2, 3);
29     qDebug() << "efA" << efA->getName();
30     qDebug() << "efB" << efB->getName();
31
32     QTest::newRow("id and name")
33             << Platform(1, "test", efA)
34             << Platform(1, "test", efB);
35
36     qDebug() << "Done first row";
37     efA = new EmuFrontFile(1, "a", "qa", 1, 2);
38     efB = new EmuFrontFile(2, "b", "qaa", 2, 3);
39     qDebug() << "efA" << efA->getName();
40     qDebug() << "efB" << efB->getName();
41
42     QTest::newRow("id, name and filename")
43             << Platform(2, "test", efA)
44             << Platform(2, "test", efB);
45     qDebug() << "Done 2nd row";
46 }
47
48 void PlatformTest::equals()
49 {
50     qDebug() << "Entering equals";
51     QFETCH(Platform, platform1);
52     QFETCH(Platform, platform2);
53     QVERIFY(platform1 == platform2);
54     qDebug() << "Leaving equals";
55 }*/
56
57 void PlatformTest::equals2()
58 {
59     qDebug() << "Starting equals2 test, creating EmuFrontFile objects to heap.";
60     EmuFrontFile *efA = new EmuFrontFile(1, "efA", "qa", 1, 2);
61     EmuFrontFile *efB = new EmuFrontFile(2, "efB", "qaa", 2, 3);
62     qDebug() << "Creating Platform test objects p1 and p2";
63     Platform p1(1, "px");
64     Platform p2(1, "px");
65     QVERIFY(p1 == p2);
66
67     qDebug() << efB->getName();
68
69     qDebug() << "Creating Platform test objects p5 containg member " << efA->getName();
70     Platform p5(1, "p5", efA);
71
72     // The following should not be done, efA dies with p5:
73     // and pointer from p6 would keep pointing to memory area where
74     // efA no longer exists:
75     //Platform p6(1, "p6", efA);
76
77     qDebug() << "Creating Platform test objects p6 containg member " << efB->getName();
78     Platform p6(1, "p6", efB);
79
80     qDebug() << "efA" << efA->getName();
81     qDebug() << "efB" << efB->getName();
82
83     qDebug() << "Entering QVERIFY";
84     QVERIFY(p5 == p6);
85
86     qDebug() << "efA" << efA->getName();
87     qDebug() << "efB" << efB->getName();
88
89     QVERIFY(p5 == p6);
90
91     qDebug() << "efA" << efA->getName();
92     qDebug() << "efB" << efB->getName();
93
94     qDebug() << "Leaving QVERIFY";
95     qDebug() << "Leaving equals2";
96 }
97
98 /* Platforms are equal if the following fields match:
99     - id (int)
100     - name (QString)
101     - filename (QString)
102 */
103 void PlatformTest::notEquals()
104 {
105     Platform p1(1, "testa");
106     Platform p2(1, "test");
107     // This should return true
108     QVERIFY(p1 != p2);
109 }