- rework the testsuite after new boost in factory broke it.
[platform/upstream/libzypp.git] / tests / zypp / Capabilities_test.cc
1 // Capabilities.cc
2 //
3 // tests for Capabilities
4 //
5 #include <string>
6
7 // Boost.Test
8 #include <boost/test/floating_point_comparison.hpp>
9 #include <boost/test/unit_test.hpp>
10
11 #include "zypp/Capability.h"
12
13 using boost::unit_test::test_suite;
14 using boost::unit_test::test_case;
15 using boost::test_tools::close_at_tolerance;
16
17 using namespace std;
18 using namespace zypp;
19
20 BOOST_AUTO_TEST_CASE(capabilities_test)
21 {
22 //     Resolvable::Kind kind = ResTraits<zypp::Package>::kind;
23 //     CapFactory factory;
24 //
25 //     Edition edition ("1.0", "42");
26 //     Capability cap = factory.parse ( kind, "foo", "=", "1.0-42");
27 //     BOOST_CHECK_EQUAL( cap.asString(), "foo == 1.0-42" );
28 //     BOOST_CHECK_EQUAL( cap.index(), "foo");
29 //     BOOST_CHECK_EQUAL( cap.op(), Rel::EQ);
30 //     BOOST_CHECK_EQUAL( cap.edition(), edition);
31 //
32 //     Capability cap2 = factory.parse ( kind, "foo", Rel::EQ, edition);
33 //     BOOST_CHECK_EQUAL( cap2.index(), cap.index());
34 //     BOOST_CHECK_EQUAL( cap2.op(), cap.op());
35 //     BOOST_CHECK_EQUAL( cap2.edition(), cap.edition());
36 //
37 //     Capability cap3 = factory.parse ( kind, "foo = 1.0-42");
38 //     BOOST_CHECK_EQUAL( cap3.index(), cap.index());
39 //     BOOST_CHECK_EQUAL( cap3.op(), cap.op());
40 //     BOOST_CHECK_EQUAL( cap3.edition(), cap.edition());
41 //
42 //     Capability cap6 = factory.parse ( kind, "kdelibs* > 1.5");
43 //     BOOST_CHECK_EQUAL( cap6.index(), "kdelibs*");
44 //     BOOST_CHECK_EQUAL( cap6.op(), Rel::GT);
45 //     BOOST_CHECK_EQUAL( cap6.edition(), Edition("1.5"));
46 //
47 //
48 //     string bash = "/bin/bash";
49 //     Capability cap4 = factory.parse ( kind, bash);
50 //     BOOST_CHECK_EQUAL(cap4.index(), bash);
51 //     BOOST_CHECK_EQUAL(cap4.op(), Rel::NONE);
52 //     BOOST_CHECK_EQUAL(cap4.edition(), Edition::noedition);
53 //
54 //     string hal = "hal(smp)";
55 //     Capability cap5 = factory.parse ( kind, hal);
56 //     BOOST_CHECK_EQUAL(cap5.index(), "hal()");
57 //     BOOST_CHECK_EQUAL(cap5.op(), Rel::NONE);
58 //     BOOST_CHECK_EQUAL(cap5.edition(), Edition::noedition);
59
60   Capability c0( 0 ); // id 0
61   Capability c1( 1 ); // id 1
62   Capability cD;      // default constructed empty
63   Capability cE( "" );// empty
64
65   BOOST_CHECK_EQUAL( c0.id(), 0 );
66   BOOST_CHECK_EQUAL( c1.id(), 1 );
67   BOOST_CHECK_EQUAL( Capability().id(), 1 );   // default constructed empty
68   BOOST_CHECK_EQUAL( Capability("").id(), 1 ); // empty
69
70   BOOST_CHECK_EQUAL( c0.asString(), "" );
71   BOOST_CHECK_EQUAL( c1.asString(), "" );
72
73   BOOST_CHECK_EQUAL( c0.empty(), true );
74   BOOST_CHECK_EQUAL( c1.empty(), true );
75
76   BOOST_CHECK_EQUAL( c0.detail().kind(), CapDetail::NOCAP );
77   BOOST_CHECK_EQUAL( c1.detail().kind(), CapDetail::NOCAP );
78
79   BOOST_CHECK_EQUAL( ( c0 == c1 ), false );
80   BOOST_CHECK_EQUAL( Capability::matches( c0, c1 ), CapMatch::yes );
81 }
82