libept
|
00001 /* 00002 * Copyright (C) 2007 Enrico Zini <enrico@enricozini.org> 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2.1 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with this library; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 */ 00018 00019 #include <ept/test.h> 00020 #include <ept/apt/packagerecord.h> 00021 00022 namespace std { 00023 ostream& operator<<(ostream& out, const set<string>& s) 00024 { 00025 for (set<string>::const_iterator i = s.begin(); 00026 i != s.end(); ++i) 00027 if (i == s.begin()) 00028 out << *i; 00029 else 00030 out << ", " << *i; 00031 return out; 00032 } 00033 } 00034 00035 using namespace std; 00036 using namespace ept; 00037 using namespace ept::apt; 00038 00039 struct TestAptPackagerecord { 00040 00041 // Check that the supported fields are understood 00042 Test supportedFields() 00043 { 00044 string record = 00045 "Package: apt\n" 00046 "Priority: important\n" 00047 "Section: admin\n" 00048 "Installed-Size: 4368\n" 00049 "Maintainer: APT Development Team <deity@lists.debian.org>\n" 00050 "Architecture: amd64\n" 00051 "Source: apt\n" 00052 "Version: 0.6.46.4-0.1\n" 00053 "Replaces: libapt-pkg-doc (<< 0.3.7), libapt-pkg-dev (<< 0.3.7)\n" 00054 "Provides: libapt-pkg-libc6.3-6-3.11\n" 00055 "Depends: libc6 (>= 2.3.5-1), libgcc1 (>= 1:4.1.1-12), libstdc++6 (>= 4.1.1-12), debian-archive-keyring\n" 00056 "Pre-Depends: debtags (maybe)\n" 00057 "Suggests: aptitude | synaptic | gnome-apt | wajig, dpkg-dev, apt-doc, bzip2\n" 00058 "Recommends: debtags (maybe)\n" 00059 "Enhances: debian\n" 00060 "Conflicts: marameo\n" 00061 "Filename: pool/main/a/apt/apt_0.6.46.4-0.1_amd64.deb\n" 00062 "Size: 1436478\n" 00063 "MD5sum: 1776421f80d6300c77a608e77a9f4a15\n" 00064 "SHA1: 1bd7337d2df56d267632cf72ac930c0a4895898f\n" 00065 "SHA256: b92442ab60046b4d0728245f39cc932f26e17db9f7933a5ec9aaa63172f51fda\n" 00066 "Description: Advanced front-end for dpkg\n" 00067 " This is Debian's next generation front-end for the dpkg package manager.\n" 00068 " It provides the apt-get utility and APT dselect method that provides a\n" 00069 " simpler, safer way to install and upgrade packages.\n" 00070 " .\n" 00071 " APT features complete installation ordering, multiple source capability\n" 00072 " and several other unique features, see the Users Guide in apt-doc.\n" 00073 "Build-Essential: yes\n" 00074 "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"; 00075 00076 PackageRecord p(record); 00077 00078 assert_eq(p.size(), 24u); 00079 00080 assert_eq(p.package(), "apt"); 00081 assert_eq(p.priority(), "important"); 00082 assert_eq(p.section(), "admin"); 00083 assert_eq(p.installedSize(), 4368u); 00084 assert_eq(p.maintainer(), "APT Development Team <deity@lists.debian.org>"); 00085 assert_eq(p.architecture(), "amd64"); 00086 assert_eq(p.source(), "apt"); 00087 assert_eq(p.version(), "0.6.46.4-0.1"); 00088 assert_eq(p.replaces(), "libapt-pkg-doc (<< 0.3.7), libapt-pkg-dev (<< 0.3.7)"); 00089 assert_eq(p.provides(), "libapt-pkg-libc6.3-6-3.11"); 00090 assert_eq(p.depends(), "libc6 (>= 2.3.5-1), libgcc1 (>= 1:4.1.1-12), libstdc++6 (>= 4.1.1-12), debian-archive-keyring"); 00091 assert_eq(p.preDepends(), "debtags (maybe)"); 00092 assert_eq(p.recommends(), "debtags (maybe)"); 00093 assert_eq(p.suggests(), "aptitude | synaptic | gnome-apt | wajig, dpkg-dev, apt-doc, bzip2"); 00094 assert_eq(p.enhances(), "debian"); 00095 assert_eq(p.conflicts(), "marameo"); 00096 assert_eq(p.filename(), "pool/main/a/apt/apt_0.6.46.4-0.1_amd64.deb"); 00097 assert_eq(p.packageSize(), 1436478u); 00098 assert_eq(p.md5sum(), "1776421f80d6300c77a608e77a9f4a15"); 00099 assert_eq(p.sha1(), "1bd7337d2df56d267632cf72ac930c0a4895898f"); 00100 assert_eq(p.sha256(), "b92442ab60046b4d0728245f39cc932f26e17db9f7933a5ec9aaa63172f51fda"); 00101 assert_eq(p.description(), "Advanced front-end for dpkg\n" 00102 " This is Debian's next generation front-end for the dpkg package manager.\n" 00103 " It provides the apt-get utility and APT dselect method that provides a\n" 00104 " simpler, safer way to install and upgrade packages.\n" 00105 " .\n" 00106 " APT features complete installation ordering, multiple source capability\n" 00107 " and several other unique features, see the Users Guide in apt-doc."); 00108 assert_eq(p.shortDescription(), "Advanced front-end for dpkg"); 00109 assert_eq(p.longDescription(), 00110 "This is Debian's next generation front-end for the dpkg package manager.\n" 00111 " It provides the apt-get utility and APT dselect method that provides a\n" 00112 " simpler, safer way to install and upgrade packages.\n" 00113 " .\n" 00114 " APT features complete installation ordering, multiple source capability\n" 00115 " and several other unique features, see the Users Guide in apt-doc."); 00116 assert_eq(p.buildEssential(), true); 00117 00118 std::set<std::string> tags; 00119 tags.insert("admin::package-management"); 00120 tags.insert("filetransfer::ftp"); 00121 tags.insert("filetransfer::http"); 00122 tags.insert("hardware::storage:cd"); 00123 tags.insert("interface::commandline"); 00124 tags.insert("network::client"); 00125 tags.insert("protocol::ftp"); 00126 tags.insert("protocol::http"); 00127 tags.insert("protocol::ipv6"); 00128 tags.insert("role::program"); 00129 tags.insert("suite::debian"); 00130 tags.insert("use::downloading"); 00131 tags.insert("use::searching"); 00132 tags.insert("works-with::software:package"); 00133 assert_eq(p.tag(), tags); 00134 } 00135 00136 }; 00137 00138 // vim:set ts=4 sw=4: