summaryrefslogtreecommitdiff
path: root/test/libapt/indexcopytosourcelist_test.cc
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2012-09-04 14:56:01 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2012-09-04 14:56:01 +0200
commit85909fca550d03b0e215d16cdd701190b43ff63c (patch)
treeb6767be7b1898830499b0a5fb8153460223b5649 /test/libapt/indexcopytosourcelist_test.cc
parentac5b5e826ab405935dc257c0a0984ae39b02bc23 (diff)
parent89e95aee05c7f2fde7eb11261df9697a4896b49b (diff)
merged sftp://bzr.debian.org/bzr/apt/apt/debian-sid
Diffstat (limited to 'test/libapt/indexcopytosourcelist_test.cc')
-rw-r--r--test/libapt/indexcopytosourcelist_test.cc86
1 files changed, 86 insertions, 0 deletions
diff --git a/test/libapt/indexcopytosourcelist_test.cc b/test/libapt/indexcopytosourcelist_test.cc
new file mode 100644
index 000000000..69d8fae86
--- /dev/null
+++ b/test/libapt/indexcopytosourcelist_test.cc
@@ -0,0 +1,86 @@
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/aptconfiguration.h>
+#include <apt-pkg/indexcopy.h>
+
+#include <string>
+
+#include "assert.h"
+
+class NoCopy : public IndexCopy {
+public:
+ std::string ConvertToSourceList(std::string CD,std::string Path) {
+ IndexCopy::ConvertToSourceList(CD, Path);
+ return Path;
+ }
+ bool GetFile(std::string &Filename,unsigned long long &Size) { return false; }
+ bool RewriteEntry(FILE *Target,std::string File) { return false; }
+ const char *GetFileName() { return NULL; }
+ const char *Type() { return NULL; }
+
+};
+
+int main(int argc, char const *argv[]) {
+ NoCopy ic;
+ std::string const CD("/media/cdrom/");
+
+ char const * Releases[] = { "unstable", "wheezy-updates", NULL };
+ char const * Components[] = { "main", "non-free", NULL };
+
+ for (char const ** Release = Releases; *Release != NULL; ++Release) {
+ for (char const ** Component = Components; *Component != NULL; ++Component) {
+ std::string const Path = std::string("dists/") + *Release + "/" + *Component + "/";
+ std::string const Binary = Path + "binary-";
+ std::string const A = Binary + "armel/";
+ std::string const B = Binary + "mips/";
+ std::string const C = Binary + "kfreebsd-mips/";
+ std::string const S = Path + "source/";
+ std::string const List = std::string(*Release) + " " + *Component;
+
+ _config->Clear("APT");
+ APT::Configuration::getArchitectures(false);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), A);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), B);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), C);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List);
+
+ _config->Clear("APT");
+ _config->Set("APT::Architecture", "mips");
+ _config->Set("APT::Architectures::", "mips");
+ APT::Configuration::getArchitectures(false);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), A);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), List);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), C);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List);
+
+ _config->Clear("APT");
+ _config->Set("APT::Architecture", "kfreebsd-mips");
+ _config->Set("APT::Architectures::", "kfreebsd-mips");
+ APT::Configuration::getArchitectures(false);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), A);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), B);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), List);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List);
+
+ _config->Clear("APT");
+ _config->Set("APT::Architecture", "armel");
+ _config->Set("APT::Architectures::", "armel");
+ APT::Configuration::getArchitectures(false);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), List);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), B);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), C);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List);
+
+ _config->Clear("APT");
+ _config->Set("APT::Architecture", "armel");
+ _config->Set("APT::Architectures::", "armel");
+ _config->Set("APT::Architectures::", "mips");
+ APT::Configuration::getArchitectures(false);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), List);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), List);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), C);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List);
+ }
+ }
+
+ return 0;
+}