From: Duncan Mac-Vicar P Date: Fri, 30 Jun 2006 13:51:26 +0000 (+0000) Subject: - PublicKey testcase to boost X-Git-Tag: BASE-SuSE-SLE-10-SP2-Branch~563 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=342832eaebcc3add523f09224999a1d6993244e2;p=platform%2Fupstream%2Flibzypp.git - PublicKey testcase to boost --- diff --git a/devel/devel.dmacvicar/publickey.cc b/devel/devel.dmacvicar/publickey.cc new file mode 100644 index 0000000..0a8a880 --- /dev/null +++ b/devel/devel.dmacvicar/publickey.cc @@ -0,0 +1,55 @@ +#include +#include +#include +#include + +#include "boost/filesystem/operations.hpp" // includes boost/filesystem/path.hpp +#include "boost/filesystem/fstream.hpp" // ditto + +#include + +#include +#include +#include +#include +#include +/////////////////////////////////////////////////////////////////// + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +using namespace zypp::detail; + +using namespace std; +using namespace zypp; +using namespace zypp::parser::yum; +using namespace zypp::source::yum; + + + +//using namespace DbXml; + +int main() +{ + zypp::devel::PublicKey k("/suse/dmacvicar/duncan.txt"); + + cout << k.id() << std::endl; + cout << k.fingerprint() << std::endl; + cout << k.name() << std::endl; + +} + + diff --git a/testsuite/zypp/tests/Makefile.am b/testsuite/zypp/tests/Makefile.am index 4425954..9c2b544 100644 --- a/testsuite/zypp/tests/Makefile.am +++ b/testsuite/zypp/tests/Makefile.am @@ -13,7 +13,8 @@ noinst_PROGRAMS = Arch Url1 Url2 Url3 Url4 Url5 Url \ Capabilities \ PtrTypes \ TranslatedText \ - CheckSum + CheckSum \ + PublicKey ## ################################################## diff --git a/testsuite/zypp/tests/PublicKey.cc b/testsuite/zypp/tests/PublicKey.cc index ec16368..79dc874 100644 --- a/testsuite/zypp/tests/PublicKey.cc +++ b/testsuite/zypp/tests/PublicKey.cc @@ -8,34 +8,38 @@ #include "zypp/PublicKey.h" #include "zypp/ZYppFactory.h" #include "zypp/ZYpp.h" -#include "testsuite/src/utils/TestUtils.h" + +#include + +using boost::unit_test::test_suite; +using boost::unit_test::test_case; using namespace std; using namespace zypp; -using namespace zypp::testsuite::utils; -int main( int argc, char * argv[] ) +void publickey_test() { - try - { - zypp::devel::PublicKey k1("publickey-1.asc"); + BOOST_CHECK_THROW( zypp::devel::PublicKey("nonexistant"), Exception ); - assert_equal( k1.id(), "CD1EB6A9667E42D1"); - assert_equal( k1.name(), "Duncan Mac-Vicar Prett " ); - assert_equal( k1.fingerprint(), "75DA7B971FD6ADB9A880BA9FCD1EB6A9667E42D1" ); + zypp::devel::PublicKey k1("publickey-1.asc"); - zypp::devel::PublicKey k2("publickey-suse.asc"); + BOOST_CHECK_EQUAL( k1.id(), "CD1EB6A9667E42D1"); + BOOST_CHECK_EQUAL( k1.name(), "Duncan Mac-Vicar Prett " ); + BOOST_CHECK_EQUAL( k1.fingerprint(), "75DA7B971FD6ADB9A880BA9FCD1EB6A9667E42D1" ); - assert_equal( k2.id(), "A84EDAE89C800ACA" ); - assert_equal( k2.name(), "SuSE Package Signing Key " ); - assert_equal( k2.fingerprint(), "79C179B2E1C820C1890F9994A84EDAE89C800ACA" ); - - return 0; - } - catch(const Exception &e) - { - return 40; - } + zypp::devel::PublicKey k2("publickey-suse.asc"); - return 0; + BOOST_CHECK_EQUAL( k2.id(), "A84EDAE89C800ACA" ); + BOOST_CHECK_EQUAL( k2.name(), "SuSE Package Signing Key " ); + BOOST_CHECK_EQUAL( k2.fingerprint(), "79C179B2E1C820C1890F9994A84EDAE89C800ACA" ); + } + +test_suite* +init_unit_test_suite( int, char* [] ) +{ + test_suite* test= BOOST_TEST_SUITE( "PublicKeyTest" ); + test->add( BOOST_TEST_CASE( &publickey_test ), 0 /* expected zero error */ ); + return test; +} +