mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-08 18:16:02 -05:00
430d57c1ca
Default selection is the loop-back interface. Users who require interoperation between WSJT-X instances cooperating applications running on different hosts should select a suitable network interface and carefully choose a multicast group address, and TTL, that has minimal scope covering the necessary network(s). Using 224.0.0.1 is a reasonable strategy if all hosts are on the same subnet. Administratively scoped multicast group addresses like those within 239.255.0.0/16 can cover larger boundaries, but care must be taken if the local subnet has access to a multicast enabled router. The IPv4 broadcast address (255.255.255.255) may be used as an alternative to multicast UDP, but note that WSJT-X will only send broadcast UDP datagrams on the loop-back interface, so all recipient applications must be running on the same host system. The reference UDP Message protocol applications are being extended to be configurable with a list of interfaces to join a multicast group address on. By default they will only join on the loop-back interface, which is also recommended for any applications designed to take part in the WSJT-X UDP Message Protocol. This allows full user control of the scope of multicast group membership with a very conservative default mode that will work with all interoperating applications running on the same host system.
213 lines
7.6 KiB
C++
213 lines
7.6 KiB
C++
#include <QtTest>
|
|
#include <QDateTime>
|
|
#include <QDebug>
|
|
|
|
#include "qt_helpers.hpp"
|
|
|
|
class TestQtHelpers
|
|
: public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
private:
|
|
Q_SLOT void round_15s_date_time_up ()
|
|
{
|
|
QDateTime dt {QDate {2020, 8, 6}, QTime {14, 15, 22, 500}};
|
|
QCOMPARE (qt_round_date_time_to (dt, 15000), QDateTime (QDate (2020, 8, 6), QTime (14, 15, 30)));
|
|
}
|
|
|
|
Q_SLOT void truncate_15s_date_time_up ()
|
|
{
|
|
QDateTime dt {QDate {2020, 8, 6}, QTime {14, 15, 22, 500}};
|
|
QCOMPARE (qt_truncate_date_time_to (dt, 15000), QDateTime (QDate (2020, 8, 6), QTime (14, 15, 15)));
|
|
}
|
|
|
|
Q_SLOT void round_15s_date_time_down ()
|
|
{
|
|
QDateTime dt {QDate {2020, 8, 6}, QTime {14, 15, 22, 499}};
|
|
QCOMPARE (qt_round_date_time_to (dt, 15000), QDateTime (QDate (2020, 8, 6), QTime (14, 15, 15)));
|
|
}
|
|
|
|
Q_SLOT void truncate_15s_date_time_down ()
|
|
{
|
|
QDateTime dt {QDate {2020, 8, 6}, QTime {14, 15, 22, 499}};
|
|
QCOMPARE (qt_truncate_date_time_to (dt, 15000), QDateTime (QDate (2020, 8, 6), QTime (14, 15, 15)));
|
|
}
|
|
|
|
Q_SLOT void round_15s_date_time_on ()
|
|
{
|
|
QDateTime dt {QDate {2020, 8, 6}, QTime {14, 15, 15}};
|
|
QCOMPARE (qt_round_date_time_to (dt, 15000), QDateTime (QDate (2020, 8, 6), QTime (14, 15, 15)));
|
|
}
|
|
|
|
Q_SLOT void truncate_15s_date_time_on ()
|
|
{
|
|
QDateTime dt {QDate {2020, 8, 6}, QTime {14, 15, 15}};
|
|
QCOMPARE (qt_truncate_date_time_to (dt, 15000), QDateTime (QDate (2020, 8, 6), QTime (14, 15, 15)));
|
|
}
|
|
|
|
Q_SLOT void round_15s_date_time_under ()
|
|
{
|
|
QDateTime dt {QDate {2020, 8, 6}, QTime {14, 15, 14, 999}};
|
|
QCOMPARE (qt_round_date_time_to (dt, 15000), QDateTime (QDate (2020, 8, 6), QTime (14, 15, 15)));
|
|
}
|
|
|
|
Q_SLOT void truncate_15s_date_time_under ()
|
|
{
|
|
QDateTime dt {QDate {2020, 8, 6}, QTime {14, 15, 14, 999}};
|
|
QCOMPARE (qt_truncate_date_time_to (dt, 15000), QDateTime (QDate (2020, 8, 6), QTime (14, 15)));
|
|
}
|
|
|
|
Q_SLOT void round_15s_date_time_over ()
|
|
{
|
|
QDateTime dt {QDate {2020, 8, 6}, QTime {14, 15, 15, 1}};
|
|
QCOMPARE (qt_round_date_time_to (dt, 15000), QDateTime (QDate (2020, 8, 6), QTime (14, 15, 15)));
|
|
}
|
|
|
|
Q_SLOT void truncate_15s_date_time_over ()
|
|
{
|
|
QDateTime dt {QDate {2020, 8, 6}, QTime {14, 15, 15, 1}};
|
|
QCOMPARE (qt_truncate_date_time_to (dt, 15000), QDateTime (QDate (2020, 8, 6), QTime (14, 15, 15)));
|
|
}
|
|
|
|
Q_SLOT void round_7p5s_date_time_up ()
|
|
{
|
|
QDateTime dt {QDate {2020, 8, 6}, QTime {14, 15, 26, 250}};
|
|
QCOMPARE (qt_round_date_time_to (dt, 7500), QDateTime (QDate (2020, 8, 6), QTime (14, 15, 30)));
|
|
}
|
|
|
|
Q_SLOT void truncate_7p5s_date_time_up ()
|
|
{
|
|
QDateTime dt {QDate {2020, 8, 6}, QTime {14, 15, 26, 250}};
|
|
QCOMPARE (qt_truncate_date_time_to (dt, 7500), QDateTime (QDate (2020, 8, 6), QTime (14, 15, 22, 500)));
|
|
}
|
|
|
|
Q_SLOT void round_7p5s_date_time_down ()
|
|
{
|
|
QDateTime dt {QDate {2020, 8, 6}, QTime {14, 15, 26, 249}};
|
|
QCOMPARE (qt_round_date_time_to (dt, 7500), QDateTime (QDate (2020, 8, 6), QTime (14, 15, 22, 500)));
|
|
}
|
|
|
|
Q_SLOT void truncate_7p5s_date_time_down ()
|
|
{
|
|
QDateTime dt {QDate {2020, 8, 6}, QTime {14, 15, 26, 249}};
|
|
QCOMPARE (qt_truncate_date_time_to (dt, 7500), QDateTime (QDate (2020, 8, 6), QTime (14, 15, 22, 500)));
|
|
}
|
|
|
|
Q_SLOT void round_7p5s_date_time_on ()
|
|
{
|
|
QDateTime dt {QDate {2020, 8, 6}, QTime {14, 15, 22, 500}};
|
|
QCOMPARE (qt_round_date_time_to (dt, 7500), QDateTime (QDate (2020, 8, 6), QTime (14, 15, 22, 500)));
|
|
}
|
|
|
|
Q_SLOT void truncate_7p5s_date_time_on ()
|
|
{
|
|
QDateTime dt {QDate {2020, 8, 6}, QTime {14, 15, 22, 500}};
|
|
QCOMPARE (qt_truncate_date_time_to (dt, 7500), QDateTime (QDate (2020, 8, 6), QTime (14, 15, 22, 500)));
|
|
}
|
|
|
|
Q_SLOT void round_7p5s_date_time_under ()
|
|
{
|
|
QDateTime dt {QDate {2020, 8, 6}, QTime {14, 15, 22, 499}};
|
|
QCOMPARE (qt_round_date_time_to (dt, 7500), QDateTime (QDate (2020, 8, 6), QTime (14, 15, 22, 500)));
|
|
}
|
|
|
|
Q_SLOT void truncate_7p5s_date_time_under ()
|
|
{
|
|
QDateTime dt {QDate {2020, 8, 6}, QTime {14, 15, 22, 499}};
|
|
QCOMPARE (qt_truncate_date_time_to (dt, 7500), QDateTime (QDate (2020, 8, 6), QTime (14, 15, 15)));
|
|
}
|
|
|
|
Q_SLOT void round_7p5s_date_time_over ()
|
|
{
|
|
QDateTime dt {QDate {2020, 8, 6}, QTime {14, 15, 22, 501}};
|
|
QCOMPARE (qt_round_date_time_to (dt, 7500), QDateTime (QDate (2020, 8, 6), QTime (14, 15, 22, 500)));
|
|
}
|
|
|
|
Q_SLOT void truncate_7p5s_date_time_over ()
|
|
{
|
|
QDateTime dt {QDate {2020, 8, 6}, QTime {14, 15, 22, 501}};
|
|
QCOMPARE (qt_truncate_date_time_to (dt, 7500), QDateTime (QDate (2020, 8, 6), QTime (14, 15, 22, 500)));
|
|
}
|
|
|
|
Q_SLOT void is_multicast_address_data ()
|
|
{
|
|
QTest::addColumn<QString> ("addr");
|
|
QTest::addColumn<bool> ("result");
|
|
|
|
QTest::newRow ("loopback") << "127.0.0.1" << false;
|
|
QTest::newRow ("looback IPv6") << "::1" << false;
|
|
QTest::newRow ("lowest-") << "223.255.255.255" << false;
|
|
QTest::newRow ("lowest") << "224.0.0.0" << true;
|
|
QTest::newRow ("lowest- IPv6") << "feff:ffff:ffff:ffff:ffff:ffff:ffff:ffff" << false;
|
|
QTest::newRow ("lowest IPv6") << "ff00::" << true;
|
|
QTest::newRow ("highest") << "239.255.255.255" << true;
|
|
QTest::newRow ("highest+") << "240.0.0.0" << false;
|
|
QTest::newRow ("highest IPv6") << "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff" << true;
|
|
}
|
|
|
|
Q_SLOT void is_multicast_address ()
|
|
{
|
|
QFETCH (QString, addr);
|
|
QFETCH (bool, result);
|
|
|
|
QCOMPARE (::is_multicast_address (QHostAddress {addr}), result);
|
|
}
|
|
|
|
Q_SLOT void is_MAC_ambiguous_multicast_address_data ()
|
|
{
|
|
QTest::addColumn<QString> ("addr");
|
|
QTest::addColumn<bool> ("result");
|
|
|
|
QTest::newRow ("loopback") << "127.0.0.1" << false;
|
|
QTest::newRow ("looback IPv6") << "::1" << false;
|
|
|
|
QTest::newRow ("lowest- R1") << "223.255.255.255" << false;
|
|
QTest::newRow ("lowest R1") << "224.0.0.0" << false;
|
|
QTest::newRow ("highest R1") << "224.0.0.255" << false;
|
|
QTest::newRow ("highest+ R1") << "224.0.1.0" << false;
|
|
QTest::newRow ("lowest- R1A") << "224.127.255.255" << false;
|
|
QTest::newRow ("lowest R1A") << "224.128.0.0" << true;
|
|
QTest::newRow ("highest R1A") << "224.128.0.255" << true;
|
|
QTest::newRow ("highest+ R1A") << "224.128.1.0" << false;
|
|
|
|
QTest::newRow ("lowest- R2") << "224.255.255.255" << false;
|
|
QTest::newRow ("lowest R2") << "225.0.0.0" << true;
|
|
QTest::newRow ("highest R2") << "225.0.0.255" << true;
|
|
QTest::newRow ("highest+ R2") << "225.0.1.0" << false;
|
|
QTest::newRow ("lowest- R2A") << "225.127.255.255" << false;
|
|
QTest::newRow ("lowest R2A") << "225.128.0.0" << true;
|
|
QTest::newRow ("highest R2A") << "225.128.0.255" << true;
|
|
QTest::newRow ("highest+ R2A") << "225.128.1.0" << false;
|
|
|
|
QTest::newRow ("lowest- R3") << "238.255.255.255" << false;
|
|
QTest::newRow ("lowest R3") << "239.0.0.0" << true;
|
|
QTest::newRow ("highest R3") << "239.0.0.255" << true;
|
|
QTest::newRow ("highest+ R3") << "239.0.1.0" << false;
|
|
QTest::newRow ("lowest- R3A") << "239.127.255.255" << false;
|
|
QTest::newRow ("lowest R3A") << "239.128.0.0" << true;
|
|
QTest::newRow ("highest R3A") << "239.128.0.255" << true;
|
|
QTest::newRow ("highest+ R3A") << "239.128.1.0" << false;
|
|
|
|
QTest::newRow ("lowest- IPv6") << "feff:ffff:ffff:ffff:ffff:ffff:ffff:ffff" << false;
|
|
QTest::newRow ("lowest IPv6") << "ff00::" << false;
|
|
QTest::newRow ("highest") << "239.255.255.255" << false;
|
|
QTest::newRow ("highest+") << "240.0.0.0" << false;
|
|
QTest::newRow ("highest IPv6") << "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff" << false;
|
|
}
|
|
|
|
Q_SLOT void is_MAC_ambiguous_multicast_address ()
|
|
{
|
|
QFETCH (QString, addr);
|
|
QFETCH (bool, result);
|
|
|
|
QCOMPARE (::is_MAC_ambiguous_multicast_address (QHostAddress {addr}), result);
|
|
}
|
|
};
|
|
|
|
QTEST_MAIN (TestQtHelpers);
|
|
|
|
#include "test_qt_helpers.moc"
|