Skip to content

Commit 2f50209

Browse files
committed
Add test
1 parent 4ee2047 commit 2f50209

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/test_parseMessage.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,20 @@ TEST_CASE("Parse Message with non byte aligned values") {
162162
REQUIRE(Catch::Approx(result_values.at(2)) == 76);
163163
REQUIRE(Catch::Approx(result_values.at(3)) == -125);
164164
}
165+
166+
TEST_CASE("Parse Message data length < 8 unsigned") {
167+
const auto* filename = std::tmpnam(NULL);
168+
create_tmp_dbc_with(filename, R"(BO_ 234 MSG1: 8 Vector__XXX
169+
SG_ Msg1Sig1 : 7|8@0+ (1,0) [-3276.8|-3276.7] "C" Vector__XXX
170+
SG_ Msg1Sig2 : 15|8@0+ (1,0) [-3276.8|-3276.7] "km/h" Vector__XXX)");
171+
172+
libdbc::DbcParser p;
173+
p.parse_file(filename);
174+
175+
std::vector<uint8_t> data{0x1, 0x2};
176+
std::vector<double> result_values;
177+
REQUIRE(p.parseMessage(234, data, result_values) == libdbc::Message::ParseSignalsStatus::Success);
178+
REQUIRE(result_values.size() == 2);
179+
REQUIRE(Catch::Approx(result_values.at(0)) == 0x1);
180+
REQUIRE(Catch::Approx(result_values.at(1)) == 0x2);
181+
}

0 commit comments

Comments
 (0)