~thopiekar/zypper/libzypp-manual-import

« back to all changes in this revision

Viewing changes to tests/parser/ws/WebpinResultFileReader_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/parser/ws/WebpinResultFileReader.h"
 
9
#include "zypp/ws/WebpinResult.h"
 
10
 
 
11
#include "zypp/Url.h"
 
12
#include "zypp/PathInfo.h"
 
13
 
 
14
using namespace std;
 
15
using namespace zypp;
 
16
using namespace boost::unit_test;
 
17
 
 
18
using namespace zypp::ws;
 
19
using namespace zypp::parser::ws;
 
20
 
 
21
#define DATADIR (Pathname(TESTS_SRC_DIR) + "parser/ws/data")
 
22
 
 
23
class Collector
 
24
{
 
25
public:
 
26
  Collector()
 
27
  {}
 
28
  
 
29
  bool callback( const WebpinResult &result )
 
30
  {
 
31
    items.push_back(result);
 
32
    //items.push_back(loc);
 
33
    //cout << items.size() << endl;
 
34
    return true;
 
35
  }
 
36
  
 
37
  vector<WebpinResult> items;
 
38
};
 
39
 
 
40
BOOST_AUTO_TEST_CASE(result_read)
 
41
{  
 
42
    Collector collect;
 
43
    Pathname file;
 
44
 
 
45
    // this testcase represents this search:
 
46
    // http://api.opensuse-community.org/searchservice/Search/Simple/openSUSE_103/kopete
 
47
 
 
48
    file = DATADIR + "/search-kopete.xml";
 
49
    
 
50
    WebpinResultFileReader reader( file, bind( &Collector::callback, &collect, _1));
 
51
    BOOST_CHECK_EQUAL( collect.items.size(), 17);
 
52
    
 
53
    WebpinResult first = collect.items[0];
 
54
    BOOST_CHECK_EQUAL( first.name(), "kopete-otr");
 
55
    BOOST_CHECK_EQUAL( first.edition(), "0.6");
 
56
    BOOST_CHECK_EQUAL( first.repositoryUrl(), Url("http://download.opensuse.org/repositories/home:/burnickl_andreas/openSUSE_10.3"));
 
57
    BOOST_CHECK_EQUAL( first.distribution(), "openSUSE_103");
 
58
    BOOST_CHECK_EQUAL( first.checksum(), CheckSum::sha1("2a4d9e95f87abe16c28e4aefa0b3a0ae52220429"));
 
59
    BOOST_CHECK_EQUAL( first.priority(), 0);
 
60
    BOOST_CHECK_EQUAL( first.summary(), "OTR Plugin for Kopete");
 
61
}
 
62
 
 
63
 
 
64
// vim: set ts=2 sts=2 sw=2 ai et: