Add parser support for bits

Change-Id: I8f36a2639d3f4911c2fb825dd3bf28956886a9a6
diff --git a/tests/leaf_editing.cpp b/tests/leaf_editing.cpp
index 53194c0..7b203f4 100644
--- a/tests/leaf_editing.cpp
+++ b/tests/leaf_editing.cpp
@@ -71,6 +71,8 @@
     schema->addLeaf("/", "mod:dummy", yang::Empty{});
     schema->addLeaf("/", "mod:readonly", yang::Int32{}, yang::AccessType::ReadOnly);
 
+    schema->addLeaf("/", "mod:flags", yang::Bits{{"carry", "sign"}});
+
     Parser parser(schema);
     std::string input;
     std::ostringstream errorStream;
@@ -457,6 +459,33 @@
                 expected.m_path.m_nodes.emplace_back(module_{"mod"}, leaf_("dummy"));
                 expected.m_data = empty_{};
             }
+
+            SECTION("bits")
+            {
+                input = "set mod:flags ";
+                decltype(bits_::m_bits) bits;
+                SECTION("<nothing>") {
+                    bits = {};
+                }
+                SECTION("carry") {
+                    input += "carry";
+                    bits = {"carry"};
+                }
+                SECTION("sign") {
+                    input += "sign";
+                    bits = {"sign"};
+                }
+                SECTION("carry sign") {
+                    input += "carry sign";
+                    bits = {"carry", "sign"};
+                }
+                SECTION("sign carry") {
+                    input += "sign carry";
+                    bits = {"sign", "carry"};
+                }
+                expected.m_path.m_nodes.emplace_back(module_{"mod"}, leaf_("flags"));
+                expected.m_data = bits_{bits};
+            }
         }
 
         command_ command = parser.parseCommand(input, errorStream);
@@ -614,6 +643,16 @@
             input = "set mod:readonly 123";
         }
 
+        SECTION("nonexistent bits")
+        {
+            input = "set mod:flags daw";
+        }
+
+        SECTION("same bit more than once")
+        {
+            input = "set mod:flags carry carry";
+        }
+
         REQUIRE_THROWS_AS(parser.parseCommand(input, errorStream), InvalidCommandException);
         REQUIRE(errorStream.str().find(expectedError) != std::string::npos);
     }