meta: refine internal::meta_arg_node + code coverage
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include "../config/config.h"
|
||||
#include "../container/dense_map.hpp"
|
||||
#include "../core/attribute.h"
|
||||
#include "../core/enum.hpp"
|
||||
@@ -141,6 +142,7 @@ template<typename... Args>
|
||||
return static_cast<element_type>(nullptr);
|
||||
} else {
|
||||
const element_type args[sizeof...(Args)]{&internal::resolve<std::remove_cv_t<std::remove_reference_t<Args>>>...};
|
||||
ENTT_ASSERT(index < sizeof...(Args), "Out of bounds");
|
||||
return args[index];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <entt/meta/meta.hpp>
|
||||
#include <entt/meta/resolve.hpp>
|
||||
#include <entt/meta/utility.hpp>
|
||||
#include "../common/config.h"
|
||||
|
||||
struct clazz {
|
||||
void setter(int v) {
|
||||
@@ -51,6 +52,8 @@ struct MetaUtility: ::testing::Test {
|
||||
}
|
||||
};
|
||||
|
||||
using MetaUtilityDeathTest = MetaUtility;
|
||||
|
||||
TEST_F(MetaUtility, MetaDispatch) {
|
||||
int value = 42;
|
||||
|
||||
@@ -79,6 +82,11 @@ TEST_F(MetaUtility, MetaArg) {
|
||||
ASSERT_EQ((entt::meta_arg<entt::type_list<int, char>>(1u)), entt::resolve<char>());
|
||||
}
|
||||
|
||||
ENTT_DEBUG_TEST_F(MetaUtilityDeathTest, MetaArg) {
|
||||
ASSERT_DEATH([[maybe_unused]] auto type = entt::meta_arg<entt::type_list<>>(0u), "");
|
||||
ASSERT_DEATH([[maybe_unused]] auto type = entt::meta_arg<entt::type_list<int>>(3u), "");
|
||||
}
|
||||
|
||||
TEST_F(MetaUtility, MetaSetter) {
|
||||
const int invalid{};
|
||||
clazz instance{};
|
||||
|
||||
Reference in New Issue
Block a user