- unsucessfully tried to fix bug on ini parsing...
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Tue, 19 Jun 2007 22:01:55 +0000 (22:01 +0000)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Tue, 19 Jun 2007 22:01:55 +0000 (22:01 +0000)
tests/parser/inifile/inidict_test.cc
tests/parser/inifile/iniparser_test.cc
zypp/RepoInfo.cc

index a16ef6c..a8de14a 100644 (file)
@@ -16,6 +16,7 @@
 using std::cout;
 using std::endl;
 using std::string;
+using std::map;
 using namespace zypp;
 using namespace zypp::parser;
 using namespace boost::unit_test;
@@ -39,6 +40,16 @@ void ini_read_test(const string &dir)
   }
 }
 
+void ini_read_test2(const string &dir)
+{
+  InputStream is((Pathname(dir)+"/2.ini"));
+  IniDict dict(is);
+
+  BOOST_CHECK( find( dict.sectionsBegin(), dict.sectionsEnd(), "base" ) != dict.sectionsEnd() );
+  //IniDict::entry_const_iterator i = find( dict.entriesBegin("base"), dict.entriesEnd("base"), "name");
+  //BOOST_CHECK( i != dict.entriesEnd("base") );
+}
+
 test_suite*
 init_unit_test_suite( int argc, char *argv[] )
 {
@@ -61,6 +72,8 @@ init_unit_test_suite( int argc, char *argv[] )
   std::string const params[] = { datadir };
   test->add(BOOST_PARAM_TEST_CASE(&ini_read_test,
                                  (std::string const*)params, params+1));
+  test->add(BOOST_PARAM_TEST_CASE(&ini_read_test2,
+                                 (std::string const*)params, params+1));
   return test;
 }
 
index ed31bba..ab40563 100644 (file)
@@ -29,7 +29,26 @@ class IniTest : public IniParser
 
   virtual void consume( const std::string &section, const std::string &key, const std::string &value )
   {
-    MIL << section << " | " << key << " | " << value << endl;
+    MIL << "'" << section << "'" << " | " << "'" << key << "'" << " | " << "'" << value << "'" << endl;
+  }
+};
+
+
+class WithSpacesTest : public IniParser
+{
+  virtual void consume( const std::string &section )
+  {
+    MIL << section << endl;
+  }
+
+  virtual void consume( const std::string &section, const std::string &key, const std::string &value )
+  {
+    MIL << "'" << section << "'" << " | " << "'" << key << "'" << " | " << "'" << value << "'" << endl;
+    if ( section == "base")
+    {
+      if ( key == "name" )
+        BOOST_CHECK_EQUAL( value, "foo" );
+    }
   }
 };
 
@@ -40,6 +59,13 @@ void ini_read_test(const string &dir)
   parser.parse(is);
 }
 
+void ini_spaces_test(const string &dir)
+{
+  InputStream is((Pathname(dir)+"/2.ini"));
+  WithSpacesTest parser;
+  parser.parse(is);
+}
+
 test_suite*
 init_unit_test_suite( int argc, char *argv[] )
 {
@@ -62,6 +88,8 @@ init_unit_test_suite( int argc, char *argv[] )
   std::string const params[] = { datadir };
   test->add(BOOST_PARAM_TEST_CASE(&ini_read_test,
                                  (std::string const*)params, params+1));
+  test->add(BOOST_PARAM_TEST_CASE(&ini_spaces_test,
+                                 (std::string const*)params, params+1));
   return test;
 }
 
index 13b41d8..a55348d 100644 (file)
@@ -191,19 +191,19 @@ namespace zypp
   std::ostream & RepoInfo::dumpRepoOn( std::ostream & str ) const
   {
     str << "[" << alias() << "]" << endl;
-    str << "name = " << name() << endl;
+    str << "name=" << name() << endl;
 
     if ( ! baseUrls().empty() )
-      str << "baseurl = ";
+      str << "baseurl=";
     for ( urls_const_iterator it = baseUrlsBegin();
           it != baseUrlsEnd();
           ++it )
     {
       str << *it << endl;
     }
-    str << "mirrorlist = " << mirrorListUrl() << endl;
-    str << "type = " << type().asString() << endl;
-    str << "enabled = " << (enabled() ? "1" : "0") << endl;
+    str << "mirrorlist=" << mirrorListUrl() << endl;
+    str << "type=" << type().asString() << endl;
+    str << "enabled=" << (enabled() ? "1" : "0") << endl;
     return str;
   }