X-Git-Url: http://git.silmor.de/gitweb/?p=web%2Fkonrad%2Fchester.git;a=blobdiff_plain;f=tests%2Fdptrtest.cpp;fp=tests%2Fdptrtest.cpp;h=273106cde97b56d48a618b12bd7af447441d424c;hp=0000000000000000000000000000000000000000;hb=1a6e626b9c76f45fc1c330231d3c449305f32db9;hpb=632fa4f67f6838599da6225452b5d93b844b2241 diff --git a/tests/dptrtest.cpp b/tests/dptrtest.cpp new file mode 100644 index 0000000..273106c --- /dev/null +++ b/tests/dptrtest.cpp @@ -0,0 +1,46 @@ + +#include "dptrtest.h" + +#include +#include +#include + +void DPtrTest::simpleDP() +{ + QCOMPARE(ClassWithDptr().num(),0); + ClassWithDptr o1;o1.setNum(1); + QCOMPARE(o1.num(),1); + ClassWithDptr o2;o2.setNum(2); + ClassWithDptr o3(o1); + QCOMPARE(o1.num(),1); + QCOMPARE(o2.num(),2); + QCOMPARE(o3.num(),1); + o1=o2; + QCOMPARE(o1.num(),2); + o2.setNum(3); + QCOMPARE(o1.num(),2); + QCOMPARE(o2.num(),3); +} + +void DPtrTest::sharedDP() +{ + QCOMPARE(ClassWithSDptr().num(),0); + ClassWithSDptr o1;o1.setNum(1); + QCOMPARE(o1.num(),1); + ClassWithSDptr o2;o2.setNum(2); + ClassWithSDptr o3(o1); + QCOMPARE(o1.num(),1); + QCOMPARE(o2.num(),2); + QCOMPARE(o3.num(),1); + o1.setNum(4); + QCOMPARE(o1.num(),4); + QCOMPARE(o2.num(),2); + QCOMPARE(o3.num(),4); + o2=o1;o2.setNum(5); + QCOMPARE(o1.num(),5); + QCOMPARE(o2.num(),5); + QCOMPARE(o3.num(),5); +} + + +QTEST_MAIN(DPtrTest) \ No newline at end of file