-
Notifications
You must be signed in to change notification settings - Fork 13
/
testqmodbusbits.cpp
56 lines (48 loc) · 1.49 KB
/
testqmodbusbits.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/****************************************************************************
**
** SPDX-License-Identifier: LGPL-3.0-or-later
** SPDX-FileCopyrightText: 2012 - present, Karol Drożak <[email protected]>
**
****************************************************************************/
#include "testqmodbusbits.h"
#include "qmodbusbits.h"
#include <QtTest/QTest>
void TestQModbusBits::testGetValue ()
{
Modbus::QModbusBits bits (4, 16);
QCOMPARE (bits.getValue (3), false);
}
void TestQModbusBits::testGetNumber ()
{
Modbus::QModbusBits bits (4, 16);
QCOMPARE (bits.getNumber (), (unsigned int)16);
}
void TestQModbusBits::testGetAddress ()
{
Modbus::QModbusBits bits (4, 16);
QCOMPARE (bits.getAddress (), (unsigned int)4);
}
void TestQModbusBits::testSetAndGetValue ()
{
Modbus::QModbusBits bits (0, 16);
bits.setValue (8, true);
QCOMPARE (bits.getValue (8), true);
bits.setValue (8, false);
QCOMPARE (bits.getValue (8), false);
}
void TestQModbusBits::testSetAndGetNumber ()
{
Modbus::QModbusBits bits (0, 16);
bits.setNumber (8);
QCOMPARE (bits.getNumber (), (unsigned int)8);
bits.setNumber (32);
QCOMPARE (bits.getNumber (), (unsigned int)32);
}
void TestQModbusBits::testSetAndGetAddress ()
{
Modbus::QModbusBits bits (0, 16);
bits.setAddress (8);
QCOMPARE (bits.getAddress (), (unsigned int)8);
bits.setAddress (16);
QCOMPARE (bits.getAddress (), (unsigned int)16);
}