6 #include <boost/test/auto_unit_test.hpp>
8 #include "zypp/base/Logger.h"
9 #include "zypp/base/InputStream.h"
10 #include "zypp/parser/IniParser.h"
12 #include "zypp/PathInfo.h"
18 using namespace zypp::parser;
19 using namespace boost::unit_test;
21 #define DATADIR (Pathname(TESTS_SRC_DIR) + "/parser/inifile/data")
23 class IniTest : public IniParser
25 virtual void consume( const std::string §ion )
27 MIL << section << endl;
30 virtual void consume( const std::string §ion, const std::string &key, const std::string &value )
32 MIL << "'" << section << "'" << " | " << "'" << key << "'" << " | " << "'" << value << "'" << endl;
33 if (section == "base" && key == "gpgcheck")
34 BOOST_CHECK_EQUAL(value, "1");
39 class WithSpacesTest : public IniParser
41 virtual void consume( const std::string §ion )
43 MIL << section << endl;
44 BOOST_CHECK(section == "base" || section == "equal");
47 virtual void consume( const std::string §ion, const std::string &key, const std::string &value )
49 MIL << "'" << section << "'" << " | " << "'" << key << "'" << " | " << "'" << value << "'" << endl;
50 if ( section == "base")
53 BOOST_CHECK_EQUAL( value, "foo" );
55 else if ( section == "equal" )
58 BOOST_CHECK_EQUAL( value, "=foo" );
59 else if ( key == "name2" )
60 BOOST_CHECK_EQUAL( value, "f=oo" );
61 else if ( key == "name3" )
62 BOOST_CHECK_EQUAL( value, "foo=" );
65 cout << "'" << section << "'" << " | " << "'" << key << "'" << " | " << "'" << value << "'" << endl;
66 BOOST_CHECK_MESSAGE( false, "Unhandled key" );
72 BOOST_AUTO_TEST_CASE(ini_read)
74 InputStream is((DATADIR+"/1.ini"));
79 BOOST_AUTO_TEST_CASE(ini_spaces_test)
81 InputStream is((DATADIR+"/2.ini"));
82 WithSpacesTest parser;