From fe6361ce45cdb094ebea2e58b10ceb60fb17ebc5 Mon Sep 17 00:00:00 2001 From: Hannes Matuschek Date: Fri, 24 Jan 2025 15:23:50 +0100 Subject: [PATCH] Fixed encoding of group list indices for OpenGD77 channels. Addresses #539. (#559) --- lib/opengd77base_codeplug.cc | 2 +- test/opengd77_test.cc | 31 +++++++++++++++++++++++++++++++ test/opengd77_test.hh | 2 ++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/lib/opengd77base_codeplug.cc b/lib/opengd77base_codeplug.cc index 708b5477..338b9df3 100644 --- a/lib/opengd77base_codeplug.cc +++ b/lib/opengd77base_codeplug.cc @@ -102,7 +102,7 @@ OpenGD77BaseCodeplug::ChannelElement::clear() { enablePowerSave(false); enableBeep(false); clearDMRId(); - setGroupListIndex(0); + clearGroupListIndex(); setColorCode(0); clearAPRSIndex(); clearTXContact(); diff --git a/test/opengd77_test.cc b/test/opengd77_test.cc index 769cd426..7e4d4b14 100644 --- a/test/opengd77_test.cc +++ b/test/opengd77_test.cc @@ -82,6 +82,37 @@ OpenGD77Test::testChannelFrequency() { } +void +OpenGD77Test::testChannelGroupList() { + ErrorStack err; + + Config config, decoded; + if (! config.readYAML(":/data/config_test.yaml", err)) + QFAIL(QString("Cannot open codeplug file: %1") + .arg(err.format()).toLocal8Bit().constData()); + + config.channelList()->channel(0)->as()->setGroupListObj(nullptr); + config.channelList()->channel(0)->as()->setTXContactObj(nullptr); + config.channelList()->channel(1)->as()->setTXContactObj(nullptr); + config.channelList()->channel(2)->as()->setGroupListObj(nullptr); + + if (! encodeDecode(config, decoded, err)) + QFAIL(err.format().toLocal8Bit().constData()); + + QVERIFY(decoded.channelList()->channel(0)->as()->groupList()->isNull()); + QVERIFY(decoded.channelList()->channel(0)->as()->contact()->isNull()); + + QVERIFY(! decoded.channelList()->channel(1)->as()->groupList()->isNull()); + QVERIFY(decoded.channelList()->channel(1)->as()->contact()->isNull()); + + QVERIFY(decoded.channelList()->channel(2)->as()->groupList()->isNull()); + QVERIFY(! decoded.channelList()->channel(2)->as()->contact()->isNull()); + + QVERIFY(! decoded.channelList()->channel(3)->as()->groupList()->isNull()); + QVERIFY(decoded.channelList()->channel(3)->as()->contact()->isNull()); +} + + void OpenGD77Test::testChannelPowerSettings() { ErrorStack err; diff --git a/test/opengd77_test.hh b/test/opengd77_test.hh index 39686730..2c1e1393 100644 --- a/test/opengd77_test.hh +++ b/test/opengd77_test.hh @@ -21,6 +21,8 @@ private slots: void testBasicConfigDecoding(); void testChannelFrequency(); + /** Regression test for #539. */ + void testChannelGroupList(); /** Regression test for #507 */ void testChannelPowerSettings(); /** Regression test for #541. */