move tests to dptr
[web/konrad/chester.git] / tests / dptrtest.cpp
1
2 #include "dptrtest.h"
3
4 #include <QtCore>
5 #include <QtTest>
6 #include <QDebug>
7
8 void DPtrTest::simpleDP()
9 {
10         QCOMPARE(ClassWithDptr().num(),0);
11         ClassWithDptr o1;o1.setNum(1);
12         QCOMPARE(o1.num(),1);
13         ClassWithDptr o2;o2.setNum(2);
14         ClassWithDptr o3(o1);
15         QCOMPARE(o1.num(),1);
16         QCOMPARE(o2.num(),2);
17         QCOMPARE(o3.num(),1);
18         o1=o2;
19         QCOMPARE(o1.num(),2);
20         o2.setNum(3);
21         QCOMPARE(o1.num(),2);
22         QCOMPARE(o2.num(),3);
23 }
24
25 void DPtrTest::sharedDP()
26 {
27         QCOMPARE(ClassWithSDptr().num(),0);
28         ClassWithSDptr o1;o1.setNum(1);
29         QCOMPARE(o1.num(),1);
30         ClassWithSDptr o2;o2.setNum(2);
31         ClassWithSDptr o3(o1);
32         QCOMPARE(o1.num(),1);
33         QCOMPARE(o2.num(),2);
34         QCOMPARE(o3.num(),1);
35         o1.setNum(4);
36         QCOMPARE(o1.num(),4);
37         QCOMPARE(o2.num(),2);
38         QCOMPARE(o3.num(),4);
39         o2=o1;o2.setNum(5);
40         QCOMPARE(o1.num(),5);
41         QCOMPARE(o2.num(),5);
42         QCOMPARE(o3.num(),5);
43 }
44
45
46 QTEST_MAIN(DPtrTest)