Explorar o código

config: add ENTT_VERSION

Michele Caini %!s(int64=4) %!d(string=hai) anos
pai
achega
772ac64e3b
Modificáronse 3 ficheiros con 18 adicións e 0 borrados
  1. 6 0
      src/entt/config/version.h
  2. 4 0
      test/CMakeLists.txt
  3. 8 0
      test/entt/config/version.cpp

+ 6 - 0
src/entt/config/version.h

@@ -1,8 +1,14 @@
 #ifndef ENTT_CONFIG_VERSION_H
 #define ENTT_CONFIG_VERSION_H
 
+#include "macro.h"
+
 #define ENTT_VERSION_MAJOR 3
 #define ENTT_VERSION_MINOR 10
 #define ENTT_VERSION_PATCH 0
 
+#define ENTT_VERSION \
+    ENTT_XSTR(ENTT_VERSION_MAJOR) \
+    "." ENTT_XSTR(ENTT_VERSION_MINOR) "." ENTT_XSTR(ENTT_VERSION_PATCH)
+
 #endif

+ 4 - 0
test/CMakeLists.txt

@@ -174,6 +174,10 @@ if(ENTT_BUILD_SNAPSHOT)
     target_include_directories(cereal PRIVATE ${cereal_INCLUDE_DIR})
 endif()
 
+# Test config
+
+SETUP_BASIC_TEST(version entt/config/version.cpp)
+
 # Test container
 
 SETUP_BASIC_TEST(dense_map entt/container/dense_map.cpp)

+ 8 - 0
test/entt/config/version.cpp

@@ -0,0 +1,8 @@
+#include <regex>
+#include <gtest/gtest.h>
+#include <entt/config/version.h>
+
+TEST(Version, All) {
+    ASSERT_STREQ(ENTT_VERSION, ENTT_XSTR(ENTT_VERSION_MAJOR) "." ENTT_XSTR(ENTT_VERSION_MINOR) "." ENTT_XSTR(ENTT_VERSION_PATCH));
+    ASSERT_TRUE(std::regex_match(ENTT_VERSION, std::regex{"^[0-9]+\\.[0-9]+\\.[0-9]+$"}));
+}