-
Notifications
You must be signed in to change notification settings - Fork 5
use ctest and set path to dbc files with a compile definition #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…0) [0|204] "Km/h" DEVICE1,DEVICE2,DEVICE3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know when you are ready for review on this one. Here are some thoughts I had looking over it. Thank you for the work on this one!
test/test_dbc.cpp
Outdated
|
||
auto* file = std::fopen(filename, "w"); | ||
CHECK(file); | ||
|
||
std::fputs(PRIMITIVE_DBC.c_str(), file); | ||
std::fputs(R"(BO_ 234 MSG1: 8 Vector__XXX | ||
SG_ Sig1 : 55|16@0- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX | ||
SG_ Sig2 : 39|16@0- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX | ||
SG_ Sig3 : 23|16@0- (10,0) [-3276.8|-3276.7] "C" Vector__XXX | ||
SG_ Sig4 : 7|16@0- (1,-10) [0|32767] "" Vector__XXX)", file); | ||
std::fclose(file); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One quick refactor I would suggest is to pull this out into a function void create_tmp_dbc_with(const std::string_view content)
at the top of the test file here. That way you can pull out the duplicate code in the case below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would preferr not doing this, because consider you are adding additional tests then you have to create another function. I also don't like copy paste, but in tests I prefer, so when I change it at one position I don't break all tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess why would you need another function in that case? The only differences are the content you are putting in the tmp file right so the two function calls would like such:
create_tmp_dbc_with(R"(BO_ 234 MSG1: 8 Vector__XXX
SG_ Sig1 : 55|16@0- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX
SG_ Sig2 : 39|16@0- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX
SG_ Sig3 : 23|16@0- (10,0) [-3276.8|-3276.7] "C" Vector__XXX
SG_ Sig4 : 7|16@0- (1,-10) [0|32767] "" Vector__XXX)"
);
// In the other test case
create_tmp_dbc_with(R"(BO_ 234 MSG1: 8 Vector__XXX
SG_ Speed : 0|8@1+ (1,0) [0|204] "Km/h" DEVICE1,DEVICE2,DEVICE3)"
);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The actual function would be:
void create_tmp_dbc_with(const std::string_view content)
{
auto* file = std::fopen(filename, "w");
CHECK(file);
std::fputs(PRIMITIVE_DBC.c_str(), file);
std::fputs(content, file);
std::fclose(file);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok I understand yes this would be possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it fine using const char*
instead of string_view, because string_view requires c++17 and labplot currently uses c++11.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed in a666b52
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea that is fine with just const char *
. I forgot that i had it set to c++11. I left a comment about the inclusion of the <string_view>
header. Once that is removed I am good to merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed it in 2a4d059
No description provided.