LCOV - lcov.info - ept/debtags/maint/pkgid.test.h

LTP GCOV extension - code coverage report
Current view: | directory - ept/debtags/maint - pkgid.test.h
Test: | lcov.info
Date: | 2008-08-14 |  | Instrumented lines: | 18
Code covered: | 100.0 % |  | Executed lines: | 18

           1                 : // -*- mode: c++; tab-width: 4; indent-tabs-mode: t -*-
           2                 : /*
           3                 :  * id->package mapping
           4                 :  *
           5                 :  * Copyright (C) 2006  Enrico Zini <enrico@debian.org>
           6                 :  *
           7                 :  * This program is free software; you can redistribute it and/or modify
           8                 :  * it under the terms of the GNU General Public License as published by
           9                 :  * the Free Software Foundation; either version 2 of the License, or
          10                 :  * (at your option) any later version.
          11                 :  *
          12                 :  * This program is distributed in the hope that it will be useful,
          13                 :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
          14                 :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
          15                 :  * GNU General Public License for more details.
          16                 :  *
          17                 :  * You should have received a copy of the GNU General Public License
          18                 :  * along with this program; if not, write to the Free Software
          19                 :  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
          20                 :  */
          21                 :
          22                 : #include <ept/debtags/maint/pkgid.h>
          23                 : #include <ept/debtags/maint/path.h>
          24                 : #include <ept/debtags/debtags.h>
          25                 : #include <set>
          26                 :
          27                 : #include <ept/test.h>
          28                 :
          29                 : using namespace std;
          30                 : using namespace ept;
          31                 : using namespace ept::debtags;
          32                 :
          33                 : struct TestPkgid : DebtagsTestEnvironment
          34               2 : {
          35                 :         Debtags debtags;
          36                 :         PkgId& pkgid;
          37                 :
          38               2 :         TestPkgid()
          39               2 :                 : pkgid(debtags.pkgid())
          40                 :         {
          41               2 :         }
          42                 :
          43                 : // Check that we can go from name to ID and back
          44               1 :         Test _1()
          45                 : {
          46                 :         //int x = 0;
          47           21146 :         for (Debtags::const_iterator i = debtags.begin();
          48                 :                         i != debtags.end(); ++i)
          49                 :         {
          50           21145 :                 int id = pkgid.byName(i->first);
          51           21145 :                 std::string pkg = pkgid.byID(id);
          52           21145 :                 assert(i->first == pkg);
          53                 :
          54                 :                 /* std::cerr << x << ": " << i->id() << ": "
          55                 :                                   << i->name() << ", " << pkgidx().name( i->id() ) <<
          56                 :                                   std::endl; */
          57                 :                 //++ x;
          58               1 :         }
          59               1 : }
          60                 :
          61                 : // Check that IDs are distinct
          62               1 :         Test _2()
          63                 : {
          64                 :         using namespace std;
          65                 :
          66               1 :         size_t count = 0;
          67               1 :         set<int> ids;
          68           21146 :         for (Debtags::const_iterator i = debtags.begin(); i != debtags.end(); ++i, ++count)
          69           21146 :                 ids.insert(pkgid.byName(i->first));
          70               1 :         assert_eq(ids.size(), count);
          71               1 : }
          72                 :
          73                 : };
          74                 :
          75                 : // vim:set ts=4 sw=4:

Generated by: LTP GCOV extension version 1.6