@@ -1242,6 +1242,50 @@ TEST(ArgumentsCase, TaskStateEnum)
12421242 EXPECT_EQ (today::TaskState::Started, actual) << " should parse the enum" ;
12431243}
12441244
1245+ TEST (ArgumentsCase, TaskStateEnumFromString)
1246+ {
1247+ response::Value response (response::Type::Map);
1248+ response::Value status (" Started" );
1249+ response.emplace_back (" status" , std::move (status));
1250+ today::TaskState actual = static_cast <today::TaskState>(-1 );
1251+ bool caughtException = false ;
1252+ std::string exceptionWhat;
1253+
1254+ try
1255+ {
1256+ actual = service::ModifiedArgument<today::TaskState>::require (" status" , response);
1257+ }
1258+ catch (const service::schema_exception& ex)
1259+ {
1260+ caughtException = true ;
1261+ exceptionWhat = response::toJSON (response::Value (ex.getErrors ()));
1262+ }
1263+
1264+ EXPECT_NE (today::TaskState::Started, actual) << " should not parse the enum from a known string value" ;
1265+ ASSERT_TRUE (caughtException);
1266+ EXPECT_EQ (R"js( [{"message":"Invalid argument: status message: not a valid TaskState value"}])js" , exceptionWhat) << " exception should match" ;
1267+ }
1268+
1269+ TEST (ArgumentsCase, TaskStateEnumFromJSONString)
1270+ {
1271+ response::Value response (response::Type::Map);
1272+ response::Value status (" Started" );
1273+ response.emplace_back (" status" , status.from_json ());
1274+ today::TaskState actual = static_cast <today::TaskState>(-1 );
1275+
1276+
1277+ try
1278+ {
1279+ actual = service::ModifiedArgument<today::TaskState>::require (" status" , response);
1280+ }
1281+ catch (const service::schema_exception& ex)
1282+ {
1283+ FAIL () << response::toJSON (response::Value (ex.getErrors ()));
1284+ }
1285+
1286+ EXPECT_EQ (today::TaskState::Started, actual) << " should parse the enum" ;
1287+ }
1288+
12451289TEST (PegtlCase, ParseKitchenSinkQuery)
12461290{
12471291 memory_input<> input (R"gql(
0 commit comments