~thopiekar/zypper/libzypp-manual-import

« back to all changes in this revision

Viewing changes to tests/parser/inifile/inidict_test.cc

  • Committer: Thomas-Karl Pietrowski
  • Date: 2014-01-29 22:44:28 UTC
  • Revision ID: thopiekar@googlemail.com-20140129224428-gpcqnsdakby362n8
firstĀ import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <iostream>
 
3
#include <fstream>
 
4
#include <vector>
 
5
#include <list>
 
6
#include <boost/test/auto_unit_test.hpp>
 
7
 
 
8
#include "zypp/base/Logger.h"
 
9
#include "zypp/base/InputStream.h"
 
10
#include "zypp/parser/IniDict.h"
 
11
#include "zypp/Url.h"
 
12
#include "zypp/PathInfo.h"
 
13
 
 
14
using std::cout;
 
15
using std::endl;
 
16
using std::string;
 
17
using std::map;
 
18
using namespace zypp;
 
19
using namespace zypp::parser;
 
20
using namespace boost::unit_test;
 
21
 
 
22
#define DATADIR (Pathname(TESTS_SRC_DIR) +  "/parser/inifile/data")
 
23
 
 
24
BOOST_AUTO_TEST_CASE(ini_read)
 
25
{
 
26
  InputStream is((DATADIR+"/1.ini"));
 
27
  IniDict dict(is);
 
28
 
 
29
  //MIL << dict["homedmacvicar"]["type"] << endl;
 
30
 
 
31
  for ( IniDict::section_const_iterator it = dict.sectionsBegin(); it != dict.sectionsEnd(); ++it )
 
32
  {
 
33
    MIL << (*it) << endl;
 
34
    
 
35
    for ( IniDict::entry_const_iterator it2 = dict.entriesBegin(*it); it2 != dict.entriesEnd(*it); ++it2 )
 
36
    {
 
37
      MIL << "  - " << (*it2).first << " | " << (*it2).second << endl;
 
38
    }
 
39
  }
 
40
 
 
41
  BOOST_CHECK( dict.hasSection("addons") );
 
42
  BOOST_CHECK( !dict.hasSection("uhlala") );
 
43
  BOOST_CHECK( dict.hasEntry("contrib", "name") );
 
44
  BOOST_CHECK( !dict.hasEntry("foo", "bar") );
 
45
}
 
46
 
 
47
BOOST_AUTO_TEST_CASE(ini_read2)
 
48
{
 
49
  InputStream is((DATADIR+"/2.ini"));
 
50
  IniDict dict(is);
 
51
 
 
52
  BOOST_CHECK( find( dict.sectionsBegin(), dict.sectionsEnd(), "base" ) != dict.sectionsEnd() );
 
53
  //IniDict::entry_const_iterator i = find( dict.entriesBegin("base"), dict.entriesEnd("base"), "name");
 
54
  //BOOST_CHECK( i != dict.entriesEnd("base") );
 
55
}
 
56
 
 
57
// vim: set ts=2 sts=2 sw=2 ai et: