LTP GCOV extension - code coverage report
Current view: directory - ept/apt - packagerecord.test.h
Test: lcov.info
Date: 2008-08-14 Instrumented lines: 52
Code covered: 88.5 % Executed lines: 46

       1                 : /*
       2                 :  * Copyright (C) 2007  Enrico Zini <enrico@enricozini.org>
       3                 :  *
       4                 :  * This library is free software; you can redistribute it and/or
       5                 :  * modify it under the terms of the GNU Lesser General Public
       6                 :  * License as published by the Free Software Foundation; either
       7                 :  * version 2.1 of the License, or (at your option) any later version.
       8                 :  *
       9                 :  * This library is distributed in the hope that it will be useful,
      10                 :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      11                 :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      12                 :  * Lesser General Public License for more details.
      13                 :  *
      14                 :  * You should have received a copy of the GNU Lesser General Public
      15                 :  * License along with this library; if not, write to the Free Software
      16                 :  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
      17                 :  */
      18                 : 
      19                 : #include <ept/test.h>
      20                 : #include <ept/apt/packagerecord.h>
      21                 : 
      22                 : namespace std {
      23               0 :     ostream& operator<<(ostream& out, const set<string>& s)
      24                 :         {
      25               0 :             for (set<string>::const_iterator i = s.begin();
      26                 :                  i != s.end(); ++i)
      27               0 :                 if (i == s.begin())
      28               0 :                     out << *i;
      29                 :                 else
      30               0 :                     out << ", " << *i;
      31               0 :             return out;
      32                 :         }
      33                 : }
      34                 : 
      35                 : using namespace std;
      36                 : using namespace ept;
      37                 : using namespace ept::apt;
      38                 : 
      39                 : struct TestAptPackagerecord {
      40                 : 
      41                 :     // Check that the supported fields are understood
      42               1 :     Test supportedFields()
      43                 :     {
      44                 :         string record =
      45                 :             "Package: apt\n"
      46                 :             "Priority: important\n"
      47                 :             "Section: admin\n"
      48                 :             "Installed-Size: 4368\n"
      49                 :             "Maintainer: APT Development Team <deity@lists.debian.org>\n"
      50                 :             "Architecture: amd64\n"
      51                 :             "Source: apt\n"
      52                 :             "Version: 0.6.46.4-0.1\n"
      53                 :             "Replaces: libapt-pkg-doc (<< 0.3.7), libapt-pkg-dev (<< 0.3.7)\n"
      54                 :             "Provides: libapt-pkg-libc6.3-6-3.11\n"
      55                 :             "Depends: libc6 (>= 2.3.5-1), libgcc1 (>= 1:4.1.1-12), libstdc++6 (>= 4.1.1-12), debian-archive-keyring\n"
      56                 :             "Pre-Depends: debtags (maybe)\n"
      57                 :             "Suggests: aptitude | synaptic | gnome-apt | wajig, dpkg-dev, apt-doc, bzip2\n"
      58                 :             "Recommends: debtags (maybe)\n"
      59                 :             "Enhances: debian\n"
      60                 :             "Conflicts: marameo\n"
      61                 :             "Filename: pool/main/a/apt/apt_0.6.46.4-0.1_amd64.deb\n"
      62                 :             "Size: 1436478\n"
      63                 :             "MD5sum: 1776421f80d6300c77a608e77a9f4a15\n"
      64                 :             "SHA1: 1bd7337d2df56d267632cf72ac930c0a4895898f\n"
      65                 :             "SHA256: b92442ab60046b4d0728245f39cc932f26e17db9f7933a5ec9aaa63172f51fda\n"
      66                 :             "Description: Advanced front-end for dpkg\n"
      67                 :             " This is Debian's next generation front-end for the dpkg package manager.\n"
      68                 :             " It provides the apt-get utility and APT dselect method that provides a\n"
      69                 :             " simpler, safer way to install and upgrade packages.\n"
      70                 :             " .\n"
      71                 :             " APT features complete installation ordering, multiple source capability\n"
      72                 :             " and several other unique features, see the Users Guide in apt-doc.\n"
      73                 :             "Build-Essential: yes\n"
      74               1 :             "Tag: admin::package-management, filetransfer::ftp, filetransfer::http, hardware::storage:cd, interface::commandline, network::client, protocol::{ftp,http,ipv6}, role::program, suite::debian, use::downloading, use::searching, works-with::software:package\n";
      75                 : 
      76               1 :         PackageRecord p(record);
      77                 : 
      78               1 :         assert_eq(p.size(), 24u);
      79                 : 
      80               2 :         assert_eq(p.package(), "apt");
      81               1 :         assert_eq(p.priority(), "important");
      82               1 :         assert_eq(p.section(), "admin");
      83               1 :         assert_eq(p.installedSize(), 4368u);
      84               2 :         assert_eq(p.maintainer(), "APT Development Team <deity@lists.debian.org>");
      85               1 :         assert_eq(p.architecture(), "amd64");
      86               1 :         assert_eq(p.source(), "apt");
      87               1 :         assert_eq(p.version(), "0.6.46.4-0.1");
      88               1 :         assert_eq(p.replaces(), "libapt-pkg-doc (<< 0.3.7), libapt-pkg-dev (<< 0.3.7)");
      89               1 :         assert_eq(p.provides(), "libapt-pkg-libc6.3-6-3.11");
      90               1 :         assert_eq(p.depends(), "libc6 (>= 2.3.5-1), libgcc1 (>= 1:4.1.1-12), libstdc++6 (>= 4.1.1-12), debian-archive-keyring");
      91               1 :         assert_eq(p.preDepends(), "debtags (maybe)");
      92               1 :         assert_eq(p.recommends(), "debtags (maybe)");
      93               1 :         assert_eq(p.suggests(), "aptitude | synaptic | gnome-apt | wajig, dpkg-dev, apt-doc, bzip2");
      94               1 :         assert_eq(p.enhances(), "debian");
      95               1 :         assert_eq(p.conflicts(), "marameo");
      96               1 :         assert_eq(p.filename(), "pool/main/a/apt/apt_0.6.46.4-0.1_amd64.deb");
      97               1 :         assert_eq(p.packageSize(), 1436478u);
      98               2 :         assert_eq(p.md5sum(), "1776421f80d6300c77a608e77a9f4a15");
      99               1 :         assert_eq(p.sha1(), "1bd7337d2df56d267632cf72ac930c0a4895898f");
     100               1 :         assert_eq(p.sha256(), "b92442ab60046b4d0728245f39cc932f26e17db9f7933a5ec9aaa63172f51fda");
     101                 :         assert_eq(p.description(), "Advanced front-end for dpkg\n"
     102                 :                       " This is Debian's next generation front-end for the dpkg package manager.\n"
     103                 :                       " It provides the apt-get utility and APT dselect method that provides a\n"
     104                 :                       " simpler, safer way to install and upgrade packages.\n"
     105                 :                       " .\n"
     106                 :                       " APT features complete installation ordering, multiple source capability\n"
     107               1 :                       " and several other unique features, see the Users Guide in apt-doc.");
     108               1 :         assert_eq(p.shortDescription(), "Advanced front-end for dpkg");
     109                 :         assert_eq(p.longDescription(),
     110                 :                       "This is Debian's next generation front-end for the dpkg package manager.\n"
     111                 :                       " It provides the apt-get utility and APT dselect method that provides a\n"
     112                 :                       " simpler, safer way to install and upgrade packages.\n"
     113                 :                       " .\n"
     114                 :                       " APT features complete installation ordering, multiple source capability\n"
     115               1 :                       " and several other unique features, see the Users Guide in apt-doc.");
     116               1 :         assert_eq(p.buildEssential(), true);
     117                 :         
     118               1 :         std::set<std::string> tags;
     119               1 :         tags.insert("admin::package-management");
     120               2 :         tags.insert("filetransfer::ftp");
     121               2 :         tags.insert("filetransfer::http");
     122               2 :         tags.insert("hardware::storage:cd");
     123               2 :         tags.insert("interface::commandline");
     124               2 :         tags.insert("network::client");
     125               2 :         tags.insert("protocol::ftp");
     126               2 :         tags.insert("protocol::http");
     127               2 :         tags.insert("protocol::ipv6");
     128               2 :         tags.insert("role::program");
     129               2 :         tags.insert("suite::debian");
     130               2 :         tags.insert("use::downloading");
     131               2 :         tags.insert("use::searching");
     132               2 :         tags.insert("works-with::software:package");
     133               2 :         assert_eq(p.tag(), tags);
     134               1 :     }
     135                 : 
     136                 : };
     137                 : 
     138                 : // vim:set ts=4 sw=4:

Generated by: LTP GCOV extension version 1.6