test: bare minimum tests for meta types from different contexts

This commit is contained in:
Michele Caini
2022-10-12 10:04:28 +02:00
parent 2a39717893
commit d2048c037a
2 changed files with 15 additions and 3 deletions

View File

@@ -567,7 +567,7 @@ public:
/*! @copydoc any::operator== */
[[nodiscard]] bool operator==(const meta_any &other) const noexcept {
return (!node.info && !other.node.info) || (node.info && other.node.info && *node.info == *other.node.info && storage == other.storage);
return (ctx == other.ctx) && ((!node.info && !other.node.info) || (node.info && other.node.info && *node.info == *other.node.info && storage == other.storage));
}
/*! @copydoc any::operator!= */
@@ -1495,7 +1495,7 @@ public:
* @return True if the objects refer to the same type, false otherwise.
*/
[[nodiscard]] bool operator==(const meta_type &other) const noexcept {
return (!node.info && !other.node.info) || (node.info && other.node.info && *node.info == *other.node.info);
return (ctx == other.ctx) && ((!node.info && !other.node.info) || (node.info && other.node.info && *node.info == *other.node.info));
}
private:

View File

@@ -63,7 +63,19 @@ TEST_F(MetaContext, Resolve) {
TEST_F(MetaContext, MetaType) {
using namespace entt::literals;
// TODO
const auto global = entt::resolve<clazz>();
const auto local = entt::resolve<clazz>(context);
ASSERT_TRUE(global);
ASSERT_TRUE(local);
ASSERT_NE(global, local);
ASSERT_EQ(global, entt::resolve("foo"_hs));
ASSERT_EQ(local, entt::resolve(context, "bar"_hs));
ASSERT_EQ(global.id(), "foo"_hs);
ASSERT_EQ(local.id(), "bar"_hs);
}
TEST_F(MetaContext, MetaBase) {