From 39e63e816baaa5aebe7d6992a8f8653ac4fd81d0 Mon Sep 17 00:00:00 2001 From: Duncan Mac-Vicar P Date: Tue, 19 Jun 2007 22:01:55 +0000 Subject: [PATCH] - unsucessfully tried to fix bug on ini parsing... --- tests/parser/inifile/inidict_test.cc | 13 +++++++++++++ tests/parser/inifile/iniparser_test.cc | 30 +++++++++++++++++++++++++++++- zypp/RepoInfo.cc | 10 +++++----- 3 files changed, 47 insertions(+), 6 deletions(-) diff --git a/tests/parser/inifile/inidict_test.cc b/tests/parser/inifile/inidict_test.cc index a16ef6c..a8de14a 100644 --- a/tests/parser/inifile/inidict_test.cc +++ b/tests/parser/inifile/inidict_test.cc @@ -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; } diff --git a/tests/parser/inifile/iniparser_test.cc b/tests/parser/inifile/iniparser_test.cc index ed31bba..ab40563 100644 --- a/tests/parser/inifile/iniparser_test.cc +++ b/tests/parser/inifile/iniparser_test.cc @@ -29,7 +29,26 @@ class IniTest : public IniParser virtual void consume( const std::string §ion, 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 §ion ) + { + MIL << section << endl; + } + + virtual void consume( const std::string §ion, 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; } diff --git a/zypp/RepoInfo.cc b/zypp/RepoInfo.cc index 13b41d8..a55348d 100644 --- a/zypp/RepoInfo.cc +++ b/zypp/RepoInfo.cc @@ -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; } -- 2.7.4