#include #include #include /////////////////////////////////////////////////////////////////////////////// namespace foo::bar { enum qux_t { qux0, qux1, }; } //----------------------------------------------------------------------------- static void test_local (cruft::TAP::logger &tap) { enum enum_t { value0 = 0, value1 = 1, value3 = 3, }; tap.expect_eq (cruft::introspection::from_string ("value1"), value1, "from_string, dynamic"); tap.expect_eq (cruft::introspection::to_string (), "value1", "to_string, static"); tap.expect_eq (cruft::introspection::to_string (value1), "value1", "to_string, dynamic"); } //----------------------------------------------------------------------------- static void test_namespaced (cruft::TAP::logger &tap) { auto const val = cruft::introspection::to_string (); (void)val; tap.expect_eq ( cruft::introspection::from_string ("qux1"), foo::bar::qux1, "namespaced: from_string, dynamic" ); tap.expect_eq ( cruft::introspection::to_string< foo::bar::qux_t, foo::bar::qux1 > (), "qux1", "namespaced: to_string, static" ); tap.expect_eq ( cruft::introspection::to_string(foo::bar::qux1), "qux1", "namespaced: to-string, dynamic" ); } //----------------------------------------------------------------------------- int main () { cruft::TAP::logger tap; test_local (tap); test_namespaced (tap); return tap.status (); }