• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

wirenboard / wb-mqtt-serial / 1

20 Oct 2026 04:57AM UTC coverage: 86.817% (+14.0%) from 72.836%
1

Pull #1281

github

fab311
KraPete
Fix device model fallback in device/LoadConfig RPC

The short model register was never read because the extended register
error was converted to TRPCException. The RPC error now says that
the device model could not be read.
Pull Request #1281: Fix device model fallback in device/LoadConfig RPC

31180 of 80922 branches covered (38.53%)

74 of 76 new or added lines in 2 files covered. (97.37%)

1379 existing lines in 84 files now uncovered.

22464 of 25875 relevant lines covered (86.82%)

5205.91 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

79.49
/src/register_value.cpp
1
#include "register_value.h"
2

3
namespace
4
{
5
    std::string GetTypeName(TRegisterValue::ValueType type)
×
6
    {
7
        switch (type) {
×
8
            case TRegisterValue::ValueType::Undefined:
×
9
                return "Undefined";
×
10
            case TRegisterValue::ValueType::Integer:
×
11
                return "Integer";
×
12
            case TRegisterValue::ValueType::String:
×
13
                return "String";
×
14
        }
15
        return "Unknown";
×
16
    }
17
}
18

19
TRegisterValueException::TRegisterValueException(const char* file, int line, const std::string& message)
×
20
    : WBMQTT::TBaseException(file, line, message)
×
UNCOV
21
{}
×
22

23
template<> uint64_t TRegisterValue::Get<>() const
11,677 ✔
24
{
25
    CheckIntegerValue();
11,677 ✔
26
    return IntegerValue;
11,677 ✔
27
}
28

29
template<> int64_t TRegisterValue::Get<>() const
52 ✔
30
{
31
    CheckIntegerValue();
52 ✔
32
    return static_cast<int64_t>(IntegerValue);
52 ✔
33
}
34

35
template<> uint16_t TRegisterValue::Get() const
90 ✔
36
{
37
    CheckIntegerValue();
90 ✔
38
    return static_cast<uint16_t>(IntegerValue);
90 ✔
39
}
40

41
template<> int16_t TRegisterValue::Get() const
46 ✔
42
{
43
    CheckIntegerValue();
46 ✔
44
    return static_cast<int16_t>(Get<uint16_t>());
46 ✔
45
}
46

47
template<> uint32_t TRegisterValue::Get() const
134 ✔
48
{
49
    CheckIntegerValue();
134 ✔
50
    return static_cast<uint32_t>(IntegerValue);
134 ✔
51
}
52

53
template<> int32_t TRegisterValue::Get() const
132 ✔
54
{
55
    CheckIntegerValue();
132 ✔
56
    return static_cast<int32_t>(Get<uint32_t>());
132 ✔
57
}
58

59
template<> uint8_t TRegisterValue::Get() const
712 ✔
60
{
61
    CheckIntegerValue();
712 ✔
62
    return static_cast<uint8_t>(IntegerValue);
712 ✔
63
}
64

65
template<> int8_t TRegisterValue::Get() const
36 ✔
66
{
67
    CheckIntegerValue();
36 ✔
68
    return static_cast<int8_t>(Get<uint8_t>());
36 ✔
69
}
70

71
template<> std::string TRegisterValue::Get() const
654 ✔
72
{
73
    CheckStringValue();
654 ✔
74
    return StringValue;
654 ✔
75
}
76

77
TRegisterValue::TRegisterValue(uint64_t value)
12,039 ✔
78
{
79
    Set(value);
12,039 ✔
80
}
12,039 ✔
81

82
TRegisterValue::TRegisterValue(const std::string& stringValue)
606 ✔
83
{
84
    Set(stringValue);
606 !
85
}
606 ✔
86

87
void TRegisterValue::Set(uint64_t value)
13,805 ✔
88
{
89
    Type = ValueType::Integer;
13,805 ✔
90
    IntegerValue = value;
13,805 ✔
91
}
13,805 ✔
92

