Skip to content

Commit f2dc698

Browse files
committed
Removing std::cerr debugs and finished removing old function for creating temporary file
1 parent 35bc831 commit f2dc698

3 files changed

Lines changed: 27 additions & 40 deletions

File tree

test/locale_testing/test_locale_main.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,12 @@ TEST_CASE("Should parse doubld string locale independently") {
3434
}
3535

3636
TEST_CASE("Should process message with floats locale indpendently") {
37-
const auto* filename = std::tmpnam(NULL);
38-
39-
create_tmp_dbc_with(filename, R"(BO_ 234 MSG1: 8 Vector__XXX
37+
std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 234 MSG1: 8 Vector__XXX
4038
SG_ Sig1 : 55|16@0- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX
4139
SG_ Sig2 : 39|16@0- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX
4240
SG_ Sig3 : 23|16@0- (10,0) [-3276.8|-3276.7] "C" Vector__XXX
43-
SG_ Sig4 : 7|16@0- (1,-10) [0|32767] "" Vector__XXX)");
41+
SG_ Sig4 : 7|16@0- (1,-10) [0|32767] "" Vector__XXX)";
42+
const auto filename = create_temporary_dbc_with(dbc_contents.c_str());
4443

4544
auto parser = libdbc::DbcParser();
4645
parser.parse_file(filename);

test/test_dbc.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ TEST_CASE("Testing big endian, little endian") {
6767
SG_ Sig1 : 55|16@0- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX
6868
SG_ Sig2 : 39|16@1- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX)";
6969
const auto filename = create_temporary_dbc_with(dbc_contents.c_str());
70-
std::cerr << filename << std::endl;
7170

7271
auto parser = libdbc::DbcParser();
7372
parser.parse_file(filename.c_str());
@@ -92,7 +91,6 @@ TEST_CASE("Testing negative values") {
9291
SG_ Sig3 : 23|16@0- (10,0) [-3276.8|-3276.7] "C" Vector__XXX
9392
SG_ Sig4 : 7|16@0- (1,-10) [0|32767] "" Vector__XXX)";
9493
const auto filename = create_temporary_dbc_with(dbc_contents.c_str());
95-
std::cerr << filename << std::endl;
9694

9795
auto parser = libdbc::DbcParser();
9896
parser.parse_file(filename.c_str());
@@ -135,7 +133,6 @@ TEST_CASE("Special characters in unit") {
135133
std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 234 MSG1: 8 Vector__XXX
136134
SG_ Speed : 0|8@1+ (1,0) [0|204] "Km/h" DEVICE1,DEVICE2,DEVICE3)";
137135
const auto filename = create_temporary_dbc_with(dbc_contents.c_str());
138-
std::cerr << filename << std::endl;
139136

140137
auto parser = libdbc::DbcParser();
141138
parser.parse_file(filename.c_str());
@@ -155,7 +152,6 @@ TEST_CASE("Signal Value Description") {
155152
SG_ State2 : 0|8@1+ (1,0) [0|204] "" DEVICE1,DEVICE2,DEVICE3
156153
VAL_ 234 State1 123 "Description 1" 0 "Description 2" 90903489 "Big value and special characters &$§())!" ;)";
157154
const auto filename = create_temporary_dbc_with(dbc_contents.c_str());
158-
std::cerr << filename << std::endl;
159155

160156
auto parser = libdbc::DbcParser();
161157
parser.parse_file(filename.c_str());
@@ -182,7 +178,6 @@ TEST_CASE("Signal Value Description Extended CAN id") {
182178
SG_ State2 : 0|8@1+ (1,0) [0|204] "" DEVICE1,DEVICE2,DEVICE3
183179
VAL_ 3221225472 State1 123 "Description 1" 0 "Description 2" 4000000000 "Big value and special characters &$§())!" ;)";
184180
const auto filename = create_temporary_dbc_with(dbc_contents.c_str());
185-
std::cerr << filename << std::endl;
186181

