X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=tests%2Fparser%2Fyum%2FRepomdFileReader_test.cc;h=1faff438a6a7e66a85989baf2e4046764a6f4f51;hb=d58a5d90878551ca9fde5de55c8a026453ac32ca;hp=0d46005c07ebb1edde7c2e1a141203a4ff9e0a12;hpb=be55b907da8b179dbdad2740a468162cd3c7d665;p=platform%2Fupstream%2Flibzypp.git diff --git a/tests/parser/yum/RepomdFileReader_test.cc b/tests/parser/yum/RepomdFileReader_test.cc index 0d46005..1faff43 100644 --- a/tests/parser/yum/RepomdFileReader_test.cc +++ b/tests/parser/yum/RepomdFileReader_test.cc @@ -14,7 +14,6 @@ using namespace zypp; using namespace boost::unit_test; using namespace zypp::parser::yum; -using repo::yum::ResourceType; #define DATADIR (Pathname(TESTS_SRC_DIR) + "parser/yum/data") @@ -23,17 +22,14 @@ class Collector public: Collector() {} - - bool callback( const OnMediaLocation &loc, const ResourceType &t ) + + bool operator()( OnMediaLocation &&loc, const std::string &t ) { - items.push_back( make_pair( t, loc ) ); - //items.push_back(loc); - //cout << items.size() << endl; + items.push_back( make_pair( t, std::move(loc) ) ); return true; } - vector > items; - //vector items; + vector > items; }; BOOST_AUTO_TEST_CASE(repomd_read) @@ -48,28 +44,32 @@ BOOST_AUTO_TEST_CASE(repomd_read) if ( ( file.basename().substr(0, 6) == "repomd" ) && (file.extension() == ".xml" ) ) { cout << *it << endl; - + Collector collect; - RepomdFileReader( file, RepomdFileReader::ProcessResource(bind( &Collector::callback, &collect, _1, _2 )) ); - + RepomdFileReader( file, std::ref(collect) ); + std::ifstream ifs( file.extend(".solution").asString().c_str() ); - + unsigned int count = 0; - while ( ifs && ! ifs.eof() && count < collect.items.size() ) + while ( ifs && !ifs.eof() ) { string dtype; + getline(ifs, dtype); + if ( dtype.empty() ) + break; + BOOST_REQUIRE( count < collect.items.size() ); + BOOST_CHECK_EQUAL( collect.items[count].first, dtype ); + string checksum_type; string checksum; - string loc; - - getline(ifs, dtype); - BOOST_CHECK_EQUAL( collect.items[count].first, ResourceType(dtype)); getline(ifs, checksum_type); getline(ifs, checksum); BOOST_CHECK_EQUAL( collect.items[count].second.checksum(), CheckSum(checksum_type, checksum) ); + + string loc; getline(ifs, loc); BOOST_CHECK_EQUAL( collect.items[count].second.filename(), Pathname(loc) ); - + count++; } BOOST_CHECK_EQUAL( collect.items.size(), count );