summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/plugins/genericcanbus/dummybackend.cpp5
-rw-r--r--tests/auto/plugins/genericcanbus/dummybackend.h2
-rw-r--r--tests/auto/plugins/genericcanbus/main.cpp14
-rw-r--r--tests/auto/plugins/genericcanbusv1/dummybackendv1.cpp80
-rw-r--r--tests/auto/plugins/genericcanbusv1/dummybackendv1.h65
-rw-r--r--tests/auto/plugins/genericcanbusv1/genericcanbusv1.pro17
-rw-r--r--tests/auto/plugins/genericcanbusv1/main.cpp66
-rw-r--r--tests/auto/plugins/genericcanbusv1/plugin.json3
-rw-r--r--tests/auto/plugins/plugins.pro2
-rw-r--r--tests/auto/qcanbus/tst_qcanbus.cpp19
-rw-r--r--tests/auto/qcanbusframe/tst_qcanbusframe.cpp108
-rw-r--r--tests/auto/qmodbusdataunit/tst_qmodbusdataunit.cpp8
12 files changed, 373 insertions, 16 deletions
diff --git a/tests/auto/plugins/genericcanbus/dummybackend.cpp b/tests/auto/plugins/genericcanbus/dummybackend.cpp
index 82cdb86..4c3173a 100644
--- a/tests/auto/plugins/genericcanbus/dummybackend.cpp
+++ b/tests/auto/plugins/genericcanbus/dummybackend.cpp
@@ -84,4 +84,9 @@ QString DummyBackend::interpretErrorFrame(const QCanBusFrame &/*errorFrame*/)
return QString();
}
+QList<QCanBusDeviceInfo> DummyBackend::interfaces()
+{
+ return {createDeviceInfo(QStringLiteral("can0"), true, true)};
+}
+
QT_END_NAMESPACE
diff --git a/tests/auto/plugins/genericcanbus/dummybackend.h b/tests/auto/plugins/genericcanbus/dummybackend.h
index 965177b..22bbc80 100644
--- a/tests/auto/plugins/genericcanbus/dummybackend.h
+++ b/tests/auto/plugins/genericcanbus/dummybackend.h
@@ -56,6 +56,8 @@ public:
QString interpretErrorFrame(const QCanBusFrame &) override;
+ static QList<QCanBusDeviceInfo> interfaces();
+
public Q_SLOTS:
void sendMessage();
diff --git a/tests/auto/plugins/genericcanbus/main.cpp b/tests/auto/plugins/genericcanbus/main.cpp
index 838715a..8e14fee 100644
--- a/tests/auto/plugins/genericcanbus/main.cpp
+++ b/tests/auto/plugins/genericcanbus/main.cpp
@@ -38,18 +38,24 @@
#include <QtSerialBus/qcanbus.h>
#include <QtSerialBus/qcanbusfactory.h>
-
-#include <QtCore/qfile.h>
+#include "../../../../src/serialbus/qcanbusdeviceinfo_p.h"
QT_BEGIN_NAMESPACE
-class GenericBusPlugin : public QObject, public QCanBusFactory
+class GenericBusPlugin : public QObject, public QCanBusFactoryV2
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QCanBusFactory" FILE "plugin.json")
- Q_INTERFACES(QCanBusFactory)
+ Q_INTERFACES(QCanBusFactoryV2)
public:
+ QList<QCanBusDeviceInfo> availableDevices(QString *errorMessage) const override
+ {
+ Q_UNUSED(errorMessage);
+
+ return DummyBackend::interfaces();
+ }
+
QCanBusDevice *createDevice(const QString &interfaceName, QString *errorMessage) const override
{
if (interfaceName == QStringLiteral("invalid")) {
diff --git a/tests/auto/plugins/genericcanbusv1/dummybackendv1.cpp b/tests/auto/plugins/genericcanbusv1/dummybackendv1.cpp
new file mode 100644
index 0000000..117aeec
--- /dev/null
+++ b/tests/auto/plugins/genericcanbusv1/dummybackendv1.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 Andre Hartmann <aha_1980@gmx.de>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtSerialBus module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "dummybackendv1.h"
+
+#include <QtCore/qdatetime.h>
+#include <QtCore/qdebug.h>
+#include <QtCore/qtimer.h>
+
+QT_BEGIN_NAMESPACE
+
+DummyBackendV1::DummyBackendV1() :
+ sendTimer(new QTimer(this))
+{
+ connect(sendTimer, &QTimer::timeout, [this]() {
+ const quint64 timeStamp = QDateTime::currentDateTime().toMSecsSinceEpoch();
+ QCanBusFrame dummyFrame(11, "abc");
+ dummyFrame.setTimeStamp(QCanBusFrame::TimeStamp::fromMicroSeconds(timeStamp * 1000));
+
+ enqueueReceivedFrames({dummyFrame});
+ });
+ sendTimer->start(1000);
+}
+
+bool DummyBackendV1::open()
+{
+ setState(QCanBusDevice::ConnectedState);
+ return true;
+}
+
+void DummyBackendV1::close()
+{
+ setState(QCanBusDevice::UnconnectedState);
+}
+
+bool DummyBackendV1::writeFrame(const QCanBusFrame &data)
+{
+ qDebug("DummyBackendV1::writeFrame: %ls", qUtf16Printable(data.toString()));
+ return true;
+}
+
+QString DummyBackendV1::interpretErrorFrame(const QCanBusFrame &/*errorFrame*/)
+{
+ return QString();
+}
+
+QT_END_NAMESPACE
diff --git a/tests/auto/plugins/genericcanbusv1/dummybackendv1.h b/tests/auto/plugins/genericcanbusv1/dummybackendv1.h
new file mode 100644
index 0000000..4c3fc64
--- /dev/null
+++ b/tests/auto/plugins/genericcanbusv1/dummybackendv1.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 Andre Hartmann <aha_1980@gmx.de>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtSerialBus module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DUMMYBACKENDV1_H
+#define DUMMYBACKENDV1_H
+
+#include <QtSerialBus/qcanbusdevice.h>
+
+QT_BEGIN_NAMESPACE
+
+class QTimer;
+
+class DummyBackendV1 : public QCanBusDevice
+{
+ Q_OBJECT
+public:
+ explicit DummyBackendV1();
+
+ bool open() override;
+ void close() override;
+
+ bool writeFrame(const QCanBusFrame &data) override;
+
+ QString interpretErrorFrame(const QCanBusFrame &) override;
+
+private:
+ QTimer *sendTimer;
+};
+
+QT_END_NAMESPACE
+
+#endif // DUMMYBACKENDV1_H
diff --git a/tests/auto/plugins/genericcanbusv1/genericcanbusv1.pro b/tests/auto/plugins/genericcanbusv1/genericcanbusv1.pro
new file mode 100644
index 0000000..57c4aa1
--- /dev/null
+++ b/tests/auto/plugins/genericcanbusv1/genericcanbusv1.pro
@@ -0,0 +1,17 @@
+TARGET = qtcanbustestgenericv1
+
+QT = core serialbus
+
+HEADERS += \
+ dummybackendv1.h
+
+SOURCES += \
+ main.cpp \
+ dummybackendv1.cpp
+
+DISTFILES = plugin.json
+
+PLUGIN_TYPE = canbus
+PLUGIN_EXTENDS = -
+PLUGIN_CLASS_NAME = GenericBusPluginV1
+load(qt_plugin)
diff --git a/tests/auto/plugins/genericcanbusv1/main.cpp b/tests/auto/plugins/genericcanbusv1/main.cpp
new file mode 100644
index 0000000..3ed41f9
--- /dev/null
+++ b/tests/auto/plugins/genericcanbusv1/main.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 Andre Hartmann <aha_1980@gmx.de>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtSerialBus module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "dummybackendv1.h"
+
+#include <QtSerialBus/qcanbus.h>
+#include <QtSerialBus/qcanbusfactory.h>
+
+QT_BEGIN_NAMESPACE
+
+class GenericBusPluginV1 : public QObject, public QCanBusFactory
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QCanBusFactory" FILE "plugin.json")
+ Q_INTERFACES(QCanBusFactory)
+
+public:
+ QCanBusDevice *createDevice(const QString &interfaceName, QString *errorMessage) const override
+ {
+ if (interfaceName == QStringLiteral("invalid")) {
+ if (errorMessage)
+ *errorMessage = tr("No such interface: '%1'").arg(interfaceName);
+
+ return nullptr;
+ }
+ auto device = new DummyBackendV1();
+ return device;
+ }
+};
+
+QT_END_NAMESPACE
+
+#include "main.moc"
diff --git a/tests/auto/plugins/genericcanbusv1/plugin.json b/tests/auto/plugins/genericcanbusv1/plugin.json
new file mode 100644
index 0000000..e9f0f4c
--- /dev/null
+++ b/tests/auto/plugins/genericcanbusv1/plugin.json
@@ -0,0 +1,3 @@
+{
+ "Key": "genericv1"
+}
diff --git a/tests/auto/plugins/plugins.pro b/tests/auto/plugins/plugins.pro
index 58d4100..f4f4623 100644
--- a/tests/auto/plugins/plugins.pro
+++ b/tests/auto/plugins/plugins.pro
@@ -1,2 +1,2 @@
TEMPLATE = subdirs
-SUBDIRS += genericcanbus
+SUBDIRS += genericcanbus genericcanbusv1
diff --git a/tests/auto/qcanbus/tst_qcanbus.cpp b/tests/auto/qcanbus/tst_qcanbus.cpp
index 845b0c8..9e6a647 100644
--- a/tests/auto/qcanbus/tst_qcanbus.cpp
+++ b/tests/auto/qcanbus/tst_qcanbus.cpp
@@ -48,6 +48,7 @@ public:
private slots:
void initTestCase();
void plugins();
+ void interfaces();
void createDevice();
private:
@@ -82,11 +83,29 @@ void tst_QCanBus::plugins()
const QStringList pluginList = bus->plugins();
QVERIFY(!pluginList.isEmpty());
QVERIFY(pluginList.contains("generic"));
+ QVERIFY(pluginList.contains("genericv1"));
+}
+
+void tst_QCanBus::interfaces()
+{
+ // Plugins derived from QCanBusFactory(V1) don't have availableDevices()
+ const QList<QCanBusDeviceInfo> pluginListV1 = bus->availableDevices("genericV1");
+ QVERIFY(pluginListV1.isEmpty());
+ const QList<QCanBusDeviceInfo> pluginList = bus->availableDevices("generic");
+ QCOMPARE(1, pluginList.size());
+ QCOMPARE(QString("can0"), pluginList.at(0).name());
+ QVERIFY(pluginList.at(0).isVirtual());
+ QVERIFY(pluginList.at(0).hasFlexibleDataRate());
}
void tst_QCanBus::createDevice()
{
+ // Assure we can still create plugins derived from QCanBusFactory(V1)
+ QCanBusDevice *dummyV1 = bus->createDevice("genericv1", "unused");
+ QVERIFY(dummyV1);
+ delete dummyV1;
+
QString error, error2;
QCanBusDevice *dummy = bus->createDevice("generic", "unused");
QCanBusDevice *dummy2 = bus->createDevice("generic", "unused");
diff --git a/tests/auto/qcanbusframe/tst_qcanbusframe.cpp b/tests/auto/qcanbusframe/tst_qcanbusframe.cpp
index a6ab740..b67b6f8 100644
--- a/tests/auto/qcanbusframe/tst_qcanbusframe.cpp
+++ b/tests/auto/qcanbusframe/tst_qcanbusframe.cpp
@@ -48,6 +48,8 @@ private slots:
void id();
void payload();
void timeStamp();
+ void bitRateSwitch();
+ void errorStateIndicator();
void tst_isValid_data();
void tst_isValid();
@@ -180,6 +182,88 @@ void tst_QCanBusFrame::timeStamp()
QCOMPARE(timeStamp.microSeconds(), 1);
}
+void tst_QCanBusFrame::bitRateSwitch()
+{
+ QCanBusFrame frame(QCanBusFrame::DataFrame);
+ QVERIFY(!frame.hasBitrateSwitch());
+
+ // set CAN FD does not set BRS
+ frame.setFlexibleDataRateFormat(true);
+ QVERIFY(frame.hasFlexibleDataRateFormat());
+ QVERIFY(!frame.hasBitrateSwitch());
+
+ // set BRS keeps CAN FD
+ frame.setBitrateSwitch(true);
+ QVERIFY(frame.hasFlexibleDataRateFormat());
+ QVERIFY(frame.hasBitrateSwitch());
+
+ // clear BRS keeps CAN FD
+ frame.setBitrateSwitch(false);
+ QVERIFY(frame.hasFlexibleDataRateFormat());
+ QVERIFY(!frame.hasBitrateSwitch());
+
+ // clear CAN FD
+ frame.setFlexibleDataRateFormat(false);
+ QVERIFY(!frame.hasFlexibleDataRateFormat());
+ QVERIFY(!frame.hasBitrateSwitch());
+
+ // set BRS sets CAN FD
+ frame.setBitrateSwitch(true);
+ QVERIFY(frame.hasFlexibleDataRateFormat());
+ QVERIFY(frame.hasBitrateSwitch());
+
+ // clear CAN FD clears BRS
+ frame.setFlexibleDataRateFormat(false);
+ QVERIFY(!frame.hasFlexibleDataRateFormat());
+ QVERIFY(!frame.hasBitrateSwitch());
+
+ // default constructed CAN FD frame has no BRS
+ const QCanBusFrame frame2(0x123, QByteArray(10, 0x55));
+ QVERIFY(frame2.hasFlexibleDataRateFormat());
+ QVERIFY(!frame2.hasBitrateSwitch());
+}
+
+void tst_QCanBusFrame::errorStateIndicator()
+{
+ QCanBusFrame frame(QCanBusFrame::DataFrame);
+ QVERIFY(!frame.hasErrorStateIndicator());
+
+ // set CAN FD does not set ESI
+ frame.setFlexibleDataRateFormat(true);
+ QVERIFY(frame.hasFlexibleDataRateFormat());
+ QVERIFY(!frame.hasErrorStateIndicator());
+
+ // set ESI keeps CAN FD
+ frame.setErrorStateIndicator(true);
+ QVERIFY(frame.hasFlexibleDataRateFormat());
+ QVERIFY(frame.hasErrorStateIndicator());
+
+ // clear ESI keeps CAN FD
+ frame.setErrorStateIndicator(false);
+ QVERIFY(frame.hasFlexibleDataRateFormat());
+ QVERIFY(!frame.hasErrorStateIndicator());
+
+ // clear CAN FD
+ frame.setFlexibleDataRateFormat(false);
+ QVERIFY(!frame.hasFlexibleDataRateFormat());
+ QVERIFY(!frame.hasErrorStateIndicator());
+
+ // set ESI sets CAN FD
+ frame.setErrorStateIndicator(true);
+ QVERIFY(frame.hasFlexibleDataRateFormat());
+ QVERIFY(frame.hasErrorStateIndicator());
+
+ // clear CAN FD clears ESI
+ frame.setFlexibleDataRateFormat(false);
+ QVERIFY(!frame.hasFlexibleDataRateFormat());
+ QVERIFY(!frame.hasErrorStateIndicator());
+
+ // default constructed CAN FD frame has no ESI
+ const QCanBusFrame frame2(0x123, QByteArray(10, 0x55));
+ QVERIFY(frame2.hasFlexibleDataRateFormat());
+ QVERIFY(!frame2.hasErrorStateIndicator());
+}
+
void tst_QCanBusFrame::tst_isValid_data()
{
QTest::addColumn<QCanBusFrame::FrameType>("frameType");
@@ -346,33 +430,37 @@ void tst_QCanBusFrame::streaming_data()
QTest::addColumn<qint64>("microSeconds");
QTest::addColumn<bool>("isExtended");
QTest::addColumn<bool>("isFlexibleDataRate");
+ QTest::addColumn<bool>("isBitrateSwitch");
QTest::addColumn<QCanBusFrame::FrameType>("frameType");
QTest::newRow("emptyFrame") << quint32(0) << QByteArray()
<< qint64(0) << qint64(0)
- << false << false << QCanBusFrame::DataFrame;
+ << false << false << false << QCanBusFrame::DataFrame;
QTest::newRow("fullFrame1") << quint32(123) << QByteArray("abcde1")
<< qint64(456) << qint64(784)
- << true << false << QCanBusFrame::DataFrame;
+ << true << false << false << QCanBusFrame::DataFrame;
QTest::newRow("fullFrame2") << quint32(123) << QByteArray("abcde2")
<< qint64(457) << qint64(785)
- << false << false << QCanBusFrame::DataFrame;
+ << false << false << false << QCanBusFrame::DataFrame;
QTest::newRow("fullFrameFD") << quint32(123) << QByteArray("abcdfd")
<< qint64(457) << qint64(785)
- << false << true << QCanBusFrame::DataFrame;
+ << false << true << false << QCanBusFrame::DataFrame;
+ QTest::newRow("fullFrameBRS") << quint32(123) << QByteArray("abcdfd")
+ << qint64(457) << qint64(785)
+ << false << true << true << QCanBusFrame::DataFrame;
QTest::newRow("fullFrame3") << quint32(123) << QByteArray("abcde3")
<< qint64(458) << qint64(786)
- << true << false << QCanBusFrame::RemoteRequestFrame;
+ << true << false << false << QCanBusFrame::RemoteRequestFrame;
QTest::newRow("fullFrame4") << quint32(123) << QByteArray("abcde4")
<< qint64(459) << qint64(787)
- << false << false << QCanBusFrame::RemoteRequestFrame;
+ << false << false << false << QCanBusFrame::RemoteRequestFrame;
QTest::newRow("fullFrame5") << quint32(123) << QByteArray("abcde5")
<< qint64(460) << qint64(789)
- << true << false << QCanBusFrame::ErrorFrame;
+ << true << false << false << QCanBusFrame::ErrorFrame;
QTest::newRow("fullFrame6") << quint32(123) << QByteArray("abcde6")
<< qint64(453) << qint64(788)
- << false << false << QCanBusFrame::ErrorFrame;
+ << false << false << false << QCanBusFrame::ErrorFrame;
}
void tst_QCanBusFrame::streaming()
@@ -383,6 +471,7 @@ void tst_QCanBusFrame::streaming()
QFETCH(qint64, microSeconds);
QFETCH(bool, isExtended);
QFETCH(bool, isFlexibleDataRate);
+ QFETCH(bool, isBitrateSwitch);
QFETCH(QCanBusFrame::FrameType, frameType);
QCanBusFrame originalFrame(frameId, payload);
@@ -391,6 +480,7 @@ void tst_QCanBusFrame::streaming()
originalFrame.setExtendedFrameFormat(isExtended);
originalFrame.setFlexibleDataRateFormat(isFlexibleDataRate);
+ originalFrame.setBitrateSwitch(isBitrateSwitch);
originalFrame.setFrameType(frameType);
QByteArray buffer;
@@ -413,6 +503,8 @@ void tst_QCanBusFrame::streaming()
originalFrame.hasExtendedFrameFormat());
QCOMPARE(restoredFrame.hasFlexibleDataRateFormat(),
originalFrame.hasFlexibleDataRateFormat());
+ QCOMPARE(restoredFrame.hasBitrateSwitch(),
+ originalFrame.hasBitrateSwitch());
}
void tst_QCanBusFrame::tst_error()
diff --git a/tests/auto/qmodbusdataunit/tst_qmodbusdataunit.cpp b/tests/auto/qmodbusdataunit/tst_qmodbusdataunit.cpp
index 01502db..131411c 100644
--- a/tests/auto/qmodbusdataunit/tst_qmodbusdataunit.cpp
+++ b/tests/auto/qmodbusdataunit/tst_qmodbusdataunit.cpp
@@ -65,10 +65,12 @@ void tst_QModbusDataUnit::constructors()
QModbusDataUnit coils(QModbusDataUnit::Coils, 15, 20);
QCOMPARE(coils.registerType(), QModbusDataUnit::Coils);
QCOMPARE(coils.startAddress(), 15);
- QCOMPARE(coils.values().size(), 20);
- QCOMPARE(coils.values(), QVector<quint16>(20));
- foreach (auto val, coils.values())
+ const auto values = coils.values();
+ QCOMPARE(values.size(), 20);
+ QCOMPARE(values, QVector<quint16>(20));
+ for (auto val : values) {
QCOMPARE(val, quint16(0));
+ }
QCOMPARE(coils.valueCount(), 20u);
QModbusDataUnit unit2(QModbusDataUnit::HoldingRegisters, 3, QVector<quint16>() << 9);