--- /dev/null
+#include "TestSetup.h"
+#include <zypp/sat/LookupAttr.h>
+
+BOOST_AUTO_TEST_CASE(idstring)
+{
+ // id 0 ==> NULL
+ // id 1 ==> ""
+ // evaluates id in a boolean context
+ IdString a0( 0 );
+ IdString a1( 1 );
+
+ BOOST_CHECK_EQUAL( a0.id(), 0 );
+ BOOST_CHECK_EQUAL( a1.id(), 1 );
+
+ BOOST_CHECK( !a0 );
+ BOOST_CHECK( a1 );
+
+ BOOST_CHECK( !(a0 == a1) );
+ BOOST_CHECK( (a0 != a1) );
+ BOOST_CHECK( (a0 < a1) );
+ BOOST_CHECK( (a1 > a0) );
+ BOOST_CHECK( !(a0 >= a1) );
+ BOOST_CHECK( !(a1 <= a0) );
+
+ BOOST_CHECK_EQUAL( a0.compare( (const char *)0 ), 0 );
+ BOOST_CHECK_EQUAL( a0.compare( "" ), -1 );
+ BOOST_CHECK_EQUAL( a0.compare( a1 ), -1 );
+
+ BOOST_CHECK_EQUAL( a1.compare( (const char *)0 ), 1 );
+ BOOST_CHECK_EQUAL( a1.compare( "" ), 0 );
+ BOOST_CHECK_EQUAL( a1.compare( a0 ), 1 );
+}
+
+BOOST_AUTO_TEST_CASE(idstringtype)
+{
+ sat::SolvAttr a0( sat::SolvAttr::allAttr );
+ sat::SolvAttr a1( sat::SolvAttr::noAttr );
+
+ BOOST_CHECK_EQUAL( a0.id(), 0 );
+ BOOST_CHECK_EQUAL( a1.id(), 1 );
+
+ BOOST_CHECK( !a0 );
+ BOOST_CHECK( !a1 ); // evaluates empty string (id 0/1) in a boolean context
+
+ BOOST_CHECK( !(a0 == a1) );
+ BOOST_CHECK( (a0 != a1) );
+ BOOST_CHECK( (a0 < a1) );
+ BOOST_CHECK( (a1 > a0) );
+ BOOST_CHECK( !(a0 >= a1) );
+ BOOST_CHECK( !(a1 <= a0) );
+
+ BOOST_CHECK_EQUAL( a0.compare( (const char *)0 ), 0 );
+ BOOST_CHECK_EQUAL( a0.compare( "" ), -1 );
+ BOOST_CHECK_EQUAL( a0.compare( a1 ), -1 );
+
+ BOOST_CHECK_EQUAL( a1.compare( (const char *)0 ), 1 );
+ BOOST_CHECK_EQUAL( a1.compare( "" ), 0 );
+ BOOST_CHECK_EQUAL( a1.compare( a0 ), 1 );
+}
cout << (it->edition() == "4.21.3-2") << endl; // fine
cout << (it->edition() == Edition("4.21.3-2")) << endl; // fine
- cout << (it->edition().match(Edition("4.21.3-2")) == 0) << endl; // !match returns -1,0,1
- cout << (it->edition().match("4.21.3-2") == 0) << endl; // !match returns -1,0,1
+ cout << (it->edition().match(Edition("4.21.3-2")) == 0) << endl; // match returns -1,0,1
+ cout << (it->edition().match("4.21.3-2") == 0) << endl; // match returns -1,0,1
}
-
- //! \todo FIXME Edition("0:4.21.3-2") != Edition("4.21.3-2") (not even does Edition("0:4.21.3-2").match(Edition("4.21.3-2"))
}
BOOST_CHECK_EQUAL(_ed1, Edition ("1", ""));
BOOST_CHECK_EQUAL(_ed2, Edition ("1.1", ""));
+ BOOST_CHECK_EQUAL(_ed2, Edition ("1_1", "")); // Edition strings may differ in separator (non alphanum)
+ BOOST_CHECK_EQUAL(_ed2, Edition ("0:1.1")); // epoch 0 is no epoch
BOOST_CHECK_EQUAL(_ed3, Edition ("1", "", "1"));
BOOST_CHECK_EQUAL(_ed3, Edition ("1", "", 1));
BOOST_CHECK_EQUAL(_ed4, Edition ("1", "1", 2));