summaryrefslogtreecommitdiff
path: root/test/libapt/getarchitectures_test.cc
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2010-07-29 16:18:10 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2010-07-29 16:18:10 +0200
commit15240f4b681ca35c669d2b2e6e34f8ee3f6c06d9 (patch)
tree4139050e3c2f00650a0d316c971c4e7b8aba3e58 /test/libapt/getarchitectures_test.cc
parent34904390bd6901f3de90249938baa0b875873534 (diff)
parent1b8ba3ba050f01db27f1ddc0e5b280b2fccd9fb9 (diff)
merged with the debian-experimental-ma branch
Diffstat (limited to 'test/libapt/getarchitectures_test.cc')
-rw-r--r--test/libapt/getarchitectures_test.cc61
1 files changed, 61 insertions, 0 deletions
diff --git a/test/libapt/getarchitectures_test.cc b/test/libapt/getarchitectures_test.cc
new file mode 100644
index 000000000..1500caeed
--- /dev/null
+++ b/test/libapt/getarchitectures_test.cc
@@ -0,0 +1,61 @@
+#include <apt-pkg/aptconfiguration.h>
+#include <apt-pkg/configuration.h>
+
+#include "assert.h"
+#include <string>
+#include <vector>
+
+#include <iostream>
+
+// simple helper to quickly output a vector of strings
+void dumpVector(std::vector<std::string> vec) {
+ for (std::vector<std::string>::const_iterator v = vec.begin();
+ v != vec.end(); v++)
+ std::cout << *v << std::endl;
+}
+
+int main(int argc,char *argv[])
+{
+ std::vector<std::string> vec;
+
+ _config->Set("APT::Architectures::1", "i386");
+ _config->Set("APT::Architectures::2", "amd64");
+ vec = APT::Configuration::getArchitectures(false);
+ equals(vec.size(), 2);
+ equals(vec[0], "i386");
+ equals(vec[1], "amd64");
+
+ _config->Set("APT::Architecture", "i386");
+ vec = APT::Configuration::getArchitectures(false);
+ equals(vec.size(), 2);
+ equals(vec[0], "i386");
+ equals(vec[1], "amd64");
+
+ _config->Set("APT::Architectures::2", "");
+ vec = APT::Configuration::getArchitectures(false);
+ equals(vec.size(), 1);
+ equals(vec[0], "i386");
+
+ _config->Set("APT::Architecture", "armel");
+ vec = APT::Configuration::getArchitectures(false);
+ equals(vec.size(), 2);
+ equals(vec[0], "i386");
+ equals(vec[1], "armel");
+
+ _config->Set("APT::Architectures::2", "amd64");
+ _config->Set("APT::Architectures::3", "i386");
+ _config->Set("APT::Architectures::4", "armel");
+ _config->Set("APT::Architectures::5", "i386");
+ _config->Set("APT::Architectures::6", "amd64");
+ _config->Set("APT::Architectures::7", "armel");
+ _config->Set("APT::Architectures::8", "armel");
+ _config->Set("APT::Architectures::9", "amd64");
+ _config->Set("APT::Architectures::10", "amd64");
+ vec = APT::Configuration::getArchitectures(false);
+ equals(vec.size(), 3);
+ equals(vec[0], "i386");
+ equals(vec[1], "amd64");
+ equals(vec[2], "armel");
+
+ return 0;
+}