summaryrefslogtreecommitdiff
path: root/test/libapt/getlanguages_test.cc
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2010-02-18 15:07:56 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2010-02-18 15:07:56 +0100
commitb026dbb970c71213e12caaeb47bf7a27b91ea0a0 (patch)
tree68c68ff6bc12037ac74899f686fce9c0a3e419bd /test/libapt/getlanguages_test.cc
parent07f2526e45f9978201817237745727db6177c29a (diff)
parentd328fd1a20543192a7ea3eac124f10a5793743e9 (diff)
* [BREAK] add possibility to download and use multiply
Translation files, configurable with Acquire::Translation (Closes: #444222, #448216, #550564) * Ignore :qualifiers after package name in build dependencies for now as long we don't understand them (Closes: #558103) * apt-pkg/contrib/mmap.{cc,h}: - extend it to have a growable flag - unused now but maybe... * apt-pkg/pkgcache.h: - use long instead of short for {Ver,Desc}File size, patch from Víctor Manuel Jáquez Leal, thanks! (Closes: #538917) * apt-pkg/acquire-item.cc: - allow also to skip the last patch if target is reached, thanks Bernhard R. Link! (Closes: #545699) * ftparchive/writer.{cc,h}: - add APT::FTPArchive::AlwaysStat to disable the too aggressive caching if versions are build multiply times (not recommend) Patch by Christoph Goehre, thanks! (Closes: #463260)
Diffstat (limited to 'test/libapt/getlanguages_test.cc')
-rw-r--r--test/libapt/getlanguages_test.cc91
1 files changed, 91 insertions, 0 deletions
diff --git a/test/libapt/getlanguages_test.cc b/test/libapt/getlanguages_test.cc
new file mode 100644
index 000000000..fd3c8269f
--- /dev/null
+++ b/test/libapt/getlanguages_test.cc
@@ -0,0 +1,91 @@
+#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 = APT::Configuration::getLanguages(false, false, "de_DE.UTF-8");
+ equals(vec.size(), 2);
+ equals(vec[0], "de");
+ equals(vec[1], "en");
+
+ // Special: Check if the cache is actually in use
+ vec = APT::Configuration::getLanguages(false, true, "en_GB.UTF-8");
+ equals(vec.size(), 2);
+ equals(vec[0], "de");
+ equals(vec[1], "en");
+
+ vec = APT::Configuration::getLanguages(false, false, "en_GB.UTF-8");
+ equals(vec.size(), 2);
+ equals(vec[0], "en_GB");
+ equals(vec[1], "en");
+
+ vec = APT::Configuration::getLanguages(false, false, "pt_PR.UTF-8");
+ equals(vec.size(), 3);
+ equals(vec[0], "pt_PR");
+ equals(vec[1], "pt");
+ equals(vec[2], "en");
+
+ vec = APT::Configuration::getLanguages(false, false, "ast_DE.UTF-8"); // bogus, but syntactical correct
+ equals(vec.size(), 2);
+ equals(vec[0], "ast");
+ equals(vec[1], "en");
+
+ vec = APT::Configuration::getLanguages(false, false, "C");
+ equals(vec.size(), 1);
+ equals(vec[0], "en");
+
+ _config->Set("Acquire::Languages::1", "environment");
+ _config->Set("Acquire::Languages::2", "en");
+ vec = APT::Configuration::getLanguages(false, false, "de_DE.UTF-8");
+ equals(vec.size(), 2);
+ equals(vec[0], "de");
+ equals(vec[1], "en");
+
+ _config->Set("Acquire::Languages::3", "de");
+ vec = APT::Configuration::getLanguages(false, false, "de_DE.UTF-8");
+ equals(vec.size(), 2);
+ equals(vec[0], "de");
+ equals(vec[1], "en");
+
+ _config->Set("Acquire::Languages::1", "none");
+ vec = APT::Configuration::getLanguages(false, false, "de_DE.UTF-8");
+ equals(vec.size(), 0);
+ vec = APT::Configuration::getLanguages(true, false, "de_DE.UTF-8");
+ equals(vec[0], "en");
+ equals(vec[1], "de");
+
+ _config->Set("Acquire::Languages::1", "fr");
+ _config->Set("Acquire::Languages", "de_DE");
+ vec = APT::Configuration::getLanguages(false, false, "de_DE.UTF-8");
+ equals(vec.size(), 1);
+ equals(vec[0], "de_DE");
+
+ _config->Set("Acquire::Languages", "none");
+ vec = APT::Configuration::getLanguages(true, false, "de_DE.UTF-8");
+ equals(vec.size(), 0);
+
+ _config->Set("Acquire::Languages", "");
+ //FIXME: Remove support for this deprecated setting
+ _config->Set("APT::Acquire::Translation", "ast_DE");
+ vec = APT::Configuration::getLanguages(true, false, "de_DE.UTF-8");
+ equals(vec.size(), 1);
+ equals(vec[0], "ast_DE");
+ _config->Set("APT::Acquire::Translation", "none");
+ vec = APT::Configuration::getLanguages(true, false, "de_DE.UTF-8");
+ equals(vec.size(), 0);
+
+ return 0;
+}