static_assert( __cplusplus > 2020'99 ); #include "../Enum.h" #include #include #include #include static auto init= Alepha::Utility::enroll <=[] { using namespace Alepha::literals::enum_literals; using namespace Alepha::Testing::literals; using namespace Alepha::Testing::exports; using MyEnum= Alepha::Enum< "Adam"_value, "Baker"_value, "Charlie"_value, "David"_value >; "Enum round trip printing test"_test <= TableTest < []( const std::string s ) -> std::string { MyEnum e; std::istringstream iss{ s }; ( iss >> e ); return Alepha::IOStreams::String{} << e; } > ::Cases { { "Adam", { "Adam" }, "Adam" }, { "Charlie", { "Charlie" }, "Charlie" }, { "Wrong", { "Wrong" }, std::type_identity< Alepha::EnumTextMismatchError >{} }, }; "Enum failure parse"_test <= TableTest < []( const std::string s ) { try { MyEnum e; std::istringstream iss{ s }; ( iss >> e ); throw "Fail"; } catch( const Alepha::EnumTextMismatchError &ex ) { return ex.expectedValues(); } } > ::Cases { { "Wrong", { "Wrong" }, { "Adam", "Baker", "Charlie", "David" } }, }; };