mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2026-01-05 01:51:10 +07:00
type_id is just a data pointer now
This commit is contained in:
@@ -1,57 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "https://github.com/blackmatov/meta.hpp"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2021-2023, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#include <meta.hpp/meta_all.hpp>
|
||||
#include <doctest/doctest.h>
|
||||
|
||||
TEST_CASE("meta/meta_base/type_id") {
|
||||
namespace meta = meta_hpp;
|
||||
using meta::detail::type_id;
|
||||
using meta::detail::type_list;
|
||||
|
||||
static_assert(std::is_nothrow_constructible_v<type_id, type_list<int>>);
|
||||
static_assert(std::is_nothrow_copy_constructible_v<type_id>);
|
||||
static_assert(std::is_nothrow_move_constructible_v<type_id>);
|
||||
static_assert(std::is_nothrow_copy_assignable_v<type_id>);
|
||||
static_assert(std::is_nothrow_move_assignable_v<type_id>);
|
||||
|
||||
SUBCASE("ctor") {
|
||||
type_id int1_id{type_list<int>{}};
|
||||
type_id int2_id{type_list<int>{}};
|
||||
type_id float_id{type_list<float>{}};
|
||||
|
||||
CHECK(int1_id == int2_id);
|
||||
CHECK_FALSE(int2_id == float_id);
|
||||
|
||||
CHECK((int2_id < float_id || float_id < int2_id));
|
||||
CHECK_FALSE((int1_id < int2_id || int2_id < int1_id));
|
||||
}
|
||||
|
||||
SUBCASE("get_hash") {
|
||||
type_id int1_id{type_list<int>{}};
|
||||
type_id int2_id{type_list<int>{}};
|
||||
type_id float_id{type_list<float>{}};
|
||||
|
||||
CHECK(int1_id.get_hash() == int2_id.get_hash());
|
||||
CHECK_FALSE(int2_id.get_hash() == float_id.get_hash());
|
||||
}
|
||||
|
||||
SUBCASE("swap") {
|
||||
const type_id int_id{type_list<int>{}};
|
||||
const type_id float_id{type_list<float>{}};
|
||||
|
||||
type_id id1{type_list<int>{}};
|
||||
type_id id2{type_list<float>{}};
|
||||
|
||||
id1.swap(id2);
|
||||
CHECK(id1 == float_id);
|
||||
CHECK(id2 == int_id);
|
||||
|
||||
swap(id1, id2);
|
||||
CHECK(id1 == int_id);
|
||||
CHECK(id2 == float_id);
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "https://github.com/blackmatov/meta.hpp"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2021-2023, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#include <meta.hpp/meta_all.hpp>
|
||||
#include <doctest/doctest.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
struct A {};
|
||||
struct B {};
|
||||
}
|
||||
|
||||
TEST_CASE("meta/meta_issues/random/3") {
|
||||
namespace meta = meta_hpp;
|
||||
|
||||
meta::detail::type_registry& registry{meta::detail::type_registry::instance()};
|
||||
|
||||
meta::class_type a_type = registry.resolve_class_type<A>();
|
||||
meta::class_type b_type = registry.resolve_class_type<B>();
|
||||
|
||||
CHECK(registry.get_type_by_id(a_type.get_id()) == a_type);
|
||||
CHECK(registry.get_type_by_id(b_type.get_id()) == b_type);
|
||||
}
|
||||
Reference in New Issue
Block a user