187182
auto parser = libdbc::DbcParser();
188183
parser.parse_file(filename.c_str());
@@ -213,7 +208,6 @@ BO_ 123 MSG2: 8 Vector__XXX
213208
VAL_ 3221225472 State1 123 "Description 1" 0 "Description 2" ;
214209
VAL_ 123 State1 123 "Description 3" 0 "Description 4" ;)";
215210
const auto filename = create_temporary_dbc_with(dbc_contents.c_str());
216-
std::cerr << filename << std::endl;
217211

218212
auto parser = libdbc::DbcParser();
219213
parser.parse_file(filename.c_str());

test/test_parseMessage.cpp

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,22 @@
55
#include <libdbc/dbc.hpp>
66

77
#include "common.hpp"
8+
#include "defines.hpp"
89

910
// Testing of parsing messages
1011

1112
TEST_CASE("Parse Message Unknown ID") {
12-
libdbc::DbcParser parser;
13-
14-
const auto dbcContent = R"(BO_ 234 MSG1: 8 Vector__XXX
13+
std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 234 MSG1: 8 Vector__XXX
1514
SG_ Msg1Sig1 : 0|8@0+ (1,0) [-3276.8|-3276.7] "C" Vector__XXX
1615
SG_ MsgSig2 : 8|8@0+ (1,0) [-3276.8|-3276.7] "C" Vector__XXX
1716
BO_ 123 MSG2: 8 Vector__XXX
1817
SG_ Msg2Sig1 : 0|8@0+ (1,0) [-3276.8|-3276.7] "C" Vector__XXX
1918
SG_ Msg2Sig1 : 8|8@0+ (1,0) [-3276.8|-3276.7] "C" Vector__XXX
2019
)";
20+
const auto filename = create_temporary_dbc_with(dbc_contents.c_str());
2121

22-
const auto* filename = std::tmpnam(NULL);
23-
CHECK(create_tmp_dbc_with(filename, dbcContent));
24-
25-
parser.parse_file(filename);
22+
libdbc::DbcParser parser;
23+
parser.parse_file(filename.c_str());
2624

2725
SECTION("Evaluating unknown` message id") {
2826
std::vector<double> out_values;
@@ -31,9 +29,7 @@ BO_ 123 MSG2: 8 Vector__XXX
3129
}
3230

