diff --git a/.gitignore b/.gitignore index 567609b..0de87d4 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ build/ +test/version_test.cpp diff --git a/include/yaml-cpp/version.h b/include/yaml-cpp/version.h new file mode 100644 index 0000000..a3d9afd --- /dev/null +++ b/include/yaml-cpp/version.h @@ -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 + +// String representation of the current version (ie. "0.1.2") +#define YAML_CPP_VERSION "0.5.2" + +#endif // YAML_CPP_VERSION_H diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ad61a3c..2507134 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -23,6 +23,9 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR endif() 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) diff --git a/test/version_test.cpp.in b/test/version_test.cpp.in new file mode 100644 index 0000000..576b827 --- /dev/null +++ b/test/version_test.cpp.in @@ -0,0 +1,27 @@ +#include "yaml-cpp/version.h" + +#include "gtest/gtest.h" + +namespace YAML { +namespace { +TEST(VersionTest, Major) +{ + 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); +} +} +}