-
Notifications
You must be signed in to change notification settings - Fork 22
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
RSDK-8343 - create public version_metadata file #290
Conversation
@@ -115,6 +116,16 @@ BOOST_AUTO_TEST_CASE(test_from_dm_from_extra) { | |||
BOOST_CHECK_EQUAL(from_dm_from_extra(map), false); | |||
} | |||
|
|||
BOOST_AUTO_TEST_CASE(test_version_metadata) { | |||
// we don't want to check the specific values because they're going to be changing, |
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.
How about we get the sdk_version()
string here, and then check that it matches
std::to_string(sdk_major_version()) + "." + std::to_string(sdk_minor_version()) + "." + std::to_string(sdk_patch_version());
std::string sdk_version() { | ||
std::string version_metadata(impl::k_version); | ||
version_metadata.erase(0, version_metadata.find(';') + 1); | ||
return version_metadata.substr(0, version_metadata.find(';')); |
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.
Maybe have the function body as
static std::string result = []{
std::string version_metadata(impl::k_version);
version_metadata.erase(0, version_metadata.find(';') + 1);
return version_metadata.substr(0, version_metadata.find(';'));
}();
return result;
That way we only ever do this computation once.
This might seem like a micro optimization, but if this stuff later gets plugged into, eg, the response type of a grpc request that throws out the version, it could easily be hit over and over
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.
ooh good thinking! thanks :)
} | ||
|
||
int get_sub_version(int which) { | ||
auto version = sdk_version(); |
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.
Similarly here, we could do something like
static const std::array<int, 3> components = [] {
std::array<int, 3> result;
// copy your function here but let the `for` loop parse the `int`s into the array
return result;
}();
and then your function just returns components[i]
;
… into public-version-hpp
No description provided.