Skip to content

Commit 4dc7dfe

Browse files
committed
move parsing tests to test_parseMessage.cpp
1 parent f7f5741 commit 4dc7dfe

File tree

2 files changed

+44
-44
lines changed

2 files changed

+44
-44
lines changed

test/test_dbc.cpp

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -155,47 +155,3 @@ TEST_CASE("Special characters in unit") {
155155
REQUIRE(signal.unit.compare("Km/h") == 0);
156156
}
157157
}
158-
159-
TEST_CASE("Parse Message little endian") {
160-
const auto* filename = std::tmpnam(NULL);
161-
162-
create_tmp_dbc_with(filename, R"(BO_ 541 STATUS: 8 DEVICE1
163-
SG_ Temperature : 48|16@1+ (0.01,-40) [-40|125] "C" DEVICE1
164-
SG_ SOH : 0|16@1+ (0.01,0) [0|100] "%" DEVICE1
165-
SG_ SOE : 32|16@1+ (0.01,0) [0|100] "%" DEVICE1
166-
SG_ SOC : 16|16@1+ (0.01,0) [0|100] "%" DEVICE1)");
167-
168-
libdbc::DbcParser p;
169-
p.parse_file(filename);
170-
171-
std::vector<uint8_t> data{0x08, 0x27, 0xa3, 0x22, 0xe5, 0x1f, 0x45, 0x14}; // little endian
172-
std::vector<double> result_values;
173-
REQUIRE(p.parseMessage(0x21d, data, result_values) == libdbc::Message::ParseSignalsStatus::Success);
174-
REQUIRE(result_values.size() == 4);
175-
REQUIRE(Catch::Approx(result_values.at(0)) == 99.92);
176-
REQUIRE(Catch::Approx(result_values.at(1)) == 88.67);
177-
REQUIRE(Catch::Approx(result_values.at(2)) == 81.65);
178-
REQUIRE(Catch::Approx(result_values.at(3)) == 11.89);
179-
}
180-
181-
TEST_CASE("Parse Message big endian") {
182-
const auto* filename = std::tmpnam(NULL);
183-
create_tmp_dbc_with(filename, R"(BO_ 541 STATUS: 8 DEVICE1
184-
SG_ Temperature : 48|16@0+ (0.01,-40) [-40|125] "C" DEVICE1
185-
SG_ SOH : 0|16@0+ (0.01,0) [0|100] "%" DEVICE1
186-
SG_ SOE : 32|16@0+ (0.01,0) [0|100] "%" DEVICE1
187-
SG_ SOC : 16|16@0+ (0.01,0) [0|100] "%" DEVICE1)");
188-
189-
libdbc::DbcParser p;
190-
p.parse_file(filename);
191-
192-
std::vector<uint8_t> data{0x27, 0x08, 0x22, 0xa3, 0x1f, 0xe5, 0x14, 0x45}; // big endian
193-
std::vector<double> result_values;
194-
REQUIRE(p.parseMessage(0x21d, data, result_values) == libdbc::Message::ParseSignalsStatus::ErrorBigEndian);
195-
// Big endian not yet supported
196-
// REQUIRE(result_values.size() == 4);
197-
// REQUIRE(Catch::Approx(result_values.at(0)) == 99.92);
198-
// REQUIRE(Catch::Approx(result_values.at(1)) == 88.67);
199-
// REQUIRE(Catch::Approx(result_values.at(2)) == 81.65);
200-
// REQUIRE(Catch::Approx(result_values.at(3)) == 11.89);
201-
}

test/test_parseMessage.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,48 @@ TEST_CASE("Parse Message Big Number not aligned little endian") {
119119
}
120120
}
121121

122+
TEST_CASE("Parse Message little endian") {
123+
const auto* filename = std::tmpnam(NULL);
124+
125+
create_tmp_dbc_with(filename, R"(BO_ 541 STATUS: 8 DEVICE1
126+
SG_ Temperature : 48|16@1+ (0.01,-40) [-40|125] "C" DEVICE1
127+
SG_ SOH : 0|16@1+ (0.01,0) [0|100] "%" DEVICE1
128+
SG_ SOE : 32|16@1+ (0.01,0) [0|100] "%" DEVICE1
129+
SG_ SOC : 16|16@1+ (0.01,0) [0|100] "%" DEVICE1)");
130+
131+
libdbc::DbcParser p;
132+
p.parse_file(filename);
133+
134+
std::vector<uint8_t> data{0x08, 0x27, 0xa3, 0x22, 0xe5, 0x1f, 0x45, 0x14}; // little endian
135+
std::vector<double> result_values;
136+
REQUIRE(p.parseMessage(0x21d, data, result_values) == libdbc::Message::ParseSignalsStatus::Success);
137+
REQUIRE(result_values.size() == 4);
138+
REQUIRE(Catch::Approx(result_values.at(0)) == 99.92);
139+
REQUIRE(Catch::Approx(result_values.at(1)) == 88.67);
140+
REQUIRE(Catch::Approx(result_values.at(2)) == 81.65);
141+
REQUIRE(Catch::Approx(result_values.at(3)) == 11.89);
142+
}
143+
144+
TEST_CASE("Parse Message big endian") {
145+
const auto* filename = std::tmpnam(NULL);
146+
create_tmp_dbc_with(filename, R"(BO_ 541 STATUS: 8 DEVICE1
147+
SG_ Temperature : 48|16@0+ (0.01,-40) [-40|125] "C" DEVICE1
148+
SG_ SOH : 0|16@0+ (0.01,0) [0|100] "%" DEVICE1
149+
SG_ SOE : 32|16@0+ (0.01,0) [0|100] "%" DEVICE1
150+
SG_ SOC : 16|16@0+ (0.01,0) [0|100] "%" DEVICE1)");
151+
152+
libdbc::DbcParser p;
153+
p.parse_file(filename);
154+
155+
std::vector<uint8_t> data{0x27, 0x08, 0x22, 0xa3, 0x1f, 0xe5, 0x14, 0x45}; // big endian
156+
std::vector<double> result_values;
157+
REQUIRE(p.parseMessage(0x21d, data, result_values) == libdbc::Message::ParseSignalsStatus::ErrorBigEndian);
158+
// Big endian not yet supported
159+
// REQUIRE(result_values.size() == 4);
160+
// REQUIRE(Catch::Approx(result_values.at(0)) == 99.92);
161+
// REQUIRE(Catch::Approx(result_values.at(1)) == 88.67);
162+
// REQUIRE(Catch::Approx(result_values.at(2)) == 81.65);
163+
// REQUIRE(Catch::Approx(result_values.at(3)) == 11.89);
164+
}
165+
122166
// TODO: create also for big endian!

0 commit comments

Comments
 (0)