Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
build/
test/version_test.cpp
17 changes: 17 additions & 0 deletions include/yaml-cpp/version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef YAML_CPP_VERSION_H

Copy link
Copy Markdown
Owner

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.

#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

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll have to update this to 3 :)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The 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"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The 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
3 changes: 3 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" OR
set(yaml_test_flags "-Wno-c99-extensions -Wno-variadic-macros -Wno-sign-compare")
endif()

# Create version_test.cpp
configure_file(${YAML_CPP_SOURCE_DIR}/test/version_test.cpp.in ${YAML_CPP_SOURCE_DIR}/test/version_test.cpp)

file(GLOB test_headers [a-z_]*.h)
file(GLOB test_sources [a-z_]*.cpp integration/[a-z_]*.cpp node/[a-z_]*.cpp)
file(GLOB test_new_api_sources new-api/[a-z]*.cpp)
Expand Down
27 changes: 27 additions & 0 deletions test/version_test.cpp.in
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)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The 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);
}
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// namespace

}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// namespace YAML