93
void TRegisterValue::Set(const std::string& value)
628 ✔
94
{
95
    Type = ValueType::String;
628 ✔
96
    StringValue = value;
628 ✔
97
}
628 ✔
98

99
TRegisterValue& TRegisterValue::operator=(const TRegisterValue& other)
10,725 ✔
100
{
101
    // Guard self assignment
102
    if (this == &other)
10,725 !
103
        return *this;
×
104

105
    Type = other.Type;
10,725 ✔
106
    switch (other.Type) {
10,725 ✔
107
        case ValueType::String:
74 ✔
108
            StringValue = other.StringValue;
74 ✔
109
            break;
74 ✔
110
        case ValueType::Integer:
10,647 ✔
111
            IntegerValue = other.IntegerValue;
10,647 ✔
112
            break;
10,647 ✔
113
        default:
4 ✔
114
            break;
4 ✔
115
    }
116
    return *this;
10,725 ✔
117
}
118

119
TRegisterValue& TRegisterValue::operator=(TRegisterValue&& other) noexcept
1,070 ✔
120
{
121
    // Guard self assignment
122
    if (this == &other)
1,070 !
123
        return *this;
×
124

125
    Type = other.Type;
1,070 ✔
126
    switch (other.Type) {
1,070 !
127
        case ValueType::String:
98 ✔
128
            StringValue.swap(other.StringValue);
98 ✔
129
            break;
98 ✔
130
        case ValueType::Integer:
972 ✔
131
            IntegerValue = other.IntegerValue;
972 ✔
132
            break;
972 ✔
133
        default:
×
134
            break;
×
135
    }
136
    return *this;
1,070 ✔
137
}
138

139
bool TRegisterValue::operator==(const TRegisterValue& other) const
534 ✔
140
{
141
    if (Type != other.Type) {
534 !
142
        return false;
×
143
    }
144
    switch (Type) {
534 !
145
        case ValueType::String:
10 ✔
146
            return (StringValue == other.StringValue);
10 ✔
147
        case ValueType::Integer:
524 ✔
148
            return IntegerValue == other.IntegerValue;
524 ✔
149
        default:
×
150
            return true;
×
151
    }
152
}
153

154
bool TRegisterValue::operator==(uint64_t other) const
8 ✔
155
{
156
    return *this == TRegisterValue{other};
8 !
157
}
158

159
bool TRegisterValue::operator!=(const TRegisterValue& other) const
230 ✔
160
{
161
    return !(*this == other);
230 ✔
162
}
163

164
TRegisterValue::ValueType TRegisterValue::GetType() const
2,208 ✔
165
{
166
    return Type;
2,208 ✔
167
}
168

169
void TRegisterValue::CheckIntegerValue() const
12,879 ✔
170
{
171
    if (Type != ValueType::Integer) {
12,879 !
172
        wb_throw(TRegisterValueException, ("Value is not Integer: " + GetTypeName(Type)));
×
173
    }
174
}
12,879 ✔
175

176
void TRegisterValue::CheckStringValue() const
654 ✔
177
{
178
    if (Type != ValueType::String) {
654 !
179
        wb_throw(TRegisterValueException, ("Value is not String: " + GetTypeName(Type)));
×
180
    }
181
}
654 ✔
182

183
std::ostream& operator<<(std::ostream& os, const TRegisterValue& obj)
1,326 ✔
184
{
185
    switch (obj.GetType()) {
1,326 !
186
        case TRegisterValue::ValueType::Undefined: {
×
187
            os << "Undefined";
×
188
            break;
×
189
        }
190
        case TRegisterValue::ValueType::Integer: {
1,316 ✔
191
            os << obj.Get<uint64_t>();
1,316 ✔
192
            break;
1,316 ✔
193
        }
194
        case TRegisterValue::ValueType::String: {
10 ✔
195
            os << obj.Get<std::string>();
10 !
196
            break;
10 ✔
197
        }
198
    }
199
    return os;
1,326 ✔
200
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc