- move the callback from constructor to query()
[platform/upstream/libzypp.git] / tests / zypp / PoolQuery_test.cc
1 #include <stdio.h>
2 #include <iostream>
3 #include <boost/test/unit_test.hpp>
4 #include <boost/test/parameterized_test.hpp>
5 #include <boost/test/unit_test_log.hpp>
6
7 #include "zypp/ZYppFactory.h"
8 #include "zypp/PoolQuery.h"
9
10 using std::cout;
11 using std::endl;
12 using std::string;
13 using namespace zypp;
14 using namespace boost::unit_test;
15
16 bool result_cb( const ResObject::Ptr &r )
17 {
18   cout << r << endl;
19   return true;
20 }
21
22 void poolquery_simple_test()
23 {
24   Pathname dir(TESTS_SRC_DIR);
25   dir += "/zypp/data/PoolQuery";
26
27   ZYpp::Ptr z = getZYpp();
28     
29   sat::Pool::instance().addRepoSolv(dir + "foo.solv");
30
31   PoolQuery query;
32   //query.setInstalledOnly();
33   query.execute("kde", &result_cb);
34
35   cout << "search done." << endl;
36
37   query.setMatchExact(true);
38   query.execute("kde", &result_cb);
39   
40   cout << "search done." << endl;
41 }
42
43 test_suite*
44 init_unit_test_suite( int argc, char *argv[] )
45 {
46 //   if (argc < 2)
47 //   {
48 //     cout << "mediasetaccesstest:"
49 //       " path to directory with test data required as parameter" << endl;
50 //     return (test_suite *)0;
51 //   }
52
53   test_suite* test= BOOST_TEST_SUITE("PoolQuery_test");
54
55   // simple test
56   test->add(BOOST_TEST_CASE(&poolquery_simple_test));
57
58   return test;
59 }
60
61 // vim: set ts=2 sts=2 sw=2 ai et: