type flag tests

This commit is contained in:
BlackMATov
2021-08-06 16:43:18 +07:00
parent b2c3ec6584
commit 44f4a76052
10 changed files with 82 additions and 1 deletions

View File

@@ -25,6 +25,10 @@ TEST_CASE("features/types/arithmetic") {
CHECK(at.raw_type().id() == type_db::get<type>().id());
CHECK(at.size() == sizeof(type));
CHECK(at.flags() == (
arithmetic_flags::is_signed |
arithmetic_flags::is_integral));
CHECK_FALSE(at.is_const());
CHECK(at.is_signed());
CHECK_FALSE(at.is_unsigned());
@@ -44,6 +48,11 @@ TEST_CASE("features/types/arithmetic") {
CHECK(at.raw_type().id() == type_db::get<float>().id());
CHECK(at.size() == sizeof(type));
CHECK(at.flags() == (
arithmetic_flags::is_const |
arithmetic_flags::is_signed |
arithmetic_flags::is_floating_point));
CHECK(at.is_const());
CHECK(at.is_signed());
CHECK_FALSE(at.is_unsigned());
@@ -63,6 +72,11 @@ TEST_CASE("features/types/arithmetic") {
CHECK(at.raw_type().id() == type_db::get<unsigned>().id());
CHECK(at.size() == sizeof(type));
CHECK(at.flags() == (
arithmetic_flags::is_const |
arithmetic_flags::is_unsigned |
arithmetic_flags::is_integral));
CHECK(at.is_const());
CHECK_FALSE(at.is_signed());
CHECK(at.is_unsigned());

View File

@@ -24,6 +24,9 @@ TEST_CASE("features/types/array") {
CHECK(at.data_type().id() == type_db::get<int>().id());
CHECK(at.extent() == 0);
CHECK(at.flags() == (array_flags::is_unbounded));
CHECK_FALSE(at.is_bounded());
CHECK(at.is_unbounded());
}
@@ -39,6 +42,9 @@ TEST_CASE("features/types/array") {
CHECK(at.data_type().id() == type_db::get<const unsigned>().id());
CHECK(at.extent() == 42);
CHECK(at.flags() == (array_flags::is_bounded));
CHECK(at.is_bounded());
CHECK_FALSE(at.is_unbounded());
}

View File

@@ -43,6 +43,10 @@ TEST_CASE("features/types/class") {
CHECK(ct.raw_type().id() == type_db::get<type>().id());
CHECK(ct.size() == sizeof(type));
CHECK(ct.flags() == (
class_flags::is_abstract |
class_flags::is_polymorphic));
CHECK_FALSE(ct.is_const());
CHECK_FALSE(ct.is_empty());
CHECK_FALSE(ct.is_final());
@@ -62,6 +66,10 @@ TEST_CASE("features/types/class") {
CHECK(ct.raw_type().id() == type_db::get<type>().id());
CHECK(ct.size() == sizeof(type));
CHECK(ct.flags() == (
class_flags::is_final |
class_flags::is_polymorphic));
CHECK_FALSE(ct.is_const());
CHECK_FALSE(ct.is_empty());
CHECK(ct.is_final());
@@ -81,6 +89,10 @@ TEST_CASE("features/types/class") {
CHECK(ct.raw_type().id() == type_db::get<type>().id());
CHECK(ct.size() == sizeof(type));
CHECK(ct.flags() == (
class_flags::is_empty |
class_flags::is_final));
CHECK_FALSE(ct.is_const());
CHECK(ct.is_empty());
CHECK(ct.is_final());
@@ -100,6 +112,9 @@ TEST_CASE("features/types/class") {
CHECK(ct.raw_type().id() == type_db::get<type>().id());
CHECK(ct.size() == sizeof(type));
CHECK(ct.flags() == (
class_flags::is_final));
CHECK_FALSE(ct.is_const());
CHECK_FALSE(ct.is_empty());
CHECK(ct.is_final());
@@ -119,6 +134,10 @@ TEST_CASE("features/types/class") {
CHECK(ct.raw_type().id() == type_db::get<ivec2>().id());
CHECK(ct.size() == sizeof(type));
CHECK(ct.flags() == (
class_flags::is_const |
class_flags::is_final));
CHECK(ct.is_const());
CHECK_FALSE(ct.is_empty());
CHECK(ct.is_final());

View File

@@ -31,6 +31,8 @@ TEST_CASE("features/types/ctor") {
CHECK(ct.class_type().id() == type_db::get<ivec2>().id());
CHECK(ct.argument_types().size() == 0);
CHECK(ct.arity() == 0);
CHECK(ct.flags() == (ctor_flags::is_noexcept));
CHECK(ct.is_noexcept());
{
@@ -41,11 +43,13 @@ TEST_CASE("features/types/ctor") {
SUBCASE("ivec2_int") {
ctor_type ct{typename_arg<ivec2>, typename_arg<int>};
CHECK_FALSE(ct.is_noexcept());
CHECK(ct.arity() == 1);
CHECK(ct.class_type().id() == type_db::get<ivec2>().id());
CHECK(ct.argument_types().size() == 1);
CHECK(ct.flags() == (ctor_flags{}));
CHECK_FALSE(ct.is_noexcept());
{
REQUIRE(ct.argument_type(0));
const any_type arg0 = ct.argument_type(0);
@@ -63,6 +67,8 @@ TEST_CASE("features/types/ctor") {
CHECK(ct.class_type().id() == type_db::get<ivec2>().id());
CHECK(ct.argument_types().size() == 2);
CHECK(ct.arity() == 2);
CHECK(ct.flags() == (ctor_flags{}));
CHECK_FALSE(ct.is_noexcept());
{

View File

@@ -33,6 +33,8 @@ TEST_CASE("features/types/enum") {
CHECK(et.raw_type().id() == type_db::get<type>().id());
CHECK(et.underlying_type().id() == type_db::get<unsigned>().id());
CHECK(et.flags() == (enum_flags{}));
CHECK_FALSE(et.is_const());
}
@@ -47,6 +49,8 @@ TEST_CASE("features/types/enum") {
CHECK(et.raw_type().id() == type_db::get<ecolor>().id());
CHECK(et.underlying_type().id() == type_db::get<unsigned>().id());
CHECK(et.flags() == (enum_flags::is_const));
CHECK(et.is_const());
}
}

View File

@@ -35,6 +35,8 @@ TEST_CASE("features/types/function") {
CHECK(ft.return_type().id() == type_db::get<void>().id());
CHECK(ft.argument_types().size() == 1);
CHECK(ft.arity() == 1);
CHECK(ft.flags() == (function_flags{}));
CHECK_FALSE(ft.is_noexcept());
{
@@ -58,6 +60,8 @@ TEST_CASE("features/types/function") {
CHECK(ft.return_type().id() == type_db::get<void>().id());
CHECK(ft.argument_types().size() == 1);
CHECK(ft.arity() == 1);
CHECK(ft.flags() == (function_flags::is_noexcept));
CHECK(ft.is_noexcept());
{
@@ -81,6 +85,8 @@ TEST_CASE("features/types/function") {
CHECK(ft.return_type().id() == type_db::get<void>().id());
CHECK(ft.argument_types().size() == 1);
CHECK(ft.arity() == 1);
CHECK(ft.flags() == (function_flags::is_noexcept));
CHECK(ft.is_noexcept());
{

View File

@@ -44,6 +44,9 @@ TEST_CASE("features/types/method") {
CHECK(mt.return_type().id() == type_db::get<int&>().id());
CHECK(mt.argument_types().size() == 1);
CHECK(mt.arity() == 1);
CHECK(mt.flags() == (method_flags{}));
CHECK_FALSE(mt.is_const());
CHECK_FALSE(mt.is_noexcept());
@@ -69,6 +72,11 @@ TEST_CASE("features/types/method") {
CHECK(mt.return_type().id() == type_db::get<int>().id());
CHECK(mt.argument_types().size() == 0);
CHECK(mt.arity() == 0);
CHECK(mt.flags() == (
method_flags::is_const |
method_flags::is_noexcept));
CHECK(mt.is_const());
CHECK(mt.is_noexcept());

View File

@@ -31,6 +31,8 @@ TEST_CASE("features/types/pointer") {
CHECK(pt.id() == type_id{typename_arg<base_type::tag<type>>});
CHECK(pt.data_type().id() == type_db::get<ivec2>().id());
CHECK(pt.flags() == (pointer_flags{}));
CHECK_FALSE(pt.is_const());
}
@@ -44,6 +46,8 @@ TEST_CASE("features/types/pointer") {
CHECK(pt.id() == type_id{typename_arg<base_type::tag<type>>});
CHECK(pt.data_type().id() == type_db::get<const ivec2>().id());
CHECK(pt.flags() == (pointer_flags{}));
CHECK_FALSE(pt.is_const());
}
@@ -57,6 +61,8 @@ TEST_CASE("features/types/pointer") {
CHECK(pt.id() == type_id{typename_arg<base_type::tag<type>>});
CHECK(pt.data_type().id() == type_db::get<ivec2>().id());
CHECK(pt.flags() == (pointer_flags::is_const));
CHECK(pt.is_const());
}
@@ -70,6 +76,8 @@ TEST_CASE("features/types/pointer") {
CHECK(pt.id() == type_id{typename_arg<base_type::tag<type>>});
CHECK(pt.data_type().id() == type_db::get<const ivec2>().id());
CHECK(pt.flags() == (pointer_flags::is_const));
CHECK(pt.is_const());
}
}

View File

@@ -29,6 +29,9 @@ TEST_CASE("features/types/reference") {
CHECK(rt.id() == type_id{typename_arg<base_type::tag<ivec2&>>});
CHECK(rt.data_type().id() == type_db::get<ivec2>().id());
CHECK(rt.flags() == (reference_flags::is_lvalue));
CHECK(rt.is_lvalue());
CHECK_FALSE(rt.is_rvalue());
}
@@ -41,6 +44,9 @@ TEST_CASE("features/types/reference") {
CHECK(rt.id() == type_id{typename_arg<base_type::tag<const ivec2&&>>});
CHECK(rt.data_type().id() == type_db::get<const ivec2>().id());
CHECK(rt.flags() == (reference_flags::is_rvalue));
CHECK_FALSE(rt.is_lvalue());
CHECK(rt.is_rvalue());
}

View File

@@ -23,6 +23,8 @@ TEST_CASE("features/types/void") {
CHECK(vt.id() == type_id{typename_arg<base_type::tag<type>>});
CHECK(vt.raw_type().id() == type_db::get<type>().id());
CHECK(vt.flags() == (void_flags{}));
CHECK_FALSE(vt.is_const());
}
@@ -36,6 +38,8 @@ TEST_CASE("features/types/void") {
CHECK(vt.id() == type_id{typename_arg<base_type::tag<type>>});
CHECK(vt.raw_type().id() == type_db::get<void>().id());
CHECK(vt.flags() == (void_flags::is_const));
CHECK(vt.is_const());
}
}