test/introspection: add more templated type_name tests

This commit is contained in:
Danny Robson 2019-05-28 13:48:45 +10:00
parent a21f09493d
commit 25746b2036

View File

@ -22,6 +22,21 @@ namespace bar {
}
///////////////////////////////////////////////////////////////////////////////
template <typename ValueT>
struct templated_with_type { ValueT inner; };
template <int ValueV>
struct templated_with_value { };
enum enumeration_t { FOO };
template <enumeration_t EnumV>
struct templated_with_enum { };
///////////////////////////////////////////////////////////////////////////////
// define introspection data
namespace cruft
@ -79,5 +94,23 @@ int main ()
tap.expect_eq (cruft::view (cruft::type_name<foo> ()), "foo", "struct type_name");
tap.expect_eq (cruft::view (cruft::type_name<bar::qux> ()), "qux", "namespaced struct type_name");
tap.expect_eq (
cruft::type_name<templated_with_type<int>> (),
std::string_view {"templated_with_type<int>"},
"templated_with_type"
);
tap.expect_eq (
cruft::type_name<templated_with_value<-1>> (),
std::string_view {"templated_with_value<-1>"},
"templated_with_value"
);
tap.expect_eq (
cruft::type_name<templated_with_enum<FOO>> (),
std::string_view {"templated_with_enum<FOO>"},
"templated_with_enum"
);
return tap.status ();
}