11 #include <QDBusArgument>
35 using namespace swift::misc::aviation;
36 using namespace swift::misc::physical_quantities;
37 using namespace swift::misc::geo;
38 using namespace swift::misc::network;
71 QString toQString(
bool)
const {
return {}; }
79 Q_DECLARE_METATYPE(MiscTest::CTestMatcher)
85 void CTestVariantAndMap::variant()
89 CCoordinateGeodetic::fromWgs84(
"48° 21′ 13″ N",
"11° 47′ 09″ E", { 1487, CLengthUnit::ft() });
91 CFrequency(118.7, CFrequencyUnit::MHz()), geoPos,
CLength(50, CLengthUnit::km()),
false);
94 CFrequency(120.7, CFrequencyUnit::MHz()), geoPos,
CLength(100, CLengthUnit::km()),
false);
99 QVERIFY2(l1 == l2,
"Null lengths should be equal");
101 CLength l3(0, CLengthUnit::m());
102 CLength l4(-1, CLengthUnit::m());
103 QVERIFY2(l1 != l3,
"Null length and non-null length should not be equal");
104 QVERIFY2(l1 != l4,
"Null length and non-null length should not be equal");
105 QVERIFY2((l1 < l4) != (l1 > l4),
"Null length and non-null length should be comparable");
106 QVERIFY2(
compare(l1, l4) != 0,
"Null length and non-null length should be sortable");
109 QVERIFY2(station1 == station1,
"Station should be equal");
111 QVERIFY(station1.getController() == station2.getController());
112 QVERIFY(station1.getRelativeDistance() == station2.getRelativeDistance());
114 QVERIFY2(station1 == station2,
"Station should be equal");
115 QVERIFY2(station1 != station3,
"Station should not be equal");
123 QVERIFY2(
compare(station1, station3) != 0,
"Station should not be equal");
126 void CTestVariantAndMap::variantList()
131 QVERIFY2(variant.
convert(qMetaTypeId<CVariantList>()),
"Variant containing list can convert to CVariantList");
133 QVERIFY2(ints.size() == variantInts.size(),
"Variant list has same size as original list");
134 QVERIFY2(ints[0] == variantInts[0].value<int>(),
"Variant list has same element");
141 QVERIFY2(variant.
convert(qMetaTypeId<CVariantList>()),
"Variant containing list can convert to CVariantList");
143 QVERIFY2(list.size() == variantList.size(),
"Variant list has same size as original list");
144 QVERIFY2(list[0] == variantList[0].value<CAirlineIcaoCode>(),
"Variant list has same element");
149 void CTestVariantAndMap::matches()
151 CTestMatcher::registerMetadata();
152 const CTestMatcher matcher {};
157 void CTestVariantAndMap::valueMap()
161 CCoordinateGeodetic::fromWgs84(
"48° 21′ 13″ N",
"11° 47′ 09″ E", { 1487, CLengthUnit::ft() });
163 CFrequency(118.7, CFrequencyUnit::MHz()), geoPos,
CLength(50, CLengthUnit::km()),
false);
177 QVERIFY2(vmWildcard.matches(station1),
"Station should be equal to wildcard");
178 QVERIFY2(!vmNoWildcard.matches(station1),
"Station should not be equal to empty list");
180 QVERIFY2(vmWildcard == vmCopy,
"Maps should be equal");
184 vm.
addValue(CAtcStation::IndexPosition, geoPos);
195 #include "testvariantandmap.moc"
Variant and map related tests.
Specialized value object compliant map for variants, based on indexes.
bool matches(const T &value) const
True if this map matches the value.
void addValue(const CPropertyIndex &index, const CVariant &value)
Add a value.
bool isWildcard() const
Wildcard, only relevant when used in search.
Generic sequential container with value semantics.
Wrapper around QVariant which provides transparent access to CValueObject methods of the contained ob...
static CVariant fromValue(T &&value)
Construct a variant from a value.
T value() const
Return the value converted to the type T.
bool convert(int typeId)
Convert this variant to the type with the given metatype ID and return true if successful.
bool matches(const CVariant &event) const
If this is an event subscription, return true if it matches the given event.
bool canConvert(int typeId) const
True if this variant can be converted to the type with the given metatype ID.
Value object encapsulating a list of variants.
Value object for ICAO classification.
Value object encapsulating a list of ICAO codes.
Value object encapsulating information about an ATC station.
Value object encapsulating information of a callsign.
Value object encapsulating information of a user.
Physical unit length (length)
int compare(T a, T b)
Compare arithmetic values.
const QDBusArgument & operator>>(const QDBusArgument &arg, std::string &s)
Operator for std::string from QDBusArgument.
Free functions in swift::misc.
void registerMetadata()
Register all relevant metadata in Misc.
QDebug operator<<(QDebug d, const CRange< I > &range)
Streaming operators for CRange to qDebug.
QVERIFY2(condition, message)
SWIFTTEST_APPLESS_MAIN(MiscTest::CTestVariantAndMap)
main