config_parser: Add type checking to config map

In order to guarantee the output file is consistent, the
constructed values are checked for safety.

Change-Id: Ib70e369471e9f2f47a1cdb5522f4a3bebc37805e
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/test/test_config_parser.cpp b/test/test_config_parser.cpp
index 909ad7f..e7d44ef 100644
--- a/test/test_config_parser.cpp
+++ b/test/test_config_parser.cpp
@@ -49,6 +49,31 @@
     EXPECT_FALSE(parseBool("oFf").value());
 }
 
+TEST(TestTypeChecking, Section)
+{
+    Section("");
+    Section("fds#1!'\"");
+    EXPECT_THROW(Section("fds]sf"), std::invalid_argument);
+    EXPECT_THROW(Section("g\ng"), std::invalid_argument);
+}
+
+TEST(TestTypeChecking, Value)
+{
+    Value("");
+    Value("=fds1!'\"#=");
+    Value("fds]sf'' #");
+    EXPECT_THROW(Value("g\ng"), std::invalid_argument);
+}
+
+TEST(TestTypeChecking, Key)
+{
+    Key("");
+    Key("fds1!'\"#");
+    Key("fds]sf'' #");
+    EXPECT_THROW(Key("fds]sf'='"), std::invalid_argument);
+    EXPECT_THROW(Key("g\ng"), std::invalid_argument);
+}
+
 class TestConfigParser : public stdplus::gtest::TestWithTmp
 {
   public: