-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Access yaml-cpp version from within a program. #349
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| build/ | ||
| test/version_test.cpp |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #ifndef YAML_CPP_VERSION_H | ||
| #define YAML_CPP_VERSION_H | ||
|
|
||
| #if defined(_MSC_VER) || \ | ||
| (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ | ||
| (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 | ||
| #pragma once | ||
| #endif | ||
|
|
||
| #define YAML_CPP_VERSION_MAJOR 0 | ||
| #define YAML_CPP_VERSION_MINOR 5 | ||
| #define YAML_CPP_VERSION_PATCH 2 | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You'll have to update this to 3 :)
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if that's the case then should the equivalent variable in the top-level CMakeLists.txt also be 3? especially as this is the variable that is used to generate the version_test that this file is checked against.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is. |
||
|
|
||
| // String representation of the current version (ie. "0.1.2") | ||
| #define YAML_CPP_VERSION "0.5.2" | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably worth deriving from the other defines, as suggested in the comments. |
||
|
|
||
| #endif // YAML_CPP_VERSION_H | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| #include "yaml-cpp/version.h" | ||
|
|
||
| #include "gtest/gtest.h" | ||
|
|
||
| namespace YAML { | ||
| namespace { | ||
| TEST(VersionTest, Major) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Put { on the same line as the function. (For that matter, make sure you run it through clang-format using the style file at the base of the repo.) |
||
| { | ||
| ASSERT_EQ(${YAML_CPP_VERSION_MAJOR}, YAML_CPP_VERSION_MAJOR); | ||
| } | ||
|
|
||
| TEST(VersionTest, Minor) | ||
| { | ||
| ASSERT_EQ(${YAML_CPP_VERSION_MINOR}, YAML_CPP_VERSION_MINOR); | ||
| } | ||
|
|
||
| TEST(VersionTest, Path) | ||
| { | ||
| ASSERT_EQ(${YAML_CPP_VERSION_PATCH}, YAML_CPP_VERSION_PATCH); | ||
| } | ||
|
|
||
| TEST(VersionTest, String) | ||
| { | ||
| ASSERT_STREQ("${YAML_CPP_VERSION}", YAML_CPP_VERSION); | ||
| } | ||
| } | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. // namespace |
||
| } | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. // namespace YAML |
||
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.
Please append _62B23520_7C8E_11DE_8A39_0800200C9A66 to this, which is a random nonce I generated for all such defines.