Explorar o código

test: avoid regressions with any and deduced const T[N] types

Michele Caini %!s(int64=4) %!d(string=hai) anos
pai
achega
b9a925dbd4
Modificáronse 1 ficheiros con 15 adicións e 0 borrados
  1. 15 0
      test/entt/core/any.cpp

+ 15 - 0
test/entt/core/any.cpp

@@ -1,4 +1,5 @@
 #include <algorithm>
+#include <string.h>
 #include <unordered_map>
 #include <vector>
 #include <gtest/gtest.h>
@@ -966,3 +967,17 @@ TEST_F(Any, AggregatesMustWork) {
     // the goal of this test is to enforce the requirements for aggregate types
     entt::any{std::in_place_type<aggregate_type>, 42}.emplace<aggregate_type>(42);
 }
+
+TEST_F(Any, DeducedArrayType) {
+    entt::any any{"array of char"};
+
+    ASSERT_TRUE(any);
+    ASSERT_EQ(any.type(), entt::type_id<const char *>());
+    ASSERT_EQ((std::strcmp("array of char", entt::any_cast<const char *>(any))), 0);
+
+    any = "another array of char";
+
+    ASSERT_TRUE(any);
+    ASSERT_EQ(any.type(), entt::type_id<const char *>());
+    ASSERT_EQ((std::strcmp("another array of char", entt::any_cast<const char *>(any))), 0);
+}