meta: return a string_view from name()
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <gtest/gtest.h>
|
||||
#include <entt/core/hashed_string.hpp>
|
||||
@@ -169,13 +170,13 @@ TEST_F(MetaData, Name) {
|
||||
const entt::meta_type type = entt::resolve<clazz>();
|
||||
const entt::meta_type other = entt::resolve<setter_getter>();
|
||||
|
||||
ASSERT_EQ(type.data("i"_hs).name(), nullptr);
|
||||
ASSERT_STREQ(type.data("j"_hs).name(), "j");
|
||||
ASSERT_STREQ(type.data("h"_hs).name(), "hhh");
|
||||
ASSERT_EQ(type.data("i"_hs).name(), std::string_view{});
|
||||
ASSERT_EQ(type.data("j"_hs).name(), std::string_view{"j"});
|
||||
ASSERT_EQ(type.data("h"_hs).name(), std::string_view{"hhh"});
|
||||
|
||||
ASSERT_EQ(other.data("z"_hs).name(), nullptr);
|
||||
ASSERT_STREQ(other.data("w"_hs).name(), "w");
|
||||
ASSERT_STREQ(other.data("z_ro"_hs).name(), "readonly");
|
||||
ASSERT_EQ(other.data("z"_hs).name(), std::string_view{});
|
||||
ASSERT_EQ(other.data("w"_hs).name(), std::string_view{"w"});
|
||||
ASSERT_EQ(other.data("z_ro"_hs).name(), std::string_view{"readonly"});
|
||||
}
|
||||
|
||||
TEST_F(MetaData, Comparison) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <cstddef>
|
||||
#include <string_view>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <gtest/gtest.h>
|
||||
@@ -214,9 +215,9 @@ TEST_F(MetaFunc, Name) {
|
||||
|
||||
const entt::meta_type type = entt::resolve<derived>();
|
||||
|
||||
ASSERT_EQ(type.func("setter_from_base"_hs).name(), nullptr);
|
||||
ASSERT_STREQ(type.func("getter_from_base"_hs).name(), "getter_from_base");
|
||||
ASSERT_STREQ(type.func("static_setter_from_base"_hs).name(), "static setter");
|
||||
ASSERT_EQ(type.func("setter_from_base"_hs).name(), std::string_view{});
|
||||
ASSERT_EQ(type.func("getter_from_base"_hs).name(), std::string_view{"getter_from_base"});
|
||||
ASSERT_EQ(type.func("static_setter_from_base"_hs).name(), std::string_view{"static setter"});
|
||||
}
|
||||
|
||||
TEST_F(MetaFunc, Comparison) {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <gtest/gtest.h>
|
||||
@@ -313,10 +314,10 @@ TEST_F(MetaType, IdAndInfo) {
|
||||
TEST_F(MetaType, Name) {
|
||||
using namespace entt::literals;
|
||||
|
||||
ASSERT_EQ(entt::resolve<base>().name(), nullptr);
|
||||
ASSERT_STREQ(entt::resolve<derived>().name(), "derived");
|
||||
ASSERT_STREQ(entt::resolve<unsigned int>().name(), "uint");
|
||||
ASSERT_EQ(entt::resolve<void>().name(), nullptr);
|
||||
ASSERT_EQ(entt::resolve<base>().name(), std::string_view{});
|
||||
ASSERT_EQ(entt::resolve<derived>().name(), std::string_view{"derived"});
|
||||
ASSERT_EQ(entt::resolve<unsigned int>().name(), std::string_view{"uint"});
|
||||
ASSERT_EQ(entt::resolve<void>().name(), std::string_view{});
|
||||
}
|
||||
|
||||
TEST_F(MetaType, SizeOf) {
|
||||
|
||||
Reference in New Issue
Block a user