backup
[platform/upstream/libzypp.git] / tests / sat / LookupAttr_test.cc
1 #include "TestSetup.h"
2 #include <zypp/sat/LookupAttr.h>
3
4 #define LABELED(V) #V << ":\t" << V
5
6 static TestSetup test( "/tmp/x", Arch_x86_64 );
7
8 // Must be the first test!
9 BOOST_AUTO_TEST_CASE(bnc_435838)
10 {
11   // On the fly check that findSystemRepo does not
12   // cause loading the SystemRepo. check 2 times.
13   BOOST_REQUIRE( ! test.satpool().findSystemRepo() );
14   BOOST_REQUIRE( ! test.satpool().findSystemRepo() );
15
16   // empty @system to pool
17   test.satpool().systemRepo();
18   BOOST_REQUIRE( test.satpool().findSystemRepo() );
19
20   // bnc_435838 crashes if iterating a just created repo.
21   sat::LookupAttr q( sat::SolvAttr::name );
22   for_( it, q.begin(),q.end() )
23     ;
24 }
25
26 BOOST_AUTO_TEST_CASE(LookupAttr_init)
27 {
28   test.loadTarget(); // initialize and load target
29   test.loadRepo( TESTS_SRC_DIR "/data/openSUSE-11.1" );
30   test.loadRepo( TESTS_SRC_DIR "/data/OBS:VirtualBox-11.1" );
31   test.loadRepo( TESTS_SRC_DIR "/data/11.0-update" );
32 }
33
34 BOOST_AUTO_TEST_CASE(LookupAttr_defaultconstructed)
35 {
36   sat::LookupAttr q;
37   BOOST_CHECK( q.empty() );
38   BOOST_CHECK( q.size() == 0 );
39   BOOST_CHECK_EQUAL( q.begin(), q.end() );
40 }
41
42 BOOST_AUTO_TEST_CASE(LookupAttr_nonexistingattr)
43 {
44   sat::LookupAttr q( sat::SolvAttr("nonexistingattr") );
45   BOOST_CHECK( q.empty() );
46   BOOST_CHECK( q.size() == 0 );
47   BOOST_CHECK_EQUAL( q.begin(), q.end() );
48 }
49
50 BOOST_AUTO_TEST_CASE(LookupAttr_existingattr)
51 {
52   sat::LookupAttr q( sat::SolvAttr::name );
53   BOOST_CHECK( ! q.empty() );
54   BOOST_CHECK( q.size() != 0 );
55   BOOST_CHECK_NE( q.begin(), q.end() );
56 }
57
58 BOOST_AUTO_TEST_CASE(LookupAttr_)
59 {
60   base::LogControl::TmpLineWriter shutUp( new log::FileLineWriter( "/tmp/YLOG" ) );
61   MIL << "GO" << endl;
62
63   sat::Pool satpool( test.satpool() );
64   for_( it, satpool.reposBegin(), satpool.reposEnd() )
65   {
66     SEC << endl;
67     sat::LookupAttr q( sat::SolvAttr::name, *it );
68     BOOST_CHECK_EQUAL( q.size(), it->solvablesSize() );
69     MIL << q << ' ' << q.size() << " in " << *it << endl;
70     DBG << q << endl;
71   }
72   return;
73   sat::LookupAttr q( sat::SolvAttr::name );
74   BOOST_CHECK_EQUAL( q.size(), satpool.solvablesSize() );
75   MIL << q << ' ' << q.size() << " in ALL" << endl;
76 }