clang-format tests

This commit is contained in:
Lars Toenning
2023-04-12 21:44:17 +02:00
parent 674710f146
commit ba41d4887b
28 changed files with 266 additions and 238 deletions

View File

@@ -22,7 +22,7 @@
#include <QTest>
#ifdef Q_OS_WIN
#include "comdef.h"
# include "comdef.h"
#endif
using namespace BlackMisc;

View File

@@ -10,9 +10,9 @@
//! \cond PRIVATE_TESTS
/*!
* \file
* \ingroup testblackfsd
*/
* \file
* \ingroup testblackfsd
*/
#include "blackconfig/buildconfig.h"
#include "blackcore/fsd/fsdclient.h"
@@ -156,7 +156,6 @@ namespace BlackFsdTest
void CTestFSDClient::testConstructor()
{
}
void CTestFSDClient::testDeleteAtc()
@@ -868,8 +867,7 @@ namespace BlackFsdTest
QCOMPARE(CConnectionStatus::Connected, arguments.at(1).value<CConnectionStatus>().getConnectionStatus());
QSignalSpy pongSpy(m_client, &CFSDClient::pongReceived);
connect(m_client, &CFSDClient::pongReceived, [](const QString & sender, double elapsedTimeM)
{
connect(m_client, &CFSDClient::pongReceived, [](const QString &sender, double elapsedTimeM) {
qDebug() << "Received pong from" << sender << "in" << elapsedTimeM << "ms";
});
m_client->sendPing("SERVER");

View File

@@ -10,9 +10,9 @@
//! \cond PRIVATE_TESTS
/*!
* \file
* \ingroup testblackfsd
*/
* \file
* \ingroup testblackfsd
*/
#include "blackconfig/buildconfig.h"
#include "blackcore/fsd/addatc.h"
@@ -196,7 +196,6 @@ namespace BlackMiscTest
const QStringList tokens = QString("ABCD:SERVER:7a57f2dd9d360d347b").split(':');
const AuthResponse messageFromTokens = AuthResponse::fromTokens(tokens);
QCOMPARE(messageFromTokens, message);
}
void CTestFsdMessages::testClientIdentification()
@@ -225,37 +224,37 @@ namespace BlackMiscTest
void CTestFsdMessages::testClientQuery()
{
// const ClientQuery message("ABCD", "@94835", Client::WhoIsTracking);
// QCOMPARE(message.sender(), QString("ABCD"));
// QCOMPARE(QString("@94835"), message.receiver());
// QCOMPARE(ClientQueryType::WhoIsTracking, message.m_queryType);
// QCOMPARE(QStringList(), message.m_payload);
// const ClientQuery message("ABCD", "@94835", Client::WhoIsTracking);
// QCOMPARE(message.sender(), QString("ABCD"));
// QCOMPARE(QString("@94835"), message.receiver());
// QCOMPARE(ClientQueryType::WhoIsTracking, message.m_queryType);
// QCOMPARE(QStringList(), message.m_payload);
// const ClientQuery pdu2("ABCD", "@94835", ClientQueryType::WhoIsTracking, {"LHA449"});
// QCOMPARE(QString("ABCD"), pdu2.sender());
// QCOMPARE(QString("@94835"), pdu2.receiver());
// QCOMPARE(ClientQueryType::WhoIsTracking, pdu2.m_queryType);
// QCOMPARE(QStringList {"LHA449"}, pdu2.m_payload);
// const ClientQuery pdu2("ABCD", "@94835", ClientQueryType::WhoIsTracking, {"LHA449"});
// QCOMPARE(QString("ABCD"), pdu2.sender());
// QCOMPARE(QString("@94835"), pdu2.receiver());
// QCOMPARE(ClientQueryType::WhoIsTracking, pdu2.m_queryType);
// QCOMPARE(QStringList {"LHA449"}, pdu2.m_payload);
// const ClientQuery message("ABCD", "@94835", ClientQueryType::WhoIsTracking, {"LHA449"});
// QString stringRef("ABCD:@94835:WH:LHA449");
// QString str = message.toTokens().join(":");
// QCOMPARE(str, stringRef);
// const ClientQuery message("ABCD", "@94835", ClientQueryType::WhoIsTracking, {"LHA449"});
// QString stringRef("ABCD:@94835:WH:LHA449");
// QString str = message.toTokens().join(":");
// QCOMPARE(str, stringRef);
// const ClientQuery reference("ABCD", "@94835", ClientQueryType::WhoIsTracking, {"LHA449"});
// const ClientQuery reference("ABCD", "@94835", ClientQueryType::WhoIsTracking, {"LHA449"});
// QStringList tokens = QString("ABCD:@94835:WH:LHA449").split(':');
// const ClientQuery messageFromTokens = ClientQuery::fromTokens(tokens);
// QCOMPARE(messageFromTokens, message);
// QStringList tokens = QString("ABCD:@94835:WH:LHA449").split(':');
// const ClientQuery messageFromTokens = ClientQuery::fromTokens(tokens);
// QCOMPARE(messageFromTokens, message);
}
void CTestFsdMessages::testClientResponse()
{
const ClientResponse message("ABCD", "SERVER", ClientQueryType::Capabilities, {"MODELDESC=1","ATCINFO=1"});
const ClientResponse message("ABCD", "SERVER", ClientQueryType::Capabilities, { "MODELDESC=1", "ATCINFO=1" });
QCOMPARE(message.sender(), QString("ABCD"));
QCOMPARE(message.receiver(), QString("SERVER"));
QCOMPARE(ClientQueryType::Capabilities, message.m_queryType);
QStringList reference {"MODELDESC=1","ATCINFO=1"};
QStringList reference { "MODELDESC=1", "ATCINFO=1" };
QCOMPARE(reference, message.m_responseData);
QString stringRef("ABCD:SERVER:CAPS:MODELDESC=1:ATCINFO=1");
@@ -299,7 +298,6 @@ namespace BlackMiscTest
QStringList tokens = QString("ABCD:1234567").split(':');
auto messageFromTokens = DeletePilot::fromTokens(tokens);
QCOMPARE(messageFromTokens, message);
}
void CTestFsdMessages::testEuroscopeSimData()
@@ -344,7 +342,7 @@ namespace BlackMiscTest
void CTestFsdMessages::testFlightPlan()
{
const FlightPlan message("ABCD", "SERVER", FlightType::VFR, "B744", 420, "EGLL", 1530, 1535, "FL350", "KORD", 8, 15,
9, 30, "NONE", "Unit Test", "EGLL.KORD");
9, 30, "NONE", "Unit Test", "EGLL.KORD");
QCOMPARE(message.sender(), QString("ABCD"));
QCOMPARE(message.receiver(), QString("SERVER"));
@@ -375,7 +373,6 @@ namespace BlackMiscTest
void CTestFsdMessages::testFSDIdentification()
{
}
void CTestFsdMessages::testInterimPilotDataUpdate()
@@ -430,10 +427,13 @@ namespace BlackMiscTest
void CTestFsdMessages::testPBH()
{
struct PBH { int pitch, bank, heading; };
struct PBH
{
int pitch, bank, heading;
};
QVector<PBH> testData;
for (int pitch = -90; pitch < 90; pitch++) { testData.push_back({ pitch, 0, 0 }); }
for (int bank = -179; bank < 180; bank++) { testData.push_back({ 0, bank, 0 }); }
for (int pitch = -90; pitch < 90; pitch++) { testData.push_back({ pitch, 0, 0 }); }
for (int bank = -179; bank < 180; bank++) { testData.push_back({ 0, bank, 0 }); }
for (int heading = 0; heading < 360; heading++) { testData.push_back({ 0, 0, heading }); }
for (const auto &input : testData)
{
@@ -463,7 +463,7 @@ namespace BlackMiscTest
void CTestFsdMessages::testPilotDataUpdate()
{
const PilotDataUpdate message(CTransponder::ModeC, "ABCD", 7000, PilotRating::Student, 43.12578, -72.15841, 12000, 12008,
125, -2, 3, 280, true);
125, -2, 3, 280, true);
QCOMPARE(message.sender(), QString("ABCD"));
QCOMPARE(QString(""), message.receiver());
@@ -706,7 +706,6 @@ namespace BlackMiscTest
void CTestFsdMessages::testTextMessage()
{
}
}

View File

@@ -13,12 +13,10 @@
//! \file
//! \ingroup testblackcore
namespace BlackCoreTest
{
} //namespace
} // namespace
//! \endcond

View File

@@ -63,8 +63,8 @@ namespace BlackCoreTest
private:
BlackCore::Db::CAirportDataReader *m_airportReader = nullptr;
BlackCore::Db::CIcaoDataReader *m_icaoReader = nullptr;
BlackCore::Db::CModelDataReader *m_modelReader = nullptr;
BlackCore::Db::CIcaoDataReader *m_icaoReader = nullptr;
BlackCore::Db::CModelDataReader *m_modelReader = nullptr;
//! Test if server is available
static bool connectServer(const BlackMisc::Network::CUrl &url);
@@ -84,7 +84,11 @@ namespace BlackCoreTest
{
const CUrl url(sApp->getGlobalSetup().getDbIcaoReaderUrl());
qDebug() << "Reader URL" << url.toQString();
if (!this->connectServer(url)) { QSKIP("Server not reachable."); return; }
if (!this->connectServer(url))
{
QSKIP("Server not reachable.");
return;
}
m_icaoReader->start();
m_icaoReader->readInBackgroundThread(CEntityFlags::AllIcaoEntities, QDateTime());
@@ -135,7 +139,11 @@ namespace BlackCoreTest
{
const CUrl url(sApp->getGlobalSetup().getDbModelReaderUrl());
qDebug() << "Reader URL" << url.toQString();
if (!this->connectServer(url)) { QSKIP("Server not reachable."); return; }
if (!this->connectServer(url))
{
QSKIP("Server not reachable.");
return;
}
m_modelReader->start();
m_modelReader->readInBackgroundThread(CEntityFlags::ModelEntity, QDateTime());
@@ -161,7 +169,11 @@ namespace BlackCoreTest
const CUrl url(sApp->getGlobalSetup().getDbAirportReaderUrl());
qDebug() << "Reader URL" << url.toQString();
if (!this->connectServer(url)) { QSKIP("Server not reachable."); return; }
if (!this->connectServer(url))
{
QSKIP("Server not reachable.");
return;
}
m_airportReader->start();
m_airportReader->readInBackgroundThread(CEntityFlags::AirportEntity, QDateTime());

View File

@@ -21,8 +21,7 @@
namespace BlackGuiTest
{
} //namespace
} // namespace
//! \endcond

View File

@@ -272,7 +272,7 @@ namespace BlackMiscTest
const auto hint = std::make_pair(time.elapsed(), getThreadCpuTimeMs() - cpuTime);
const double ratio = static_cast<double>(hint.second) / static_cast<double>(noHint.second); // expected <1.0
//qDebug() << "MacOS:" << boolToYesNo(CBuildConfig::isRunningOnMacOSPlatform());
// qDebug() << "MacOS:" << boolToYesNo(CBuildConfig::isRunningOnMacOSPlatform());
qDebug() << "Access without hint" << noHint.first << "ms (CPU time" << noHint.second << "ms)";
qDebug() << "Access with hint" << hint.first << "ms (CPU time" << hint.second << "ms)";
qDebug() << "Access ratio" << ratio;

View File

@@ -238,8 +238,7 @@ namespace BlackMiscTest
CCoordinateGeodetic(
CLatitude::fromWgs84("N 049° 18' 17"),
CLongitude::fromWgs84("E 008° 27' 05"),
CAltitude(312, CLengthUnit::ft()))
);
CAltitude(312, CLengthUnit::ft())));
const CAircraftSituation situation2(situation1);
QVERIFY2(situation1 == situation2, "situations shall be equal");
@@ -285,8 +284,10 @@ namespace BlackMiscTest
const CAircraftIcaoCode icaoB737("B737", "L2J");
const CAircraftIcaoCode icaoB747("B747", "L4J");
CSpeed s172, sB737, sB747; s172 = sB737 = sB747 = CSpeed::null();
CLength cg172, cgB737, cgB747; cg172 = cgB737 = cgB747 = CLength::null();
CSpeed s172, sB737, sB747;
s172 = sB737 = sB747 = CSpeed::null();
CLength cg172, cgB737, cgB747;
cg172 = cgB737 = cgB747 = CLength::null();
icao172.guessModelParameters(cg172, s172);
icaoB737.guessModelParameters(cgB737, sB737);
icaoB747.guessModelParameters(cgB747, sB747);

View File

@@ -93,12 +93,12 @@ namespace BlackMiscTest
CHotkeyCombination comb1;
comb1.addKeyboardKey(Key_ControlLeft);
comb1.addKeyboardKey(Key_D);
CActionHotkey actionHotkey1 (CIdentifier::anonymous(), comb1, "action");
CActionHotkey actionHotkey1(CIdentifier::anonymous(), comb1, "action");
CHotkeyCombination comb2;
comb2.addKeyboardKey(Key_ControlLeft);
comb2.addKeyboardKey(Key_D);
CActionHotkey actionHotkey2 (CIdentifier::anonymous(), comb2, "action");
CActionHotkey actionHotkey2(CIdentifier::anonymous(), comb2, "action");
QVERIFY2(actionHotkey1 == actionHotkey2, "Objects should equal");
}
@@ -107,24 +107,24 @@ namespace BlackMiscTest
CHotkeyCombination comb;
comb.addKeyboardKey(Key_ControlLeft);
comb.addKeyboardKey(Key_D);
CActionHotkey actionHotkey1 (CIdentifier::anonymous(), comb, "action");
CActionHotkey actionHotkey1(CIdentifier::anonymous(), comb, "action");
CHotkeyCombination comb2;
comb2.addKeyboardKey(Key_ControlLeft);
comb2.addKeyboardKey(Key_C);
CActionHotkey actionHotkey2 (CIdentifier::anonymous(), comb2, "action");
CActionHotkey actionHotkey2(CIdentifier::anonymous(), comb2, "action");
QVERIFY2(actionHotkey1 != actionHotkey2, "Objects should not be equal");
CHotkeyCombination comb3;
comb3.addKeyboardKey(Key_ShiftLeft);
comb3.addKeyboardKey(Key_D);
CActionHotkey actionHotkey3 (CIdentifier::anonymous(), comb2, "action");
CActionHotkey actionHotkey3(CIdentifier::anonymous(), comb2, "action");
QVERIFY2(actionHotkey1 != actionHotkey3, "Objects should not be equal");
CHotkeyCombination comb4;
comb4.addKeyboardKey(Key_ControlLeft);
comb4.addKeyboardKey(Key_D);
CActionHotkey actionHotkey4 (CIdentifier::anonymous(), comb2, "other_action");
CActionHotkey actionHotkey4(CIdentifier::anonymous(), comb2, "other_action");
QVERIFY2(actionHotkey1 != actionHotkey4, "Objects should not be equal");
}
@@ -133,14 +133,14 @@ namespace BlackMiscTest
CHotkeyCombination comb1;
comb1.addKeyboardKey(Key_ControlLeft);
comb1.addKeyboardKey(Key_C);
CActionHotkey actionHotkey1 (CIdentifier::anonymous(), comb1, "action");
CActionHotkey actionHotkey1(CIdentifier::anonymous(), comb1, "action");
CActionHotkeyList list1;
list1.push_back(actionHotkey1);
CHotkeyCombination comb2;
comb2.addKeyboardKey(Key_ControlLeft);
comb2.addKeyboardKey(Key_D);
CActionHotkey actionHotkey2 (CIdentifier::anonymous(), comb2, "action");
CActionHotkey actionHotkey2(CIdentifier::anonymous(), comb2, "action");
CActionHotkeyList list2;
list2.push_back(actionHotkey2);
QVERIFY2(CVariant::fromValue(list1) != CVariant::fromValue(list2), "List should not be equal");
@@ -151,16 +151,16 @@ namespace BlackMiscTest
CHotkeyCombination comb1;
comb1.addKeyboardKey(Key_ControlLeft);
comb1.addKeyboardKey(Key_D);
CActionHotkey actionHotkey1 (CIdentifier::anonymous(), comb1, "action");
CActionHotkey actionHotkey1(CIdentifier::anonymous(), comb1, "action");
CHotkeyCombination comb2;
comb2.addKeyboardKey(Key_ControlLeft);
CActionHotkey actionHotkey2 (CIdentifier::anonymous(), comb2, "action");
CActionHotkey actionHotkey2(CIdentifier::anonymous(), comb2, "action");
CHotkeyCombination comb3;
comb3.addKeyboardKey(Key_ShiftLeft);
comb3.addKeyboardKey(Key_D);
CActionHotkey actionHotkey3 (CIdentifier::anonymous(), comb3, "action");
CActionHotkey actionHotkey3(CIdentifier::anonymous(), comb3, "action");
CActionHotkeyList list1;
list1.push_back(actionHotkey1);
@@ -173,17 +173,17 @@ namespace BlackMiscTest
{
CHotkeyCombination comb1;
comb1.addKeyboardKey(Key_ControlLeft);
CActionHotkey actionHotkey1 (CIdentifier::anonymous(), comb1, "action");
CActionHotkey actionHotkey1(CIdentifier::anonymous(), comb1, "action");
CHotkeyCombination comb2;
comb2.addKeyboardKey(Key_ControlLeft);
comb2.addKeyboardKey(Key_D);
CActionHotkey actionHotkey2 (CIdentifier::anonymous(), comb2, "action");
CActionHotkey actionHotkey2(CIdentifier::anonymous(), comb2, "action");
CHotkeyCombination comb3;
comb3.addKeyboardKey(Key_ShiftLeft);
comb3.addKeyboardKey(Key_D);
CActionHotkey actionHotkey3 (CIdentifier::anonymous(), comb3, "action");
CActionHotkey actionHotkey3(CIdentifier::anonymous(), comb3, "action");
CActionHotkeyList list1;
list1.push_back(actionHotkey1);

View File

@@ -160,8 +160,8 @@ namespace BlackMiscTest
QCOMPARE(f1.valueRounded(CFrequencyUnit::kHz(), 2), 1000.0); // "Mega is 1000kHz
QCOMPARE(f1.value(), 1.0); // 1MHz
QCOMPARE(f1.value(CFrequencyUnit::defaultUnit()), 1000000.0); // 1E6 Hz
CFrequency f2(1e+6, CFrequencyUnit::Hz()) ; // 1 Megahertz
QVERIFY2(f1 == f2 , "MHz is 1E6 Hz");
CFrequency f2(1e+6, CFrequencyUnit::Hz()); // 1 Megahertz
QVERIFY2(f1 == f2, "MHz is 1E6 Hz");
}
void CTestPhysicalQuantities::angleTests()
@@ -268,7 +268,8 @@ namespace BlackMiscTest
a1.switchUnit(CAccelerationUnit::ft_s2());
QVERIFY2(a1 == a2, "Accelerations should be similar");
QVERIFY2(CMathUtils::epsilonEqual(BlackMisc::Math::CMathUtils::round(a2.value() * ftFactor, 6),
a1.valueRounded(6)), "Numerical values should be equal");
a1.valueRounded(6)),
"Numerical values should be equal");
}
void CTestPhysicalQuantities::memoryTests()
@@ -294,7 +295,6 @@ namespace BlackMiscTest
QVERIFY2(CSpeed(123.45, CSpeedUnit::km_h()) == CSpeed("123.45km/h"), "Speed");
QVERIFY2(CMass(33.45, CMassUnit::kg()) == CMass("33.45000 kg"), "CMass");
// parsing via variant
CSpeed parsedPq1 = CPqString::parseToVariant("100.123 km/h").value<CSpeed>();
QVERIFY2(CSpeed(100.123, CSpeedUnit::km_h()) == parsedPq1, "Parsed speed via variant");
@@ -336,7 +336,6 @@ namespace BlackMiscTest
CAngle a2(1.5 * CAngle::PI(), CAngleUnit::rad());
a1 += a2;
QVERIFY2(a1.valueInteger(CAngleUnit::deg()) == 450, "Expect 450 degrees");
}
void CTestPhysicalQuantities::literalsTest()

View File

@@ -105,7 +105,7 @@ namespace BlackMiscTest
double lngOld = 360.0;
qint64 from = ts - 2 * deltaT + offset;
qint64 to = ts; // ts + offset is last value, but we have to consider offset
qint64 to = ts; // ts + offset is last value, but we have to consider offset
qint64 step = deltaT / 20;
for (qint64 currentTime = from; currentTime < to; currentTime += step)
{
@@ -139,7 +139,7 @@ namespace BlackMiscTest
for (int loops = 0; loops < 20; loops++)
{
from = startTimeMsSinceEpoch + offset;
to = ts; // ts + offset is last value, but we have to consider offset
to = ts; // ts + offset is last value, but we have to consider offset
step = deltaT / 20;
for (qint64 currentTime = from; currentTime < to; currentTime += step)
@@ -164,7 +164,8 @@ namespace BlackMiscTest
// this is a risky test as in some situations the values can be exceeded
int timeMs = timer.elapsed();
QVERIFY2(timeMs < interpolationNo * 1.5, "Interpolation > 1.5ms");
qDebug() << timeMs << "ms" << "for" << interpolationNo << "interpolations";
qDebug() << timeMs << "ms"
<< "for" << interpolationNo << "interpolations";
int fetchedParts = 0;
timer.start();
@@ -175,7 +176,8 @@ namespace BlackMiscTest
QVERIFY2(result.getPartsStatus().isSupportingParts(), "Parts not supported");
}
timeMs = timer.elapsed();
qDebug() << timeMs << "ms" << "for" << fetchedParts << "fetched parts";
qDebug() << timeMs << "ms"
<< "for" << fetchedParts << "fetched parts";
}
void CTestInterpolatorLinear::pbhInterpolatorTest()
@@ -200,7 +202,11 @@ namespace BlackMiscTest
pbh.setTimeFraction(timeFraction);
const CHeading heading = pbh.getHeading();
const double h = heading.value(CAngleUnit::deg());
if (i < 1) { lastDeg = h; continue; }
if (i < 1)
{
lastDeg = h;
continue;
}
QVERIFY2(h > lastDeg, "Expect increasing heading");
lastDeg = h;
}
@@ -218,7 +224,11 @@ namespace BlackMiscTest
pbh.setTimeFraction(timeFraction);
const CHeading heading = pbh.getHeading();
const double h = heading.value(CAngleUnit::deg());
if (i < 1) { lastDeg = h; continue; }
if (i < 1)
{
lastDeg = h;
continue;
}
QVERIFY2(h > lastDeg, "Expect increasing heading");
lastDeg = h;
}
@@ -236,7 +246,11 @@ namespace BlackMiscTest
pbh.setTimeFraction(timeFraction);
const CHeading heading = pbh.getHeading();
const double h = CAngle::normalizeDegrees360(heading.value(CAngleUnit::deg()));
if (i < 1) { lastDeg = h; continue; }
if (i < 1)
{
lastDeg = h;
continue;
}
QVERIFY2(h < lastDeg, "Expect increasing heading");
lastDeg = h;
}
@@ -256,7 +270,11 @@ namespace BlackMiscTest
pbh.setTimeFraction(timeFraction);
const CAngle bank = pbh.getBank();
const double b = bank.value(CAngleUnit::deg());
if (i < 1) { lastDeg = b; continue; }
if (i < 1)
{
lastDeg = b;
continue;
}
QVERIFY2(b > lastDeg, "Expect increasing bank");
lastDeg = b;
}
@@ -274,7 +292,11 @@ namespace BlackMiscTest
pbh.setTimeFraction(timeFraction);
const CAngle bank = pbh.getBank();
const double b = CAngle::normalizeDegrees360(bank.value(CAngleUnit::deg()));
if (i < 1) { lastDeg = b; continue; }
if (i < 1)
{
lastDeg = b;
continue;
}
QVERIFY2(b > lastDeg, "Expect increasing bank");
lastDeg = b;
}
@@ -294,7 +316,11 @@ namespace BlackMiscTest
pbh.setTimeFraction(timeFraction);
const CAngle pitch = pbh.getPitch();
const double p = pitch.value(CAngleUnit::deg());
if (i < 1) { lastDeg = p; continue; }
if (i < 1)
{
lastDeg = p;
continue;
}
QVERIFY2(p < lastDeg, "Expect decreasing pitch");
lastDeg = p;
}
@@ -314,7 +340,11 @@ namespace BlackMiscTest
pbh.setTimeFraction(timeFraction);
const CAngle pitch = pbh.getPitch();
const double p = pitch.value(CAngleUnit::deg());
if (i < 1) { lastDeg = p; continue; }
if (i < 1)
{
lastDeg = p;
continue;
}
QVERIFY2(p > lastDeg, "Expect increasing pitch");
lastDeg = p;
}

View File

@@ -14,8 +14,6 @@
#include "blackmisc/simulation/interpolationrenderingsetup.h"
#include "test.h"
#include <QDebug>
#include <QTest>
#include <QtDebug>

View File

@@ -55,7 +55,7 @@ namespace BlackMiscTest
interpolator.markAsUnitTest();
// fixed time so everything can be debugged
const qint64 ts = 1425000000000; // QDateTime::currentMSecsSinceEpoch()
const qint64 ts = 1425000000000; // QDateTime::currentMSecsSinceEpoch()
const qint64 deltaT = 5000; // ms
const int number = CRemoteAircraftProviderDummy::MaxPartsPerCallsign;
// const int numberHalf = number / 2;
@@ -108,7 +108,7 @@ namespace BlackMiscTest
CCallsign cs("SWIFT");
// fixed time so everything can be debugged
const qint64 ts = 1425000000000; // QDateTime::currentMSecsSinceEpoch()
const qint64 ts = 1425000000000; // QDateTime::currentMSecsSinceEpoch()
const qint64 deltaT = 5000; // ms
const int number = 10;

View File

@@ -9,9 +9,9 @@
//! \cond PRIVATE_TESTS
/*!
* \file
* \ingroup testblackmisc
*/
* \file
* \ingroup testblackmisc
*/
#include "blackconfig/buildconfig.h"
#include "blackmisc/compressutils.h"

View File

@@ -40,7 +40,6 @@
#include <set>
#include <vector>
using namespace BlackMisc;
using namespace BlackMisc::Aviation;
using namespace BlackMisc::Geo;
@@ -182,16 +181,14 @@ namespace BlackMiscTest
QString name;
int age;
};
CSequence<Person> list
{
CSequence<Person> list {
{ "Alice", 33 },
{ "Bob", 32 },
{ "Cathy", 32 },
{ "Dave", 31 },
{ "Emily", 31 }
};
CSequence<Person> sorted
{
CSequence<Person> sorted {
{ "Dave", 31 },
{ "Emily", 31 },
{ "Bob", 32 },
@@ -204,10 +201,8 @@ namespace BlackMiscTest
void CTestContainers::removeTests()
{
const CSequence<int> base { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
const CSequence<CSequence<int>> subsets
{
{}, { 1 }, { 9 }, { 5 }, { 1, 9 }, { 1, 5 }, { 5, 9 }, { 1, 2 },
{ 8, 9 }, { 4, 5, 6 }, { 1, 5, 9 }, { 3, 7 }, { 3, 5, 7 }, base
const CSequence<CSequence<int>> subsets {
{}, { 1 }, { 9 }, { 5 }, { 1, 9 }, { 1, 5 }, { 5, 9 }, { 1, 2 }, { 8, 9 }, { 4, 5, 6 }, { 1, 5, 9 }, { 3, 7 }, { 3, 5, 7 }, base
};
for (const auto &subset : subsets)
{
@@ -424,7 +419,7 @@ namespace BlackMiscTest
}
}
}
} //namespace
} // namespace
//! main
BLACKTEST_APPLESS_MAIN(BlackMiscTest::CTestContainers);

View File

@@ -48,8 +48,7 @@ namespace BlackMiscTest
void CTestDataStream::marshalUnmarshal()
{
CSimulatedAircraftList testData
{
CSimulatedAircraftList testData {
{ CCallsign("BAW123"), {}, {} },
{ CCallsign("DLH456"), {}, {} },
{ CCallsign("AAL789"), {}, {} }

View File

@@ -48,7 +48,7 @@ namespace BlackMiscTest
c++;
}
}
} //namespace
} // namespace
//! main
BLACKTEST_MAIN(BlackMiscTest::CTestIcon);

View File

@@ -80,9 +80,9 @@ namespace BlackMiscTest
}
CTestIdentifiable::CTestIdentifiable(QObject *nameObject) : CIdentifiable(nameObject)
{ }
{}
} //namespace
} // namespace
//! main
BLACKTEST_APPLESS_MAIN(BlackMiscTest::CTestIdentifier);

View File

@@ -32,7 +32,7 @@ namespace BlackMiscTest
void CTestProcess::processInfo()
{
CProcessInfo invalid;
QVERIFY2(! invalid.exists(), "Invalid process shall not exist");
QVERIFY2(!invalid.exists(), "Invalid process shall not exist");
CProcessInfo current1(CProcessInfo::currentProcess());
CProcessInfo current2(QCoreApplication::applicationPid());

View File

@@ -64,9 +64,9 @@ namespace BlackMiscTest
{
int result = 0;
CPromise<int> promise;
doAfter(promise.future(), nullptr, [ & ](QFuture<int> future) { result = future.result(); });
doAfter(promise.future(), nullptr, [&](QFuture<int> future) { result = future.result(); });
promise.setResult(42);
bool ok = qWaitFor([ & ] { return result == 42; });
bool ok = qWaitFor([&] { return result == 42; });
QVERIFY2(ok, "future contains expected result");
}
@@ -81,7 +81,7 @@ namespace BlackMiscTest
observer.initialize(&dataLink);
mutator.setValue(42);
bool ok = qWaitFor([ & ] { return observer.value() == 42; });
bool ok = qWaitFor([&] { return observer.value() == 42; });
QVERIFY2(ok, "expected value received");
qWait(0);
QVERIFY2(observer.value() == 42, "still has expected value");
@@ -89,7 +89,7 @@ namespace BlackMiscTest
CTestScalarObserver observer2(this);
observer2.initialize(&dataLink);
ok = qWaitFor([ & ] { return observer2.value() == 42; });
ok = qWaitFor([&] { return observer2.value() == 42; });
QVERIFY2(ok, "new observer got existing value");
qWait(0);
QVERIFY2(observer2.value() == 42, "still has correct value");
@@ -107,18 +107,18 @@ namespace BlackMiscTest
observer.setFilter({});
mutator.addElement(1);
bool ok = qWaitFor([ & ] { return observer.allValues() == QList<int> { 1 }; });
bool ok = qWaitFor([&] { return observer.allValues() == QList<int> { 1 }; });
QVERIFY2(ok, "expected value received");
qWait(0);
QVERIFY2(observer.allValues() == QList<int> { 1 }, "still has expected value");
for (int e = 2; e <= 6; ++e) { mutator.addElement(e); }
ok = qWaitFor([ & ] { return observer.allValues() == QList<int> { 1, 2, 3, 4, 5, 6 }; });
ok = qWaitFor([&] { return observer.allValues() == QList<int> { 1, 2, 3, 4, 5, 6 }; });
QVERIFY2(ok, "expected value received");
observer.allValues() = {};
observer.setFilter({ 1 });
ok = qWaitFor([ & ] { return observer.allValues() == QList<int> { 1, 3, 5 }; });
ok = qWaitFor([&] { return observer.allValues() == QList<int> { 1, 3, 5 }; });
QVERIFY2(ok, "expected value received");
}
@@ -129,8 +129,7 @@ namespace BlackMiscTest
//! ctor
Server()
{
QObject::connect(&m_process, qOverload<int, QProcess::ExitStatus>(&QProcess::finished), [](int code, QProcess::ExitStatus status)
{
QObject::connect(&m_process, qOverload<int, QProcess::ExitStatus>(&QProcess::finished), [](int code, QProcess::ExitStatus status) {
qDebug() << "Server process exited" << (status ? "abnormally" : "normally") << "with exit code" << code;
});
m_process.start("sharedstatetestserver", QStringList());
@@ -143,6 +142,7 @@ namespace BlackMiscTest
m_process.kill();
m_process.waitForFinished();
}
private:
QProcess m_process;
};
@@ -155,7 +155,7 @@ namespace BlackMiscTest
CDataLinkDBus dataLink;
dataLink.initializeRemote(connection, SWIFT_SERVICENAME);
bool ok = qWaitFor([ & ] { return dataLink.watcher()->isConnected(); });
bool ok = qWaitFor([&] { return dataLink.watcher()->isConnected(); });
QVERIFY2(ok, "Connection failed");
CTestScalarObserver observer(this);
@@ -163,13 +163,13 @@ namespace BlackMiscTest
observer.initialize(&dataLink);
mutator.initialize(&dataLink);
ok = qWaitFor([ & ] { return observer.value() == 42; });
ok = qWaitFor([&] { return observer.value() == 42; });
QVERIFY2(ok, "expected value received");
qWait(1000);
QVERIFY2(observer.value() == 42, "still has expected value");
mutator.setValue(69);
ok = qWaitFor([ & ] { return observer.value() == 69; });
ok = qWaitFor([&] { return observer.value() == 69; });
QVERIFY2(ok, "expected value received");
qWait(1000);
QVERIFY2(observer.value() == 69, "still has expected value");
@@ -183,7 +183,7 @@ namespace BlackMiscTest
CDataLinkDBus dataLink;
dataLink.initializeRemote(connection, SWIFT_SERVICENAME);
bool ok = qWaitFor([ & ] { return dataLink.watcher()->isConnected(); });
bool ok = qWaitFor([&] { return dataLink.watcher()->isConnected(); });
QVERIFY2(ok, "Connection failed");
CTestListObserver observer(this);
@@ -192,18 +192,18 @@ namespace BlackMiscTest
mutator.initialize(&dataLink);
observer.setFilter({});
ok = qWaitFor([ & ] { return observer.allValues() == QList<int> { 1, 2, 3, 4, 5, 6 }; });
ok = qWaitFor([&] { return observer.allValues() == QList<int> { 1, 2, 3, 4, 5, 6 }; });
QVERIFY2(ok, "expected value received");
qWait(1000);
QVERIFY2(observer.allValues() == QList<int>({ 1, 2, 3, 4, 5, 6 }), "still has expected value");
observer.allValues() = {};
observer.setFilter({ 1 });
ok = qWaitFor([ & ] { return observer.allValues() == QList<int> { 1, 3, 5 }; });
ok = qWaitFor([&] { return observer.allValues() == QList<int> { 1, 3, 5 }; });
QVERIFY2(ok, "expected value received");
mutator.addElement(7);
ok = qWaitFor([ & ] { return observer.allValues() == QList<int> { 1, 3, 5, 7 }; });
ok = qWaitFor([&] { return observer.allValues() == QList<int> { 1, 3, 5, 7 }; });
QVERIFY2(ok, "expected value received");
qWait(1000);
QVERIFY2(observer.allValues() == QList<int>({ 1, 3, 5, 7 }), "still has expected value");

View File

@@ -34,6 +34,7 @@ namespace BlackMiscTest
}
QString convertToQString(bool = false) const { return QString::number(m_mask); }
CTestFilter(unsigned mask = ~0u) : m_mask(mask) {}
private:
unsigned m_mask = ~0u;
BLACK_METACLASS(CTestFilter, BLACK_METAMEMBER(mask));

View File

@@ -58,8 +58,10 @@ namespace BlackMiscTest
auto s3 = CStatusMessage().info(u"literal percent: %");
auto s4 = CStatusMessage().info(u"literal percent: %%");
auto s5 = CStatusMessage().info(u"literal percents: %%%");
auto s6 = CStatusMessage().info(u"will be expanded: %1%2") << "foo" << "bar";
auto s7 = CStatusMessage().info(u"will be expanded: %1+%2") << "foo" << "bar";
auto s6 = CStatusMessage().info(u"will be expanded: %1%2") << "foo"
<< "bar";
auto s7 = CStatusMessage().info(u"will be expanded: %1+%2") << "foo"
<< "bar";
auto s8 = CStatusMessage().info(u"will be expanded: %012") << "foo";
QVERIFY(s1.getMessage() == u"literal percent: %1");

View File

@@ -74,18 +74,16 @@ namespace BlackMiscTest
void CTestStringUtils::testTimestampParsing()
{
const QStringList dts(
{
"2018-01-01 11:11:11",
"2012-05-09 03:04:05.777",
"2012-05-09 00:00:00.000",
"2015-12-31 03:04:05",
"1999-12-31 23:59:59.999",
"1975-01-01 14:13:17",
"1982-05-09 03:01:05.123",
"2000-05-02 00:04:00.000",
"2002-12-31 03:34:33",
"1992-11-01 21:59:29.999"
});
{ "2018-01-01 11:11:11",
"2012-05-09 03:04:05.777",
"2012-05-09 00:00:00.000",
"2015-12-31 03:04:05",
"1999-12-31 23:59:59.999",
"1975-01-01 14:13:17",
"1982-05-09 03:01:05.123",
"2000-05-02 00:04:00.000",
"2002-12-31 03:34:33",
"1992-11-01 21:59:29.999" });
const int size = QString("yyyyMMddHHmmss").size();
for (const QString &dt : dts)
@@ -93,11 +91,11 @@ namespace BlackMiscTest
const QString c = removeDateTimeSeparators(dt);
const QDateTime dt1 = parseDateTimeStringOptimized(c);
const QDateTime dt2 = (c.length() == size) ?
fromStringUtc(c, "yyyyMMddHHmmss") :
fromStringUtc(c, "yyyyMMddHHmmsszzz");
fromStringUtc(c, "yyyyMMddHHmmss") :
fromStringUtc(c, "yyyyMMddHHmmsszzz");
QDateTime dt3 = (c.length() == size) ?
QDateTime::fromString(c, "yyyyMMddHHmmss") :
QDateTime::fromString(c, "yyyyMMddHHmmsszzz");
QDateTime::fromString(c, "yyyyMMddHHmmss") :
QDateTime::fromString(c, "yyyyMMddHHmmsszzz");
dt3.setOffsetFromUtc(0);
const qint64 ms1 = dt1.toMSecsSinceEpoch();
@@ -131,8 +129,8 @@ namespace BlackMiscTest
{
const QString c = removeDateTimeSeparators(dt);
const QDateTime dateTime = (c.length() == size) ?
fromStringUtc(c, "yyyyMMddHHmmss") :
fromStringUtc(c, "yyyyMMddHHmmsszzz");
fromStringUtc(c, "yyyyMMddHHmmss") :
fromStringUtc(c, "yyyyMMddHHmmsszzz");
Q_UNUSED(dateTime); // avoid optimizing out of call
}
}

View File

@@ -95,9 +95,9 @@ namespace BlackMiscTest
//! Detect whether the slot was called, for verification.
bool slotFired();
std::promise<void> m_slotFired; //!< Flag marking whether the slot was called.
BlackMisc::CCached<int> m_value1; //!< First cached value.
BlackMisc::CCached<int> m_value2; //!< Second cached value.
std::promise<void> m_slotFired; //!< Flag marking whether the slot was called.
BlackMisc::CCached<int> m_value1; //!< First cached value.
BlackMisc::CCached<int> m_value2; //!< Second cached value.
};
void CTestValueCache::initTestCase()
@@ -107,19 +107,16 @@ namespace BlackMiscTest
void CTestValueCache::insertAndGet()
{
CVariantMap testData
{
CVariantMap testData {
{ "value1", CVariant::from(1) },
{ "value2", CVariant::from(2) },
{ "value3", CVariant::from(3) }
};
CVariantMap testData2
{
CVariantMap testData2 {
{ "value2", CVariant::from(42) },
{ "value4", CVariant::from(4) }
};
CVariantMap testDataCombined
{
CVariantMap testDataCombined {
{ "value1", CVariant::from(1) },
{ "value2", CVariant::from(42) },
{ "value3", CVariant::from(3) },
@@ -140,7 +137,7 @@ namespace BlackMiscTest
if (object->thread() != QThread::currentThread())
{
std::promise<void> promise;
QTimer::singleShot(0, object, [ & ] { promise.set_value(); });
QTimer::singleShot(0, object, [&] { promise.set_value(); });
promise.get_future().wait();
}
}
@@ -163,17 +160,17 @@ namespace BlackMiscTest
{
user1.m_value1.set(42);
QVERIFY(user2.slotFired());
QVERIFY(! user1.slotFired());
singleShotAndWait(&user2, [ & ] { QVERIFY(user2.m_value1.get() == 42); });
QVERIFY(!user1.slotFired());
singleShotAndWait(&user2, [&] { QVERIFY(user2.m_value1.get() == 42); });
QVERIFY(user1.m_value1.get() == 42);
user1.m_value2.set(42);
user2.slotFired();
auto status = user1.m_value2.set(-1337);
QVERIFY(status.isFailure());
QVERIFY(! user1.slotFired());
QVERIFY(! user2.slotFired());
singleShotAndWait(&user2, [ & ] { QVERIFY(user2.m_value2.get() == 42); });
QVERIFY(!user1.slotFired());
QVERIFY(!user2.slotFired());
singleShotAndWait(&user2, [&] { QVERIFY(user2.m_value2.get() == 42); });
QVERIFY(user1.m_value2.get() == 42);
}
//! \endcond
@@ -209,13 +206,11 @@ namespace BlackMiscTest
CValueCache thisCache(1);
CValueCache otherCache(1);
connect(&thisCache, &CValueCache::valuesChangedByLocal, &thisCache, [ & ](const CValueCachePacket &values)
{
connect(&thisCache, &CValueCache::valuesChangedByLocal, &thisCache, [&](const CValueCachePacket &values) {
QMetaObject::invokeMethod(&thisCache, [=, &thisCache] { thisCache.changeValuesFromRemote(values, thisProcess); });
QMetaObject::invokeMethod(&otherCache, [=, &otherCache] { otherCache.changeValuesFromRemote(values, otherProcess); });
});
connect(&otherCache, &CValueCache::valuesChangedByLocal, &thisCache, [ & ](const CValueCachePacket &values)
{
connect(&otherCache, &CValueCache::valuesChangedByLocal, &thisCache, [&](const CValueCachePacket &values) {
QMetaObject::invokeMethod(&thisCache, [=, &thisCache] { thisCache.changeValuesFromRemote(values, otherProcess); });
QMetaObject::invokeMethod(&otherCache, [=, &otherCache] { otherCache.changeValuesFromRemote(values, thisProcess); });
});
@@ -229,13 +224,13 @@ namespace BlackMiscTest
otherUser.moveToThread(&thread);
thread.start();
singleShotAndWait(&otherUser, [ & ] { otherUser.m_value1.set(99); });
singleShotAndWait(&otherUser, [&] { otherUser.m_value1.set(99); });
thisUser.m_value1.set(100);
QCoreApplication::processEvents();
waitForQueueOf(&otherUser);
QVERIFY(thisUser.slotFired() != otherUser.slotFired());
auto thisValue = thisUser.m_value1.get();
singleShotAndWait(&otherUser, [ & ] { QVERIFY(thisValue == otherUser.m_value1.get()); });
singleShotAndWait(&otherUser, [&] { QVERIFY(thisValue == otherUser.m_value1.get()); });
}
void CTestValueCache::batched()
@@ -250,10 +245,9 @@ namespace BlackMiscTest
user1.m_value1.set(42);
user1.m_value2.set(42);
}
QVERIFY(! user1.slotFired());
QVERIFY(!user1.slotFired());
QVERIFY(user2.slotFired());
singleShotAndWait(&user2, [ & ]
{
singleShotAndWait(&user2, [&] {
QVERIFY(user2.m_value1.get() == 42);
QVERIFY(user2.m_value2.get() == 42);
});
@@ -261,14 +255,12 @@ namespace BlackMiscTest
void CTestValueCache::json()
{
QJsonObject testJson
{
QJsonObject testJson {
{ "value1", CVariant::from(1).toJson() },
{ "value2", CVariant::from(2).toJson() },
{ "value3", CVariant::from(3).toJson() }
};
CVariantMap testData
{
CVariantMap testData {
{ "value1", CVariant::from(1) },
{ "value2", CVariant::from(2) },
{ "value3", CVariant::from(3) }
@@ -284,8 +276,7 @@ namespace BlackMiscTest
{
CSimulatedAircraftList aircraft({ CSimulatedAircraft("BAW001", {}, {}) });
CAtcStationList atcStations({ CAtcStation("EGLL_TWR") });
const CVariantMap testData
{
const CVariantMap testData {
{ "namespace1/value1", CVariant::from(1) },
{ "namespace1/value2", CVariant::from(2) },
{ "namespace1/value3", CVariant::from(3) },
@@ -319,9 +310,8 @@ namespace BlackMiscTest
return value >= 0 && value <= 100;
}
CValueCacheUser::CValueCacheUser(CValueCache *cache) :
m_value1(cache, "value1", "", validator, 0, this),
m_value2(cache, "value2", "", validator, 0, this)
CValueCacheUser::CValueCacheUser(CValueCache *cache) : m_value1(cache, "value1", "", validator, 0, this),
m_value2(cache, "value2", "", validator, 0, this)
{
m_value1.setNotifySlot(&CValueCacheUser::ps_valueChanged);
m_value2.setNotifySlot(&CValueCacheUser::ps_valueChanged);

View File

@@ -82,7 +82,11 @@ namespace BlackMisc
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant)
{
if (index.isMyself()) { (*this) = variant.to<CTestValueObject>(); return; }
if (index.isMyself())
{
(*this) = variant.to<CTestValueObject>();
return;
}
ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
@@ -122,13 +126,13 @@ namespace BlackMisc
struct CNotHashable
{
int n;
bool operator <(const CNotHashable &other) const { return n < other.n; }
bool operator<(const CNotHashable &other) const { return n < other.n; }
QString toQString(bool = false) const { return {}; }
};
inline QJsonArray &operator <<(QJsonArray &a, const CNotHashable &) { return a; }
inline const QJsonValueRef &operator >>(const QJsonValueRef &v, CNotHashable &) { return v; }
inline QDBusArgument &operator <<(QDBusArgument &a, const CNotHashable &) { return a; }
inline const QDBusArgument &operator >>(const QDBusArgument &a, const CNotHashable &) { return a; }
inline QJsonArray &operator<<(QJsonArray &a, const CNotHashable &) { return a; }
inline const QJsonValueRef &operator>>(const QJsonValueRef &v, CNotHashable &) { return v; }
inline QDBusArgument &operator<<(QDBusArgument &a, const CNotHashable &) { return a; }
inline const QDBusArgument &operator>>(const QDBusArgument &a, const CNotHashable &) { return a; }
//! \endcond
} // namespace

View File

@@ -73,10 +73,10 @@ namespace BlackMiscTest
// methods needed for metatype registration
QString toQString(bool) const { return {}; }
friend QDBusArgument &operator <<(QDBusArgument &arg, const CTestMatcher &) { return arg; }
friend const QDBusArgument &operator >>(const QDBusArgument &arg, CTestMatcher &) { return arg; }
friend QDataStream &operator <<(QDataStream &ds, const CTestMatcher &) { return ds; }
friend QDataStream &operator >>(QDataStream &ds, CTestMatcher &) { return ds; }
friend QDBusArgument &operator<<(QDBusArgument &arg, const CTestMatcher &) { return arg; }
friend const QDBusArgument &operator>>(const QDBusArgument &arg, CTestMatcher &) { return arg; }
friend QDataStream &operator<<(QDataStream &ds, const CTestMatcher &) { return ds; }
friend QDataStream &operator>>(QDataStream &ds, CTestMatcher &) { return ds; }
};
} // namespace

View File

@@ -70,7 +70,7 @@ namespace BlackMiscTest
const CAltitude base1 { 0, CAltitude::AboveGround, CLengthUnit::ft() };
const CAltitude top1 { 5000, CAltitude::AboveGround, CLengthUnit::ft() };
CCloudLayer cl1 (base1, top1, CCloudLayer::Scattered);
CCloudLayer cl1(base1, top1, CCloudLayer::Scattered);
QVERIFY(cl1.getBase() == base1);
QVERIFY(cl1.getTop() == top1);
QCOMPARE(cl1.getPrecipitationRate(), 0.0);
@@ -94,9 +94,9 @@ namespace BlackMiscTest
QVERIFY(cll.containsBase(base1));
QVERIFY(cll.containsBase(base2));
QVERIFY(!cll.containsBase(base3));
QVERIFY(cll.findByBase(base1) != CCloudLayer() );
QVERIFY(cll.findByBase(base2) != CCloudLayer() );
QVERIFY(cll.findByBase(base3) == CCloudLayer() );
QVERIFY(cll.findByBase(base1) != CCloudLayer());
QVERIFY(cll.findByBase(base2) != CCloudLayer());
QVERIFY(cll.findByBase(base3) == CCloudLayer());
}
void CTestWeather::temperatureLayer()
@@ -106,7 +106,7 @@ namespace BlackMiscTest
const CTemperature dp1 { 15, CTemperatureUnit::C() };
const double rh = 80.0;
CTemperatureLayer tl1 (level1, temp1, dp1, rh);
CTemperatureLayer tl1(level1, temp1, dp1, rh);
QVERIFY(tl1.getLevel() == level1);
QVERIFY(tl1.getTemperature() == temp1);
QVERIFY(tl1.getDewPoint() == dp1);
@@ -116,8 +116,8 @@ namespace BlackMiscTest
CTemperatureLayerList tll { tl1 };
QVERIFY(tll.containsLevel(level1));
QVERIFY(!tll.containsLevel(level2));
QVERIFY(tll.findByLevel(level1) != CTemperatureLayer() );
QVERIFY(tll.findByLevel(level2) == CTemperatureLayer() );
QVERIFY(tll.findByLevel(level1) != CTemperatureLayer());
QVERIFY(tll.findByLevel(level2) == CTemperatureLayer());
}
void CTestWeather::visibilityLayer()
@@ -126,7 +126,7 @@ namespace BlackMiscTest
const CAltitude top1 { 5000, CAltitude::AboveGround, CLengthUnit::ft() };
const CLength visibility1 { 10, CLengthUnit::SM() };
CVisibilityLayer vl1 (base1, top1, visibility1);
CVisibilityLayer vl1(base1, top1, visibility1);
QVERIFY(vl1.getBase() == base1);
QVERIFY(vl1.getTop() == top1);
QVERIFY(vl1.getVisibility() == visibility1);
@@ -135,8 +135,8 @@ namespace BlackMiscTest
CVisibilityLayerList vll { vl1 };
QVERIFY(vll.containsBase(base1));
QVERIFY(!vll.containsBase(base2));
QVERIFY(vll.findByBase(base1) != CVisibilityLayer() );
QVERIFY(vll.findByBase(base2) == CVisibilityLayer() );
QVERIFY(vll.findByBase(base1) != CVisibilityLayer());
QVERIFY(vll.findByBase(base2) == CVisibilityLayer());
}
void CTestWeather::windLayer()
@@ -146,7 +146,7 @@ namespace BlackMiscTest
const CSpeed speed1 { 10, CSpeedUnit::kts() };
const CSpeed gustSpeed1 { 20, CSpeedUnit::kts() };
CWindLayer wl1 (level1, direction1, speed1, gustSpeed1);
CWindLayer wl1(level1, direction1, speed1, gustSpeed1);
QVERIFY(wl1.getLevel() == level1);
QVERIFY(wl1.getDirection() == direction1);
QVERIFY(wl1.getSpeed() == speed1);
@@ -156,8 +156,8 @@ namespace BlackMiscTest
CWindLayerList wll { wl1 };
QVERIFY(wll.containsLevel(level1));
QVERIFY(!wll.containsLevel(level2));
QVERIFY(wll.findByLevel(level1) != CWindLayer() );
QVERIFY(wll.findByLevel(level2) == CWindLayer() );
QVERIFY(wll.findByLevel(level1) != CWindLayer());
QVERIFY(wll.findByLevel(level2) == CWindLayer());
}
void CTestWeather::metarDecoder()

View File

@@ -20,53 +20,58 @@
//! Implements a main() function that executes all tests in TestObject
//! without instantiating a QApplication object.
//! Also adds arguments automatically to print test results to an xml file.
#define BLACKTEST_INIT(TestObject) \
TestObject to; \
QTEST_SET_MAIN_SOURCE_PATH \
\
QStringList args; \
args.reserve(argc); \
for (int i = 0; i < argc; ++i) \
{ \
args.append(argv[i]); \
} \
\
/* Output to stdout */ \
args.append({ "-o", "-,txt" }); \
\
/* Output to file */ \
QString resultsFileName = QString(#TestObject).replace("::", "_").toLower(); \
args.append({ "-o", resultsFileName + "_testresults.xml,xml" }); \
#define BLACKTEST_INIT(TestObject) \
TestObject to; \
QTEST_SET_MAIN_SOURCE_PATH \
\
QStringList args; \
args.reserve(argc); \
for (int i = 0; i < argc; ++i) \
{ \
args.append(argv[i]); \
} \
\
/* Output to stdout */ \
args.append({ "-o", "-,txt" }); \
\
/* Output to file */ \
QString resultsFileName = QString(#TestObject).replace("::", "_").toLower(); \
args.append({ "-o", resultsFileName + "_testresults.xml,xml" });
//! Implements a main() function that executes all tests in TestObject
//! without instantiating a QApplication object.
//! Also adds arguments automatically to print test results to an xml file.
#define BLACKTEST_APPLESS_MAIN(TestObject) \
int main(int argc, char *argv[]) \
{ \
try { \
BLACKTEST_INIT(TestObject) \
return QTest::qExec(&to, args); \
} catch (...) { \
return EXIT_FAILURE; \
} \
}
#define BLACKTEST_APPLESS_MAIN(TestObject) \
int main(int argc, char *argv[]) \
{ \
try \
{ \
BLACKTEST_INIT(TestObject) \
return QTest::qExec(&to, args); \
} \
catch (...) \
{ \
return EXIT_FAILURE; \
} \
}
//! Implements a main() function that executes all tests in TestObject
//! including instantiating a QCoreApplication object.
//! Also adds arguments automatically to print test results to an xml file.
#define BLACKTEST_MAIN(TestObject) \
int main(int argc, char *argv[]) \
{ \
try { \
QCoreApplication app(argc, argv); \
BLACKTEST_INIT(TestObject) \
return QTest::qExec(&to, args); \
} catch (...) { \
return EXIT_FAILURE; \
} \
}
#define BLACKTEST_MAIN(TestObject) \
int main(int argc, char *argv[]) \
{ \
try \
{ \
QCoreApplication app(argc, argv); \
BLACKTEST_INIT(TestObject) \
return QTest::qExec(&to, args); \
} \
catch (...) \
{ \
return EXIT_FAILURE; \
} \
}
//! \endcond