Skip to content

Commit 3f2a88a

Browse files
committed
Description:Add testcase
1 parent a3b941a commit 3f2a88a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/test_parseMessage.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,24 @@ TEST_CASE("Parse Message big endian signed values") {
141141
REQUIRE(Catch::Approx(result_values.at(10)) == 3.5050);
142142
REQUIRE(Catch::Approx(result_values.at(11)) == 21.6);
143143
}
144+
145+
TEST_CASE("Parse Message with non byte aligned values") {
146+
const auto* filename = std::tmpnam(NULL);
147+
create_tmp_dbc_with(filename, R"(BO_ 403 INFORMATION: 8 Vector__XXX
148+
SG_ Voltage : 30|9@1+ (0.2,0) [0|102.2] "V" Vector__XXX
149+
SG_ Phase_Current : 20|10@1- (1,0) [-512|512] "A" Vector__XXX
150+
SG_ Iq_Current : 10|10@1- (1,0) [-512|512] "A" Vector__XXX
151+
SG_ Id_Current : 0|10@1- (1,0) [-512|512] "A" Vector__XXX)");
152+
153+
libdbc::DbcParser p;
154+
p.parse_file(filename);
155+
156+
std::vector<uint8_t> data{131, 51, 33, 9, 33, 0, 0, 0};
157+
std::vector<double> result_values;
158+
REQUIRE(p.parseMessage(545, data, result_values) == libdbc::Message::ParseSignalsStatus::Success);
159+
REQUIRE(result_values.size() == 4);
160+
REQUIRE(Catch::Approx(result_values.at(0)) == 26.4);
161+
REQUIRE(Catch::Approx(result_values.at(1)) == 146);
162+
REQUIRE(Catch::Approx(result_values.at(2)) == 76);
163+
REQUIRE(Catch::Approx(result_values.at(3)) == -125);
164+
}

0 commit comments

Comments
 (0)