3331
TEST_CASE("Parse Message Big Number not aligned little endian") {
34-
libdbc::DbcParser parser;
35-
36-
const auto dbcContent = R"(BO_ 337 STATUS: 8 Vector__XXX
32+
std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 337 STATUS: 8 Vector__XXX
3733
SG_ Value6 : 27|3@1+ (1,0) [0|7] "" Vector__XXX
3834
SG_ Value5 : 16|11@1+ (0.1,-102) [-102|102] "%" Vector__XXX
3935
SG_ Value2 : 8|2@1+ (1,0) [0|2] "" Vector__XXX
@@ -42,10 +38,9 @@ TEST_CASE("Parse Message Big Number not aligned little endian") {
4238
SG_ Value4 : 11|4@1+ (1,0) [0|3] "" Vector__XXX
4339
SG_ Value1 : 0|8@1+ (1,0) [0|204] "Km/h" Vector__XXX
4440
)";
41+
const auto filename = create_temporary_dbc_with(dbc_contents.c_str());
4542

46-
const auto* filename = std::tmpnam(NULL);
47-
CHECK(create_tmp_dbc_with(filename, dbcContent));
48-
43+
libdbc::DbcParser parser;
4944
parser.parse_file(filename);
5045

5146
SECTION("Evaluating first message") {
@@ -83,20 +78,19 @@ TEST_CASE("Parse Message Big Number not aligned little endian") {
8378
}
8479

8580
TEST_CASE("Parse Message little endian") {
86-
const auto* filename = std::tmpnam(NULL);
87-
88-
create_tmp_dbc_with(filename, R"(BO_ 541 STATUS: 8 DEVICE1
81+
std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 541 STATUS: 8 DEVICE1
8982
SG_ Temperature : 48|16@1+ (0.01,-40) [-40|125] "C" DEVICE1
9083
SG_ SOH : 0|16@1+ (0.01,0) [0|100] "%" DEVICE1
9184
SG_ SOE : 32|16@1+ (0.01,0) [0|100] "%" DEVICE1
92-
SG_ SOC : 16|16@1+ (0.01,0) [0|100] "%" DEVICE1)");
85+
SG_ SOC : 16|16@1+ (0.01,0) [0|100] "%" DEVICE1)";
86+
const auto filename = create_temporary_dbc_with(dbc_contents.c_str());
9387

94-
libdbc::DbcParser p;
95-
p.parse_file(filename);
88+
libdbc::DbcParser parser;
89+
parser.parse_file(filename);
9690

9791
std::vector<uint8_t> data{0x08, 0x27, 0xa3, 0x22, 0xe5, 0x1f, 0x45, 0x14}; // little endian
9892
std::vector<double> result_values;
99-
REQUIRE(p.parseMessage(0x21d, data, result_values) == libdbc::Message::ParseSignalsStatus::Success);
93+
REQUIRE(parser.parseMessage(0x21d, data, result_values) == libdbc::Message::ParseSignalsStatus::Success);
10094
REQUIRE(result_values.size() == 4);
10195

10296
REQUIRE(Catch::Approx(result_values.at(0)) == 11.89);
@@ -106,8 +100,7 @@ TEST_CASE("Parse Message little endian") {
106100
}
107101

108102
TEST_CASE("Parse Message big endian signed values") {
109-
const auto* filename = std::tmpnam(NULL);
110-
create_tmp_dbc_with(filename, R"(BO_ 545 MSG: 8 BMS2
103+
std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 545 MSG: 8 BMS2
111104
SG_ Sig1 : 62|1@0+ (1,0) [0|0] "" Vector__XXX
112105
SG_ Sig2 : 49|2@0+ (1,0) [0|0] "" Vector__XXX
113106
SG_ Sig3 : 39|16@0- (0.1,0) [0|0] "A" Vector__XXX
@@ -119,10 +112,11 @@ TEST_CASE("Parse Message big endian signed values") {
119112
SG_ Sig9 : 56|1@0+ (1,0) [0|0] "" Vector__XXX
120113
SG_ Sig10 : 61|1@0+ (1,0) [0|0] "" Vector__XXX
121114
SG_ Sig11 : 7|16@0+ (0.001,0) [0|65.535] "V" Vector__XXX
122-
SG_ Sig12 : 23|16@0+ (0.1,0) [0|6553.5] "A" Vector__XXX)");
115+
SG_ Sig12 : 23|16@0+ (0.1,0) [0|6553.5] "A" Vector__XXX)";
116+
const auto filename = create_temporary_dbc_with(dbc_contents.c_str());
123117

124118
libdbc::DbcParser p;
125-
p.parse_file(filename);
119+
p.parse_file(filename.c_str());
126120

127121
std::vector<uint8_t> data{13, 177, 0, 216, 251, 180, 0, 31}; // big endian
128122
std::vector<double> result_values;
@@ -143,12 +137,12 @@ TEST_CASE("Parse Message big endian signed values") {
143137
}
144138

145139
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
140+
std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 403 INFORMATION: 8 Vector__XXX
148141
SG_ Voltage : 30|9@1+ (0.2,0) [0|102.2] "V" Vector__XXX
149142
SG_ Phase_Current : 20|10@1- (1,0) [-512|512] "A" Vector__XXX
150143
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)");
144+
SG_ Id_Current : 0|10@1- (1,0) [-512|512] "A" Vector__XXX)";
145+
const auto filename = create_temporary_dbc_with(dbc_contents.c_str());
152146

153147
libdbc::DbcParser p;
154148
p.parse_file(filename);
@@ -164,10 +158,10 @@ TEST_CASE("Parse Message with non byte aligned values") {
164158
}
165159

166160
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
161+
std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 234 MSG1: 8 Vector__XXX
169162
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)");
163+
SG_ Msg1Sig2 : 15|8@0+ (1,0) [-3276.8|-3276.7] "km/h" Vector__XXX)";
164+
const auto filename = create_temporary_dbc_with(dbc_contents.c_str());
171165

172166
libdbc::DbcParser p;
173167
p.parse_file(filename);

0 commit comments

Comments
 (0)