diff --git a/test/gd73_test.cc b/test/gd73_test.cc new file mode 100644 index 00000000..fd618dde --- /dev/null +++ b/test/gd73_test.cc @@ -0,0 +1,154 @@ +#include "gd73_test.hh" +#include "config.hh" +#include "gd73.hh" +#include "gd73_codeplug.hh" +#include "errorstack.hh" +#include +#include + +GD73Test::GD73Test(QObject *parent) + : UnitTestBase(parent) +{ + // pass... +} + +void +GD73Test::testBasicConfigEncoding() { + ErrorStack err; + GD73Codeplug codeplug; + if (! codeplug.encode(&_basicConfig, Codeplug::Flags(), err)) { + QFAIL(QString("Cannot encode codeplug for Radioddity GD77: %1") + .arg(err.format()).toStdString().c_str()); + } +} + +void +GD73Test::testBasicConfigDecoding() { + ErrorStack err; + GD73Codeplug codeplug; + if (! codeplug.encode(&_basicConfig, Codeplug::Flags(), err)) { + QFAIL(QString("Cannot encode codeplug for Radioddity GD77: %1") + .arg(err.format()).toStdString().c_str()); + } + + Config config; + if (! codeplug.decode(&config, err)) { + QFAIL(QString("Cannot decode codeplug for Radioddity GD77: %1") + .arg(err.format()).toStdString().c_str()); + } +} + +void +GD73Test::testChannelFrequency() { + ErrorStack err; + GD73Codeplug codeplug; + if (! codeplug.encode(&_channelFrequencyConfig, Codeplug::Flags(), err)) { + QFAIL(QString("Cannot encode codeplug for Radioddity GD77: {}") + .arg(err.format()).toStdString().c_str()); + } + + Config config; + if (! codeplug.decode(&config, err)) { + QFAIL(QString("Cannot decode codeplug for Radioddity GD77: {}") + .arg(err.format()).toStdString().c_str()); + } + + QCOMPARE(config.channelList()->channel(0)->rxFrequency(), + Frequency::fromHz(123456780ULL)); + QCOMPARE(config.channelList()->channel(0)->txFrequency(), + Frequency::fromHz(999999990ULL)); +} + + +void +GD73Test::testFMSignaling() { + + Config config; + config.radioIDs()->add(new DMRRadioID("ID", 1234567)); + + { + FMChannel *ch = new FMChannel(); + ch->setName("Channel 1"); + ch->setRXFrequency(Frequency::fromMHz(144.0)); + ch->setTXFrequency(Frequency::fromMHz(144.6)); + ch->setRXTone(Signaling::CTCSS_67_0Hz); + ch->setTXTone(Signaling::SIGNALING_NONE); + config.channelList()->add(ch); + } + + { + FMChannel *ch = new FMChannel(); + ch->setName("Channel 2"); + ch->setRXFrequency(Frequency::fromMHz(144.0)); + ch->setTXFrequency(Frequency::fromMHz(144.6)); + ch->setRXTone(Signaling::SIGNALING_NONE); + ch->setTXTone(Signaling::CTCSS_67_0Hz); + config.channelList()->add(ch); + } + + { + FMChannel *ch = new FMChannel(); + ch->setName("Channel 3"); + ch->setRXFrequency(Frequency::fromMHz(144.0)); + ch->setTXFrequency(Frequency::fromMHz(144.6)); + ch->setRXTone(Signaling::DCS_023N); + ch->setTXTone(Signaling::SIGNALING_NONE); + config.channelList()->add(ch); + } + + { + FMChannel *ch = new FMChannel(); + ch->setName("Channel 4"); + ch->setRXFrequency(Frequency::fromMHz(144.0)); + ch->setTXFrequency(Frequency::fromMHz(144.6)); + ch->setRXTone(Signaling::SIGNALING_NONE); + ch->setTXTone(Signaling::DCS_023N); + config.channelList()->add(ch); + } + + { + FMChannel *ch = new FMChannel(); + ch->setName("Channel 5"); + ch->setRXFrequency(Frequency::fromMHz(144.0)); + ch->setTXFrequency(Frequency::fromMHz(144.6)); + ch->setRXTone(Signaling::DCS_023I); + ch->setTXTone(Signaling::SIGNALING_NONE); + config.channelList()->add(ch); + } + + { + FMChannel *ch = new FMChannel(); + ch->setName("Channel 6"); + ch->setRXFrequency(Frequency::fromMHz(144.0)); + ch->setTXFrequency(Frequency::fromMHz(144.6)); + ch->setRXTone(Signaling::SIGNALING_NONE); + ch->setTXTone(Signaling::DCS_023I); + config.channelList()->add(ch); + } + + ErrorStack err; + GD73Codeplug codeplug; + if (! codeplug.encode(&config, Codeplug::Flags(), err)) { + QFAIL(QString("Cannot encode codeplug for Radioddity GD73: {}") + .arg(err.format()).toStdString().c_str()); + } + + Config compare; + if (! codeplug.decode(&compare, err)) { + QFAIL(QString("Cannot decode codeplug for Radioddity GD73: {}") + .arg(err.format()).toStdString().c_str()); + } + + QCOMPARE(compare.channelList()->count(), 6); + for (int i=0; icount(); i++) { + QVERIFY(compare.channelList()->channel(i)->is()); + QCOMPARE((unsigned int)compare.channelList()->channel(i)->as()->rxTone(), + (unsigned int)config.channelList()->channel(i)->as()->rxTone()); + QCOMPARE((unsigned int)compare.channelList()->channel(i)->as()->txTone(), + (unsigned int)config.channelList()->channel(i)->as()->txTone()); + } +} + + +QTEST_GUILESS_MAIN(GD73Test) + diff --git a/test/gd73_test.hh b/test/gd73_test.hh new file mode 100644 index 00000000..89ad07c5 --- /dev/null +++ b/test/gd73_test.hh @@ -0,0 +1,22 @@ +#ifndef GD73TEST_HH +#define GD73TEST_HH + + +#include "libdmrconfigtest.hh" + +class GD73Test : public UnitTestBase +{ + Q_OBJECT + +public: + explicit GD73Test(QObject *parent = nullptr); + +private slots: + void testBasicConfigEncoding(); + void testBasicConfigDecoding(); + void testChannelFrequency(); + + void testFMSignaling(); +}; + +#endif // GD73TEST_HH