From ddb4f8775df38b10c3ffbfc10acd5b64a5707ea1 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Thu, 12 Dec 2013 14:39:55 -0800 Subject: [PATCH] Fixed UnitTest code and bugs found by unit tests --- src/qgcunittest/UASUnitTest.cc | 22 +++++++++++----------- src/uas/UAS.cc | 9 +++++++++ 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/qgcunittest/UASUnitTest.cc b/src/qgcunittest/UASUnitTest.cc index 58537f57f..7affa092c 100644 --- a/src/qgcunittest/UASUnitTest.cc +++ b/src/qgcunittest/UASUnitTest.cc @@ -178,23 +178,23 @@ void UASUnitTest::getSystemType_test() void UASUnitTest::getAirframe_test() { - //when uas is constructed, airframe is set to QGC_AIRFRAME_GENERIC which is 0 - QCOMPARE(uas->getAirframe(), 0); + //when uas is constructed, airframe is set to QGC_AIRFRAME_GENERIC + QVERIFY(uas->getAirframe() == UASInterface::QGC_AIRFRAME_GENERIC); } void UASUnitTest::setAirframe_test() { //check at construction, that airframe=0 (GENERIC) - QVERIFY(uas->getAirframe() == 0); + QVERIFY(uas->getAirframe() == UASInterface::QGC_AIRFRAME_GENERIC); //check that set airframe works - uas->setAirframe(11); - QVERIFY(uas->getAirframe() == 11); + uas->setAirframe(UASInterface::QGC_AIRFRAME_HEXCOPTER); + QVERIFY(uas->getAirframe() == UASInterface::QGC_AIRFRAME_HEXCOPTER); //check that setAirframe will not assign a number to airframe, that is //not defined in the enum - uas->setAirframe(12); - QVERIFY(uas->getAirframe() == 11); + uas->setAirframe(UASInterface::QGC_AIRFRAME_END_OF_ENUM); + QVERIFY(uas->getAirframe() == UASInterface::QGC_AIRFRAME_HEXCOPTER); } void UASUnitTest::getWaypointList_test() @@ -391,10 +391,10 @@ void UASUnitTest::signalIdUASLink_test() LinkInterface* b = static_cast(links.at(1)); LinkInterface* c = static_cast(links.at(2)); LinkInterface* d = static_cast(links.at(3)); - QCOMPARE(a->getName(), QString("serial port COM 17")); - QCOMPARE(b->getName(), QString("serial port COM 18")); - QCOMPARE(c->getName(), QString("serial port COM 19")); - QCOMPARE(d->getName(), QString("serial port COM 20")); + QCOMPARE(a->getName(), QString("COM 17")); + QCOMPARE(b->getName(), QString("COM 18")); + QCOMPARE(c->getName(), QString("COM 19")); + QCOMPARE(d->getName(), QString("COM 20")); LinkManager::instance()->removeLink(myLink4); delete myLink4; diff --git a/src/uas/UAS.cc b/src/uas/UAS.cc index 8d5be0668..cc3daa6ad 100644 --- a/src/uas/UAS.cc +++ b/src/uas/UAS.cc @@ -109,6 +109,11 @@ UAS::UAS(MAVLinkProtocol* protocol, int id) : UASInterface(), localX(0.0), localY(0.0), localZ(0.0), + + latitude(0.0), + longitude(0.0), + altitude(0.0), + globalEstimatorActive(false), latitude_gps(0.0), longitude_gps(0.0), @@ -131,6 +136,10 @@ UAS::UAS(MAVLinkProtocol* protocol, int id) : UASInterface(), attitudeStamped(false), lastAttitude(0), + roll(0.0), + pitch(0.0), + yaw(0.0), + paramsOnceRequested(false), simulation(0), -- 2.22.0