[Ktutorial-commits] SF.net SVN: ktutorial:[154] trunk/ktutorial/ktutorial-editor
Status: Alpha
Brought to you by:
danxuliu
From: <dan...@us...> - 2010-03-15 06:56:22
|
Revision: 154 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=154&view=rev Author: danxuliu Date: 2010-03-15 06:56:15 +0000 (Mon, 15 Mar 2010) Log Message: ----------- Add clone() and equals(const WaitFor&) methods to WaitFor and subclasses. Modified Paths: -------------- trunk/ktutorial/ktutorial-editor/src/WaitFor.cpp trunk/ktutorial/ktutorial-editor/src/WaitFor.h trunk/ktutorial/ktutorial-editor/src/WaitForComposed.cpp trunk/ktutorial/ktutorial-editor/src/WaitForComposed.h trunk/ktutorial/ktutorial-editor/src/WaitForNot.cpp trunk/ktutorial/ktutorial-editor/src/WaitForNot.h trunk/ktutorial/ktutorial-editor/src/WaitForSignal.cpp trunk/ktutorial/ktutorial-editor/src/WaitForSignal.h trunk/ktutorial/ktutorial-editor/tests/unit/CMakeLists.txt trunk/ktutorial/ktutorial-editor/tests/unit/WaitForComposedTest.cpp trunk/ktutorial/ktutorial-editor/tests/unit/WaitForNotTest.cpp trunk/ktutorial/ktutorial-editor/tests/unit/WaitForSignalTest.cpp Added Paths: ----------- trunk/ktutorial/ktutorial-editor/tests/unit/WaitForTest.cpp Modified: trunk/ktutorial/ktutorial-editor/src/WaitFor.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/WaitFor.cpp 2010-03-14 17:15:38 UTC (rev 153) +++ trunk/ktutorial/ktutorial-editor/src/WaitFor.cpp 2010-03-15 06:56:15 UTC (rev 154) @@ -22,3 +22,11 @@ WaitFor::WaitFor(QObject* parent): QObject(parent) { } + +bool WaitFor::operator==(const WaitFor& waitFor) const { + return equals(waitFor); +} + +bool WaitFor::operator!=(const WaitFor& waitFor) const { + return !equals(waitFor); +} Modified: trunk/ktutorial/ktutorial-editor/src/WaitFor.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/WaitFor.h 2010-03-14 17:15:38 UTC (rev 153) +++ trunk/ktutorial/ktutorial-editor/src/WaitFor.h 2010-03-15 06:56:15 UTC (rev 154) @@ -22,14 +22,19 @@ #include <QObject> /** - * Base class for conditions to wait for to be met. + * Abstract base class for conditions to wait for to be met. * Its subclasses store the data used in KTutorial wait for subclasses, but they * have nothing to do with them (they don't even know each others). Its purpose * is store the data needed to generate the code to initialize a true * KTutorial::WaitFor subclass object. * - * Subclasses must emit dataChanged(Step*) signal when their data is modified - * (including the data of child conditions). + * Subclass must implement clone() and equals(const WaitFor&) methods, which + * perform a deep copy and a comparison of the WaitFor. Operators == and != are + * provided for convenience in this base class and it isn't needed to define + * them in subclasses. + * + * Subclasses must also emit dataChanged(Step*) signal when their data is + * modified (including the data of child conditions). */ class WaitFor: public QObject { Q_OBJECT @@ -42,6 +47,49 @@ */ WaitFor(QObject* parent = 0); + /** + * Deep copy of this WaitFor. + * If this WaitFor has child WaitFor, they are also cloned in the returned + * WaitFor. + * + * Subclasses must implement this method. + * + * @return A deep copy of this WaitFor. + */ + virtual WaitFor* clone() const = 0; + + /** + * Deep comparison of this WaitFor to the given one. + * Two WaitFor are equal if they contain the same data and, if they contain + * child WaitFor, if their child WaitFor are equal one to one. The child + * WaitFor aren't checked for identity, but for equality (that is, it is + * checked if they are equal, no matter whether they are the same object or + * not). + * + * Subclasses must implement this method. + * + * @param waitFor The WaitFor to compare to. + * @return True if this WaitFor is equal to the given one, false otherwise. + */ + virtual bool equals(const WaitFor& waitFor) const = 0; + + /** + * Equality operator. + * + * @param waitFor The WaitFor to compare to. + * @return True if this WaitFor is equal to the given one, false otherwise. + */ + bool operator==(const WaitFor& waitFor) const; + + /** + * Inequality operator. + * + * @param waitFor The WaitFor to compare to. + * @return True if this WaitFor is not equal to the given one, false + * otherwise. + */ + bool operator!=(const WaitFor& waitFor) const; + Q_SIGNALS: /** Modified: trunk/ktutorial/ktutorial-editor/src/WaitForComposed.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/WaitForComposed.cpp 2010-03-14 17:15:38 UTC (rev 153) +++ trunk/ktutorial/ktutorial-editor/src/WaitForComposed.cpp 2010-03-15 06:56:15 UTC (rev 154) @@ -29,6 +29,41 @@ qDeleteAll(mWaitFors); } +WaitFor* WaitForComposed::clone() const { + WaitForComposed* cloned = new WaitForComposed(); + cloned->setCompositionType(mCompositionType); + + foreach (WaitFor* waitFor, mWaitFors) { + cloned->addWaitFor(waitFor->clone()); + } + + return cloned; +} + +bool WaitForComposed::equals(const WaitFor& waitFor) const { + if (!qobject_cast<const WaitForComposed*>(&waitFor)) { + return false; + } + + const WaitForComposed* waitForComposed = + static_cast<const WaitForComposed*>(&waitFor); + if (waitForComposed->compositionType() != mCompositionType) { + return false; + } + + if (waitForComposed->waitFors().count() != mWaitFors.count()) { + return false; + } + + for (int i=0; i<mWaitFors.count(); ++i) { + if (*waitForComposed->waitFors()[i] != *mWaitFors[i]) { + return false; + } + } + + return true; +} + WaitForComposed::CompositionType WaitForComposed::compositionType() const { return mCompositionType; } Modified: trunk/ktutorial/ktutorial-editor/src/WaitForComposed.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/WaitForComposed.h 2010-03-14 17:15:38 UTC (rev 153) +++ trunk/ktutorial/ktutorial-editor/src/WaitForComposed.h 2010-03-15 06:56:15 UTC (rev 154) @@ -49,6 +49,9 @@ WaitForComposed(QObject* parent = 0); virtual ~WaitForComposed(); + virtual WaitFor* clone() const; + virtual bool equals(const WaitFor& waitFor) const; + CompositionType compositionType() const; void setCompositionType(CompositionType compositionType); Modified: trunk/ktutorial/ktutorial-editor/src/WaitForNot.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/WaitForNot.cpp 2010-03-14 17:15:38 UTC (rev 153) +++ trunk/ktutorial/ktutorial-editor/src/WaitForNot.cpp 2010-03-15 06:56:15 UTC (rev 154) @@ -29,6 +29,36 @@ delete mNegatedWaitFor; } +WaitFor* WaitForNot::clone() const { + WaitForNot* cloned = new WaitForNot(); + if (mNegatedWaitFor) { + cloned->setNegatedWaitFor(mNegatedWaitFor->clone()); + } + + return cloned; +} + +bool WaitForNot::equals(const WaitFor& waitFor) const { + if (!qobject_cast<const WaitForNot*>(&waitFor)) { + return false; + } + + const WaitForNot* waitForNot = static_cast<const WaitForNot*>(&waitFor); + if (waitForNot->negatedWaitFor() == 0 && mNegatedWaitFor == 0) { + return true; + } + + if (waitForNot->negatedWaitFor() == 0 || mNegatedWaitFor == 0) { + return false; + } + + if (*waitForNot->negatedWaitFor() != *mNegatedWaitFor) { + return false; + } + + return true; +} + WaitFor* WaitForNot::negatedWaitFor() const { return mNegatedWaitFor; } Modified: trunk/ktutorial/ktutorial-editor/src/WaitForNot.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/WaitForNot.h 2010-03-14 17:15:38 UTC (rev 153) +++ trunk/ktutorial/ktutorial-editor/src/WaitForNot.h 2010-03-15 06:56:15 UTC (rev 154) @@ -43,6 +43,9 @@ WaitForNot(QObject* parent = 0); virtual ~WaitForNot(); + virtual WaitFor* clone() const; + virtual bool equals(const WaitFor& waitFor) const; + WaitFor* negatedWaitFor() const; /** Modified: trunk/ktutorial/ktutorial-editor/src/WaitForSignal.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/WaitForSignal.cpp 2010-03-14 17:15:38 UTC (rev 153) +++ trunk/ktutorial/ktutorial-editor/src/WaitForSignal.cpp 2010-03-15 06:56:15 UTC (rev 154) @@ -23,6 +23,32 @@ WaitForSignal::WaitForSignal(QObject* parent): WaitFor(parent) { } +WaitFor* WaitForSignal::clone() const { + WaitForSignal* cloned = new WaitForSignal(); + cloned->setEmitterName(mEmitterName); + cloned->setSignalName(mSignalName); + + return cloned; +} + +bool WaitForSignal::equals(const WaitFor& waitFor) const { + if (!qobject_cast<const WaitForSignal*>(&waitFor)) { + return false; + } + + const WaitForSignal* waitForSignal = + static_cast<const WaitForSignal*>(&waitFor); + if (waitForSignal->emitterName() != mEmitterName) { + return false; + } + + if (waitForSignal->signalName() != mSignalName) { + return false; + } + + return true; +} + QString WaitForSignal::emitterName() const { return mEmitterName; } Modified: trunk/ktutorial/ktutorial-editor/src/WaitForSignal.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/WaitForSignal.h 2010-03-14 17:15:38 UTC (rev 153) +++ trunk/ktutorial/ktutorial-editor/src/WaitForSignal.h 2010-03-15 06:56:15 UTC (rev 154) @@ -41,6 +41,9 @@ */ WaitForSignal(QObject* parent = 0); + virtual WaitFor* clone() const; + virtual bool equals(const WaitFor& waitFor) const; + QString emitterName() const; void setEmitterName(const QString& emitterName); Modified: trunk/ktutorial/ktutorial-editor/tests/unit/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/CMakeLists.txt 2010-03-14 17:15:38 UTC (rev 153) +++ trunk/ktutorial/ktutorial-editor/tests/unit/CMakeLists.txt 2010-03-15 06:56:15 UTC (rev 154) @@ -18,6 +18,7 @@ Reaction Step Tutorial + WaitFor WaitForComposed WaitForNot WaitForSignal @@ -33,6 +34,7 @@ Reaction Step Tutorial + WaitFor WaitForComposed WaitForNot WaitForSignal Modified: trunk/ktutorial/ktutorial-editor/tests/unit/WaitForComposedTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/WaitForComposedTest.cpp 2010-03-14 17:15:38 UTC (rev 153) +++ trunk/ktutorial/ktutorial-editor/tests/unit/WaitForComposedTest.cpp 2010-03-15 06:56:15 UTC (rev 154) @@ -29,6 +29,11 @@ void testConstructor(); + void testClone(); + void testCloneEmpty(); + + void testEquals(); + void testSetCompositionType(); void testAddWaitFor(); @@ -43,6 +48,28 @@ }; +class StubWaitFor: public WaitFor { +Q_OBJECT +public: + + int mValue; + + StubWaitFor(int value = 0): mValue(value) { + } + + virtual WaitFor* clone() const { + return new StubWaitFor(mValue); + } + + virtual bool equals(const WaitFor& waitFor) const { + if (!qobject_cast<const StubWaitFor*>(&waitFor)) { + return false; + } + + return mValue == static_cast<const StubWaitFor*>(&waitFor)->mValue; + } +}; + void WaitForComposedTest::initTestCase() { //WaitFor* must be registered in order to be used with QSignalSpy mWaitForStarType = qRegisterMetaType<WaitFor*>("WaitFor*"); @@ -56,6 +83,89 @@ QCOMPARE(waitForComposed->compositionType(), WaitForComposed::And); } +void WaitForComposedTest::testClone() { + WaitForComposed waitForComposed; + waitForComposed.setCompositionType(WaitForComposed::Or); + StubWaitFor* waitFor1 = new StubWaitFor(4); + waitForComposed.addWaitFor(waitFor1); + StubWaitFor* waitFor2 = new StubWaitFor(8); + waitForComposed.addWaitFor(waitFor2); + StubWaitFor* waitFor3 = new StubWaitFor(15); + waitForComposed.addWaitFor(waitFor3); + + WaitForComposed* cloned = + static_cast<WaitForComposed*>(waitForComposed.clone()); + + QVERIFY(cloned != &waitForComposed); + QCOMPARE(cloned->compositionType(), WaitForComposed::Or); + QCOMPARE(cloned->waitFors().count(), 3); + QVERIFY(cloned->waitFors()[0] != waitFor1); + QVERIFY(*cloned->waitFors()[0] == *waitFor1); + QVERIFY(cloned->waitFors()[1] != waitFor2); + QVERIFY(*cloned->waitFors()[1] == *waitFor2); + QVERIFY(cloned->waitFors()[2] != waitFor3); + QVERIFY(*cloned->waitFors()[2] == *waitFor3); + delete cloned; +} + +void WaitForComposedTest::testCloneEmpty() { + WaitForComposed waitForComposed; + waitForComposed.setCompositionType(WaitForComposed::Or); + + WaitForComposed* cloned = + static_cast<WaitForComposed*>(waitForComposed.clone()); + + QVERIFY(cloned != &waitForComposed); + QCOMPARE(cloned->compositionType(), WaitForComposed::Or); + QCOMPARE(cloned->waitFors().count(), 0); + delete cloned; +} + +void WaitForComposedTest::testEquals() { + WaitForComposed waitForComposed1; + WaitForComposed waitForComposed2; + + QCOMPARE(waitForComposed1 == waitForComposed2, true); + + waitForComposed1.setCompositionType(WaitForComposed::Or); + + QCOMPARE(waitForComposed1 == waitForComposed2, false); + QCOMPARE(waitForComposed2 == waitForComposed1, false); + + waitForComposed2.setCompositionType(WaitForComposed::Or); + + QCOMPARE(waitForComposed1 == waitForComposed2, true); + + StubWaitFor* waitFor1_1 = new StubWaitFor(4); + waitForComposed1.addWaitFor(waitFor1_1); + StubWaitFor* waitFor1_2 = new StubWaitFor(8); + waitForComposed1.addWaitFor(waitFor1_2); + StubWaitFor* waitFor1_3 = new StubWaitFor(15); + waitForComposed1.addWaitFor(waitFor1_3); + + QCOMPARE(waitForComposed1 == waitForComposed2, false); + QCOMPARE(waitForComposed2 == waitForComposed1, false); + + StubWaitFor* waitFor2_1 = new StubWaitFor(4); + waitForComposed2.addWaitFor(waitFor2_1); + StubWaitFor* waitFor2_2 = new StubWaitFor(8); + waitForComposed2.addWaitFor(waitFor2_2); + StubWaitFor* waitFor2_3 = new StubWaitFor(16); + waitForComposed2.addWaitFor(waitFor2_3); + + QCOMPARE(waitForComposed1 == waitForComposed2, false); + QCOMPARE(waitForComposed2 == waitForComposed1, false); + + waitFor2_3->mValue = 15; + + QCOMPARE(waitForComposed1 == waitForComposed2, true); + QCOMPARE(waitForComposed2 == waitForComposed1, true); + + StubWaitFor stubWaitFor; + + QCOMPARE(waitForComposed1 == stubWaitFor, false); +} + void WaitForComposedTest::testSetCompositionType() { WaitForComposed waitForComposed; @@ -70,9 +180,9 @@ void WaitForComposedTest::testAddWaitFor() { WaitForComposed waitForComposed; - WaitFor* waitFor1 = new WaitFor(); - WaitFor* waitFor2 = new WaitFor(); - WaitFor* waitFor3 = new WaitFor(); + WaitFor* waitFor1 = new StubWaitFor(); + WaitFor* waitFor2 = new StubWaitFor(); + WaitFor* waitFor3 = new StubWaitFor(); QSignalSpy waitForAddedSpy(&waitForComposed, SIGNAL(waitForAdded(WaitFor*))); @@ -96,9 +206,9 @@ //They will be removed and not deleted by the WaitForComposed, so they are //created in stack - WaitFor waitFor1; - WaitFor waitFor2; - WaitFor waitFor3; + StubWaitFor waitFor1; + StubWaitFor waitFor2; + StubWaitFor waitFor3; waitForComposed.addWaitFor(&waitFor1); waitForComposed.addWaitFor(&waitFor2); Modified: trunk/ktutorial/ktutorial-editor/tests/unit/WaitForNotTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/WaitForNotTest.cpp 2010-03-14 17:15:38 UTC (rev 153) +++ trunk/ktutorial/ktutorial-editor/tests/unit/WaitForNotTest.cpp 2010-03-15 06:56:15 UTC (rev 154) @@ -27,10 +27,37 @@ void testConstructor(); + void testClone(); + void testCloneEmpty(); + + void testEquals(); + void testSetNegatedWaitFor(); }; +class StubWaitFor: public WaitFor { +Q_OBJECT +public: + + int mValue; + + StubWaitFor(int value = 0): mValue(value) { + } + + virtual WaitFor* clone() const { + return new StubWaitFor(mValue); + } + + virtual bool equals(const WaitFor& waitFor) const { + if (!qobject_cast<const StubWaitFor*>(&waitFor)) { + return false; + } + + return mValue == static_cast<const StubWaitFor*>(&waitFor)->mValue; + } +}; + void WaitForNotTest::testConstructor() { QObject parent; WaitForNot* waitForNot = new WaitForNot(&parent); @@ -39,12 +66,63 @@ QCOMPARE(waitForNot->negatedWaitFor(), (WaitFor*)0); } +void WaitForNotTest::testClone() { + WaitForNot waitForNot; + StubWaitFor* negatedWaitFor = new StubWaitFor(16); + waitForNot.setNegatedWaitFor(negatedWaitFor); + + WaitForNot* cloned = static_cast<WaitForNot*>(waitForNot.clone()); + + QVERIFY(cloned != &waitForNot); + QVERIFY(cloned->negatedWaitFor() != negatedWaitFor); + QVERIFY(*cloned->negatedWaitFor() == *negatedWaitFor); + delete cloned; +} + +void WaitForNotTest::testCloneEmpty() { + WaitForNot waitForNot; + + WaitForNot* cloned = static_cast<WaitForNot*>(waitForNot.clone()); + + QVERIFY(cloned != &waitForNot); + QCOMPARE(cloned->negatedWaitFor(), (WaitFor*)0); + delete cloned; +} + +void WaitForNotTest::testEquals() { + WaitForNot waitForNot1; + WaitForNot waitForNot2; + + QCOMPARE(waitForNot1 == waitForNot2, true); + + StubWaitFor* negatedWaitFor1 = new StubWaitFor(4); + waitForNot1.setNegatedWaitFor(negatedWaitFor1); + + QCOMPARE(waitForNot1 == waitForNot2, false); + QCOMPARE(waitForNot2 == waitForNot1, false); + + StubWaitFor* negatedWaitFor2 = new StubWaitFor(); + waitForNot2.setNegatedWaitFor(negatedWaitFor2); + + QCOMPARE(waitForNot1 == waitForNot2, false); + QCOMPARE(waitForNot2 == waitForNot1, false); + + negatedWaitFor2->mValue = 4; + + QCOMPARE(waitForNot1 == waitForNot2, true); + QCOMPARE(waitForNot2 == waitForNot1, true); + + StubWaitFor stubWaitFor; + + QCOMPARE(waitForNot1 == stubWaitFor, false); +} + //WaitFor* must be declared as a metatype to be used in qvariant_cast Q_DECLARE_METATYPE(WaitFor*); void WaitForNotTest::testSetNegatedWaitFor() { WaitForNot waitForNot; - WaitFor* negatedWaitFor = new WaitFor(); + WaitFor* negatedWaitFor = new StubWaitFor(); //WaitFor* must be registered in order to be used with QSignalSpy int waitForStarType = qRegisterMetaType<WaitFor*>("WaitFor*"); Modified: trunk/ktutorial/ktutorial-editor/tests/unit/WaitForSignalTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/WaitForSignalTest.cpp 2010-03-14 17:15:38 UTC (rev 153) +++ trunk/ktutorial/ktutorial-editor/tests/unit/WaitForSignalTest.cpp 2010-03-15 06:56:15 UTC (rev 154) @@ -29,6 +29,10 @@ void testConstructor(); + void testClone(); + + void testEquals(); + void testSetEmitterName(); void testSetSignalName(); @@ -42,6 +46,28 @@ }; +class StubWaitFor: public WaitFor { +Q_OBJECT +public: + + int mValue; + + StubWaitFor(int value = 0): mValue(value) { + } + + virtual WaitFor* clone() const { + return new StubWaitFor(mValue); + } + + virtual bool equals(const WaitFor& waitFor) const { + if (!qobject_cast<const StubWaitFor*>(&waitFor)) { + return false; + } + + return mValue == static_cast<const StubWaitFor*>(&waitFor)->mValue; + } +}; + void WaitForSignalTest::initTestCase() { //WaitFor* must be registered in order to be used with QSignalSpy mWaitForStarType = qRegisterMetaType<WaitFor*>("WaitFor*"); @@ -54,6 +80,37 @@ QCOMPARE(waitForSignal->parent(), &parent); } +void WaitForSignalTest::testClone() { + WaitForSignal waitForSignal; + + WaitForSignal* cloned = static_cast<WaitForSignal*>(waitForSignal.clone()); + + QVERIFY(cloned != &waitForSignal); + QCOMPARE(cloned->emitterName(), waitForSignal.emitterName()); + QCOMPARE(cloned->signalName(), waitForSignal.signalName()); + delete cloned; +} + +void WaitForSignalTest::testEquals() { + WaitForSignal waitForSignal1; + waitForSignal1.setEmitterName("The emitter name"); + waitForSignal1.setSignalName("The signal name"); + WaitForSignal waitForSignal2; + + QCOMPARE(waitForSignal1 == waitForSignal2, false); + QCOMPARE(waitForSignal2 == waitForSignal1, false); + + waitForSignal2.setEmitterName("The emitter name"); + waitForSignal2.setSignalName("The signal name"); + + QCOMPARE(waitForSignal1 == waitForSignal2, true); + QCOMPARE(waitForSignal2 == waitForSignal1, true); + + StubWaitFor stubWaitFor; + + QCOMPARE(waitForSignal1 == stubWaitFor, false); +} + void WaitForSignalTest::testSetEmitterName() { WaitForSignal waitForSignal; Added: trunk/ktutorial/ktutorial-editor/tests/unit/WaitForTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/WaitForTest.cpp (rev 0) +++ trunk/ktutorial/ktutorial-editor/tests/unit/WaitForTest.cpp 2010-03-15 06:56:15 UTC (rev 154) @@ -0,0 +1,64 @@ +/*************************************************************************** + * Copyright (C) 2010 by Daniel Calviño Sánchez * + * dan...@gm... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; If not, see <http://www.gnu.org/licenses/>. * + ***************************************************************************/ + +#include <QtTest> + +#include "WaitFor.h" + +class WaitForTest: public QObject { +Q_OBJECT + +private slots: + + void testOperatorEqual(); + + void testOperatorNotEqual(); + +}; + +class StubWaitFor: public WaitFor { +public: + + virtual WaitFor* clone() const { + return 0; + } + + virtual bool equals(const WaitFor& waitFor) const { + Q_UNUSED(waitFor); + return false; + } + +}; + +void WaitForTest::testOperatorEqual() { + StubWaitFor waitFor1; + StubWaitFor waitFor2; + + QCOMPARE(waitFor1 == waitFor2, false); +} + +void WaitForTest::testOperatorNotEqual() { + StubWaitFor waitFor1; + StubWaitFor waitFor2; + + QCOMPARE(waitFor1 != waitFor2, true); +} + +QTEST_MAIN(WaitForTest) + +#include "WaitForTest.moc" Property changes on: trunk/ktutorial/ktutorial-editor/tests/unit/WaitForTest.cpp ___________________________________________________________________ Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |