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

@@ -156,7 +156,6 @@ namespace BlackFsdTest
void CTestFSDClient::testConstructor() void CTestFSDClient::testConstructor()
{ {
} }
void CTestFSDClient::testDeleteAtc() void CTestFSDClient::testDeleteAtc()
@@ -868,8 +867,7 @@ namespace BlackFsdTest
QCOMPARE(CConnectionStatus::Connected, arguments.at(1).value<CConnectionStatus>().getConnectionStatus()); QCOMPARE(CConnectionStatus::Connected, arguments.at(1).value<CConnectionStatus>().getConnectionStatus());
QSignalSpy pongSpy(m_client, &CFSDClient::pongReceived); 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"; qDebug() << "Received pong from" << sender << "in" << elapsedTimeM << "ms";
}); });
m_client->sendPing("SERVER"); m_client->sendPing("SERVER");

View File

@@ -196,7 +196,6 @@ namespace BlackMiscTest
const QStringList tokens = QString("ABCD:SERVER:7a57f2dd9d360d347b").split(':'); const QStringList tokens = QString("ABCD:SERVER:7a57f2dd9d360d347b").split(':');
const AuthResponse messageFromTokens = AuthResponse::fromTokens(tokens); const AuthResponse messageFromTokens = AuthResponse::fromTokens(tokens);
QCOMPARE(messageFromTokens, message); QCOMPARE(messageFromTokens, message);
} }
void CTestFsdMessages::testClientIdentification() void CTestFsdMessages::testClientIdentification()
@@ -299,7 +298,6 @@ namespace BlackMiscTest
QStringList tokens = QString("ABCD:1234567").split(':'); QStringList tokens = QString("ABCD:1234567").split(':');
auto messageFromTokens = DeletePilot::fromTokens(tokens); auto messageFromTokens = DeletePilot::fromTokens(tokens);
QCOMPARE(messageFromTokens, message); QCOMPARE(messageFromTokens, message);
} }
void CTestFsdMessages::testEuroscopeSimData() void CTestFsdMessages::testEuroscopeSimData()
@@ -375,7 +373,6 @@ namespace BlackMiscTest
void CTestFsdMessages::testFSDIdentification() void CTestFsdMessages::testFSDIdentification()
{ {
} }
void CTestFsdMessages::testInterimPilotDataUpdate() void CTestFsdMessages::testInterimPilotDataUpdate()
@@ -430,7 +427,10 @@ namespace BlackMiscTest
void CTestFsdMessages::testPBH() void CTestFsdMessages::testPBH()
{ {
struct PBH { int pitch, bank, heading; }; struct PBH
{
int pitch, bank, heading;
};
QVector<PBH> testData; QVector<PBH> testData;
for (int pitch = -90; pitch < 90; pitch++) { testData.push_back({ pitch, 0, 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 bank = -179; bank < 180; bank++) { testData.push_back({ 0, bank, 0 }); }
@@ -706,7 +706,6 @@ namespace BlackMiscTest
void CTestFsdMessages::testTextMessage() void CTestFsdMessages::testTextMessage()
{ {
} }
} }

View File

@@ -13,8 +13,6 @@
//! \file //! \file
//! \ingroup testblackcore //! \ingroup testblackcore
namespace BlackCoreTest namespace BlackCoreTest
{ {

View File

@@ -84,7 +84,11 @@ namespace BlackCoreTest
{ {
const CUrl url(sApp->getGlobalSetup().getDbIcaoReaderUrl()); const CUrl url(sApp->getGlobalSetup().getDbIcaoReaderUrl());
qDebug() << "Reader URL" << url.toQString(); 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->start();
m_icaoReader->readInBackgroundThread(CEntityFlags::AllIcaoEntities, QDateTime()); m_icaoReader->readInBackgroundThread(CEntityFlags::AllIcaoEntities, QDateTime());
@@ -135,7 +139,11 @@ namespace BlackCoreTest
{ {
const CUrl url(sApp->getGlobalSetup().getDbModelReaderUrl()); const CUrl url(sApp->getGlobalSetup().getDbModelReaderUrl());
qDebug() << "Reader URL" << url.toQString(); 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->start();
m_modelReader->readInBackgroundThread(CEntityFlags::ModelEntity, QDateTime()); m_modelReader->readInBackgroundThread(CEntityFlags::ModelEntity, QDateTime());
@@ -161,7 +169,11 @@ namespace BlackCoreTest
const CUrl url(sApp->getGlobalSetup().getDbAirportReaderUrl()); const CUrl url(sApp->getGlobalSetup().getDbAirportReaderUrl());
qDebug() << "Reader URL" << url.toQString(); 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->start();
m_airportReader->readInBackgroundThread(CEntityFlags::AirportEntity, QDateTime()); m_airportReader->readInBackgroundThread(CEntityFlags::AirportEntity, QDateTime());

View File

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

View File

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

View File

@@ -268,7 +268,8 @@ namespace BlackMiscTest
a1.switchUnit(CAccelerationUnit::ft_s2()); a1.switchUnit(CAccelerationUnit::ft_s2());
QVERIFY2(a1 == a2, "Accelerations should be similar"); QVERIFY2(a1 == a2, "Accelerations should be similar");
QVERIFY2(CMathUtils::epsilonEqual(BlackMisc::Math::CMathUtils::round(a2.value() * ftFactor, 6), 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() void CTestPhysicalQuantities::memoryTests()
@@ -294,7 +295,6 @@ namespace BlackMiscTest
QVERIFY2(CSpeed(123.45, CSpeedUnit::km_h()) == CSpeed("123.45km/h"), "Speed"); QVERIFY2(CSpeed(123.45, CSpeedUnit::km_h()) == CSpeed("123.45km/h"), "Speed");
QVERIFY2(CMass(33.45, CMassUnit::kg()) == CMass("33.45000 kg"), "CMass"); QVERIFY2(CMass(33.45, CMassUnit::kg()) == CMass("33.45000 kg"), "CMass");
// parsing via variant // parsing via variant
CSpeed parsedPq1 = CPqString::parseToVariant("100.123 km/h").value<CSpeed>(); CSpeed parsedPq1 = CPqString::parseToVariant("100.123 km/h").value<CSpeed>();
QVERIFY2(CSpeed(100.123, CSpeedUnit::km_h()) == parsedPq1, "Parsed speed via variant"); 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()); CAngle a2(1.5 * CAngle::PI(), CAngleUnit::rad());
a1 += a2; a1 += a2;
QVERIFY2(a1.valueInteger(CAngleUnit::deg()) == 450, "Expect 450 degrees"); QVERIFY2(a1.valueInteger(CAngleUnit::deg()) == 450, "Expect 450 degrees");
} }
void CTestPhysicalQuantities::literalsTest() void CTestPhysicalQuantities::literalsTest()

View File

@@ -164,7 +164,8 @@ namespace BlackMiscTest
// this is a risky test as in some situations the values can be exceeded // this is a risky test as in some situations the values can be exceeded
int timeMs = timer.elapsed(); int timeMs = timer.elapsed();
QVERIFY2(timeMs < interpolationNo * 1.5, "Interpolation > 1.5ms"); QVERIFY2(timeMs < interpolationNo * 1.5, "Interpolation > 1.5ms");
qDebug() << timeMs << "ms" << "for" << interpolationNo << "interpolations"; qDebug() << timeMs << "ms"
<< "for" << interpolationNo << "interpolations";
int fetchedParts = 0; int fetchedParts = 0;
timer.start(); timer.start();
@@ -175,7 +176,8 @@ namespace BlackMiscTest
QVERIFY2(result.getPartsStatus().isSupportingParts(), "Parts not supported"); QVERIFY2(result.getPartsStatus().isSupportingParts(), "Parts not supported");
} }
timeMs = timer.elapsed(); timeMs = timer.elapsed();
qDebug() << timeMs << "ms" << "for" << fetchedParts << "fetched parts"; qDebug() << timeMs << "ms"
<< "for" << fetchedParts << "fetched parts";
} }
void CTestInterpolatorLinear::pbhInterpolatorTest() void CTestInterpolatorLinear::pbhInterpolatorTest()
@@ -200,7 +202,11 @@ namespace BlackMiscTest
pbh.setTimeFraction(timeFraction); pbh.setTimeFraction(timeFraction);
const CHeading heading = pbh.getHeading(); const CHeading heading = pbh.getHeading();
const double h = heading.value(CAngleUnit::deg()); 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"); QVERIFY2(h > lastDeg, "Expect increasing heading");
lastDeg = h; lastDeg = h;
} }
@@ -218,7 +224,11 @@ namespace BlackMiscTest
pbh.setTimeFraction(timeFraction); pbh.setTimeFraction(timeFraction);
const CHeading heading = pbh.getHeading(); const CHeading heading = pbh.getHeading();
const double h = heading.value(CAngleUnit::deg()); 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"); QVERIFY2(h > lastDeg, "Expect increasing heading");
lastDeg = h; lastDeg = h;
} }
@@ -236,7 +246,11 @@ namespace BlackMiscTest
pbh.setTimeFraction(timeFraction); pbh.setTimeFraction(timeFraction);
const CHeading heading = pbh.getHeading(); const CHeading heading = pbh.getHeading();
const double h = CAngle::normalizeDegrees360(heading.value(CAngleUnit::deg())); 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"); QVERIFY2(h < lastDeg, "Expect increasing heading");
lastDeg = h; lastDeg = h;
} }
@@ -256,7 +270,11 @@ namespace BlackMiscTest
pbh.setTimeFraction(timeFraction); pbh.setTimeFraction(timeFraction);
const CAngle bank = pbh.getBank(); const CAngle bank = pbh.getBank();
const double b = bank.value(CAngleUnit::deg()); 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"); QVERIFY2(b > lastDeg, "Expect increasing bank");
lastDeg = b; lastDeg = b;
} }
@@ -274,7 +292,11 @@ namespace BlackMiscTest
pbh.setTimeFraction(timeFraction); pbh.setTimeFraction(timeFraction);
const CAngle bank = pbh.getBank(); const CAngle bank = pbh.getBank();
const double b = CAngle::normalizeDegrees360(bank.value(CAngleUnit::deg())); 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"); QVERIFY2(b > lastDeg, "Expect increasing bank");
lastDeg = b; lastDeg = b;
} }
@@ -294,7 +316,11 @@ namespace BlackMiscTest
pbh.setTimeFraction(timeFraction); pbh.setTimeFraction(timeFraction);
const CAngle pitch = pbh.getPitch(); const CAngle pitch = pbh.getPitch();
const double p = pitch.value(CAngleUnit::deg()); 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"); QVERIFY2(p < lastDeg, "Expect decreasing pitch");
lastDeg = p; lastDeg = p;
} }
@@ -314,7 +340,11 @@ namespace BlackMiscTest
pbh.setTimeFraction(timeFraction); pbh.setTimeFraction(timeFraction);
const CAngle pitch = pbh.getPitch(); const CAngle pitch = pbh.getPitch();
const double p = pitch.value(CAngleUnit::deg()); 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"); QVERIFY2(p > lastDeg, "Expect increasing pitch");
lastDeg = p; lastDeg = p;
} }

View File

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

View File

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

View File

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

View File

@@ -129,8 +129,7 @@ namespace BlackMiscTest
//! ctor //! ctor
Server() 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; qDebug() << "Server process exited" << (status ? "abnormally" : "normally") << "with exit code" << code;
}); });
m_process.start("sharedstatetestserver", QStringList()); m_process.start("sharedstatetestserver", QStringList());
@@ -143,6 +142,7 @@ namespace BlackMiscTest
m_process.kill(); m_process.kill();
m_process.waitForFinished(); m_process.waitForFinished();
} }
private: private:
QProcess m_process; QProcess m_process;
}; };

View File

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

View File

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

View File

@@ -74,8 +74,7 @@ namespace BlackMiscTest
void CTestStringUtils::testTimestampParsing() void CTestStringUtils::testTimestampParsing()
{ {
const QStringList dts( const QStringList dts(
{ { "2018-01-01 11:11:11",
"2018-01-01 11:11:11",
"2012-05-09 03:04:05.777", "2012-05-09 03:04:05.777",
"2012-05-09 00:00:00.000", "2012-05-09 00:00:00.000",
"2015-12-31 03:04:05", "2015-12-31 03:04:05",
@@ -84,8 +83,7 @@ namespace BlackMiscTest
"1982-05-09 03:01:05.123", "1982-05-09 03:01:05.123",
"2000-05-02 00:04:00.000", "2000-05-02 00:04:00.000",
"2002-12-31 03:34:33", "2002-12-31 03:34:33",
"1992-11-01 21:59:29.999" "1992-11-01 21:59:29.999" });
});
const int size = QString("yyyyMMddHHmmss").size(); const int size = QString("yyyyMMddHHmmss").size();
for (const QString &dt : dts) for (const QString &dt : dts)

View File

@@ -107,19 +107,16 @@ namespace BlackMiscTest
void CTestValueCache::insertAndGet() void CTestValueCache::insertAndGet()
{ {
CVariantMap testData CVariantMap testData {
{
{ "value1", CVariant::from(1) }, { "value1", CVariant::from(1) },
{ "value2", CVariant::from(2) }, { "value2", CVariant::from(2) },
{ "value3", CVariant::from(3) } { "value3", CVariant::from(3) }
}; };
CVariantMap testData2 CVariantMap testData2 {
{
{ "value2", CVariant::from(42) }, { "value2", CVariant::from(42) },
{ "value4", CVariant::from(4) } { "value4", CVariant::from(4) }
}; };
CVariantMap testDataCombined CVariantMap testDataCombined {
{
{ "value1", CVariant::from(1) }, { "value1", CVariant::from(1) },
{ "value2", CVariant::from(42) }, { "value2", CVariant::from(42) },
{ "value3", CVariant::from(3) }, { "value3", CVariant::from(3) },
@@ -209,13 +206,11 @@ namespace BlackMiscTest
CValueCache thisCache(1); CValueCache thisCache(1);
CValueCache otherCache(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(&thisCache, [=, &thisCache] { thisCache.changeValuesFromRemote(values, thisProcess); });
QMetaObject::invokeMethod(&otherCache, [=, &otherCache] { otherCache.changeValuesFromRemote(values, otherProcess); }); 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(&thisCache, [=, &thisCache] { thisCache.changeValuesFromRemote(values, otherProcess); });
QMetaObject::invokeMethod(&otherCache, [=, &otherCache] { otherCache.changeValuesFromRemote(values, thisProcess); }); QMetaObject::invokeMethod(&otherCache, [=, &otherCache] { otherCache.changeValuesFromRemote(values, thisProcess); });
}); });
@@ -252,8 +247,7 @@ namespace BlackMiscTest
} }
QVERIFY(!user1.slotFired()); QVERIFY(!user1.slotFired());
QVERIFY(user2.slotFired()); QVERIFY(user2.slotFired());
singleShotAndWait(&user2, [ & ] singleShotAndWait(&user2, [&] {
{
QVERIFY(user2.m_value1.get() == 42); QVERIFY(user2.m_value1.get() == 42);
QVERIFY(user2.m_value2.get() == 42); QVERIFY(user2.m_value2.get() == 42);
}); });
@@ -261,14 +255,12 @@ namespace BlackMiscTest
void CTestValueCache::json() void CTestValueCache::json()
{ {
QJsonObject testJson QJsonObject testJson {
{
{ "value1", CVariant::from(1).toJson() }, { "value1", CVariant::from(1).toJson() },
{ "value2", CVariant::from(2).toJson() }, { "value2", CVariant::from(2).toJson() },
{ "value3", CVariant::from(3).toJson() } { "value3", CVariant::from(3).toJson() }
}; };
CVariantMap testData CVariantMap testData {
{
{ "value1", CVariant::from(1) }, { "value1", CVariant::from(1) },
{ "value2", CVariant::from(2) }, { "value2", CVariant::from(2) },
{ "value3", CVariant::from(3) } { "value3", CVariant::from(3) }
@@ -284,8 +276,7 @@ namespace BlackMiscTest
{ {
CSimulatedAircraftList aircraft({ CSimulatedAircraft("BAW001", {}, {}) }); CSimulatedAircraftList aircraft({ CSimulatedAircraft("BAW001", {}, {}) });
CAtcStationList atcStations({ CAtcStation("EGLL_TWR") }); CAtcStationList atcStations({ CAtcStation("EGLL_TWR") });
const CVariantMap testData const CVariantMap testData {
{
{ "namespace1/value1", CVariant::from(1) }, { "namespace1/value1", CVariant::from(1) },
{ "namespace1/value2", CVariant::from(2) }, { "namespace1/value2", CVariant::from(2) },
{ "namespace1/value3", CVariant::from(3) }, { "namespace1/value3", CVariant::from(3) },
@@ -319,8 +310,7 @@ namespace BlackMiscTest
return value >= 0 && value <= 100; return value >= 0 && value <= 100;
} }
CValueCacheUser::CValueCacheUser(CValueCache *cache) : CValueCacheUser::CValueCacheUser(CValueCache *cache) : m_value1(cache, "value1", "", validator, 0, this),
m_value1(cache, "value1", "", validator, 0, this),
m_value2(cache, "value2", "", validator, 0, this) m_value2(cache, "value2", "", validator, 0, this)
{ {
m_value1.setNotifySlot(&CValueCacheUser::ps_valueChanged); m_value1.setNotifySlot(&CValueCacheUser::ps_valueChanged);

View File

@@ -82,7 +82,11 @@ namespace BlackMisc
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex //! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant) 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>(); ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i) switch (i)
{ {

View File

@@ -36,8 +36,7 @@ args.append({ "-o", "-,txt" }); \
\ \
/* Output to file */ \ /* Output to file */ \
QString resultsFileName = QString(#TestObject).replace("::", "_").toLower(); \ QString resultsFileName = QString(#TestObject).replace("::", "_").toLower(); \
args.append({ "-o", resultsFileName + "_testresults.xml,xml" }); \ args.append({ "-o", resultsFileName + "_testresults.xml,xml" });
//! Implements a main() function that executes all tests in TestObject //! Implements a main() function that executes all tests in TestObject
//! without instantiating a QApplication object. //! without instantiating a QApplication object.
@@ -45,10 +44,13 @@ args.append({ "-o", resultsFileName + "_testresults.xml,xml" }); \
#define BLACKTEST_APPLESS_MAIN(TestObject) \ #define BLACKTEST_APPLESS_MAIN(TestObject) \
int main(int argc, char *argv[]) \ int main(int argc, char *argv[]) \
{ \ { \
try { \ try \
{ \
BLACKTEST_INIT(TestObject) \ BLACKTEST_INIT(TestObject) \
return QTest::qExec(&to, args); \ return QTest::qExec(&to, args); \
} catch (...) { \ } \
catch (...) \
{ \
return EXIT_FAILURE; \ return EXIT_FAILURE; \
} \ } \
} }
@@ -59,11 +61,14 @@ int main(int argc, char *argv[]) \
#define BLACKTEST_MAIN(TestObject) \ #define BLACKTEST_MAIN(TestObject) \
int main(int argc, char *argv[]) \ int main(int argc, char *argv[]) \
{ \ { \
try { \ try \
{ \
QCoreApplication app(argc, argv); \ QCoreApplication app(argc, argv); \
BLACKTEST_INIT(TestObject) \ BLACKTEST_INIT(TestObject) \
return QTest::qExec(&to, args); \ return QTest::qExec(&to, args); \
} catch (...) { \ } \
catch (...) \
{ \
return EXIT_FAILURE; \ return EXIT_FAILURE; \
} \ } \
} }