Fix enum key parsing

I'm not sure if this got broken during leaf_data rework, or if it was
always broken, but enum parsing had to get reworked.

The problem was parsing enums with "+char_". This works with set,
because set doesn't have any additional arguments. However, that's not
the case with key parsing. In key parsing +char_ was eating too much of
the input (mainly the closing bracker). At first I tried something like
"+char_-']'", but enums are normal strings, so ']' is a valid character.
That's why I reworked the parser to just try all the possible enums.

Change-Id: I5996286424dd95377b55f90eeba29d9a5eba731c
diff --git a/tests/cd.cpp b/tests/cd.cpp
index 307f287..174ffd0 100644
--- a/tests/cd.cpp
+++ b/tests/cd.cpp
@@ -8,6 +8,7 @@
 
 #include "trompeloeil_doctest.hpp"
 #include "ast_commands.hpp"
+#include "leaf_data_helpers.hpp"
 #include "parser.hpp"
 #include "static_schema.hpp"
 
@@ -30,6 +31,8 @@
     schema->addLeaf("/example:twoKeyList", "example:number", yang::Int32{});
     schema->addLeaf("/example:twoKeyList", "example:name", yang::String{});
     schema->addRpc("/", "example:launch-nukes");
+    schema->addList("/", "example:ports", {"name"});
+    schema->addLeaf("/example:ports", "example:name", createEnum({"A", "B", "C"}));
     Parser parser(schema);
     std::string input;
     std::ostringstream errorStream;
@@ -124,6 +127,14 @@
                     {"name", std::string{"abcd"}}};
                 expected.m_path.m_nodes.emplace_back(module_{"example"}, listElement_("twoKeyList", keys));
             }
+
+            SECTION("enum key type")
+            {
+                input = "cd example:ports[name=A]";
+                auto keys = ListInstance {
+                    {"name", enum_{"A"}}};
+                expected.m_path.m_nodes.emplace_back(module_{"example"}, listElement_("ports", keys));
+            }
         }
 
         SECTION("whitespace handling")