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