libept  0.5.25
pkgid.test.h
Go to the documentation of this file.
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 
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 
34 {
37 
39  : pkgid(debtags.pkgid())
40  {
41  }
42 
43 // Check that we can go from name to ID and back
44  Test _1()
45 {
46  //int x = 0;
47  for (Debtags::const_iterator i = debtags.begin();
48  i != debtags.end(); ++i)
49  {
50  int id = pkgid.byName(i->first);
51  std::string pkg = pkgid.byID(id);
52  assert(i->first == pkg);
53 
54  /* std::cerr << x << ": " << i->id() << ": "
55  << i->name() << ", " << pkgidx().name( i->id() ) <<
56  std::endl; */
57  //++ x;
58  }
59 }
60 
61 // Check that IDs are distinct
62  Test _2()
63 {
64  using namespace std;
65 
66  size_t count = 0;
67  set<int> ids;
68  for (Debtags::const_iterator i = debtags.begin(); i != debtags.end(); ++i, ++count)
69  ids.insert(pkgid.byName(i->first));
70  assert_eq(ids.size(), count);
71 }
72 
73 };
74 
75 // vim:set ts=4 sw=4: