diff options
author | David Kalnischkies <kalnischkies@gmail.com> | 2009-11-26 22:23:08 +0100 |
---|---|---|
committer | David Kalnischkies <kalnischkies@gmail.com> | 2009-11-26 22:23:08 +0100 |
commit | 45df0ad2aab7d019cec855ba2cfe7ecdd0f8c7c8 (patch) | |
tree | f18787e135dcd7ea9444f93abc51c2a6516e2f7e /test | |
parent | 32e994d9c891ba379af7b292eeb81b4402d3f2af (diff) |
[BREAK] add possibility to download and use multiply
Translation files, configurable with Acquire::Languages
accessable with APT::Configuration::getLanguages() and
as always with documentation in apt.conf.
The commit also includes a very very simple testapp.
Diffstat (limited to 'test')
-rw-r--r-- | test/libapt/getlanguages_test.cc | 91 | ||||
-rw-r--r-- | test/libapt/makefile | 13 |
2 files changed, 104 insertions, 0 deletions
diff --git a/test/libapt/getlanguages_test.cc b/test/libapt/getlanguages_test.cc new file mode 100644 index 000000000..f3629df68 --- /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"); + assert(vec.size() == 2); + assert(vec[0] == "de"); + assert(vec[1] == "en"); + + // Special: Check if the cache is actually in use + vec = APT::Configuration::getLanguages(false, true, "en_GB.UTF-8"); + assert(vec.size() == 2); + assert(vec[0] == "de"); + assert(vec[1] == "en"); + + vec = APT::Configuration::getLanguages(false, false, "en_GB.UTF-8"); + assert(vec.size() == 2); + assert(vec[0] == "en_GB"); + assert(vec[1] == "en"); + + vec = APT::Configuration::getLanguages(false, false, "pt_PR.UTF-8"); + assert(vec.size() == 3); + assert(vec[0] == "pt_PR"); + assert(vec[1] == "pt"); + assert(vec[2] == "en"); + + vec = APT::Configuration::getLanguages(false, false, "ast_DE.UTF-8"); // bogus, but syntactical correct + assert(vec.size() == 2); + assert(vec[0] == "ast"); + assert(vec[1] == "en"); + + vec = APT::Configuration::getLanguages(false, false, "C"); + assert(vec.size() == 1); + assert(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"); + assert(vec.size() == 2); + assert(vec[0] == "de"); + assert(vec[1] == "en"); + + _config->Set("Acquire::Languages::3", "de"); + vec = APT::Configuration::getLanguages(false, false, "de_DE.UTF-8"); + assert(vec.size() == 2); + assert(vec[0] == "de"); + assert(vec[1] == "en"); + + _config->Set("Acquire::Languages::1", "none"); + vec = APT::Configuration::getLanguages(false, false, "de_DE.UTF-8"); + assert(vec.size() == 0); + vec = APT::Configuration::getLanguages(true, false, "de_DE.UTF-8"); + assert(vec[0] == "en"); + assert(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"); + assert(vec.size() == 1); + assert(vec[0] == "de_DE"); + + _config->Set("Acquire::Languages", "none"); + vec = APT::Configuration::getLanguages(true, false, "de_DE.UTF-8"); + assert(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"); + assert(vec.size() == 1); + assert(vec[0] == "ast_DE"); + _config->Set("APT::Acquire::Translation", "none"); + vec = APT::Configuration::getLanguages(true, false, "de_DE.UTF-8"); + assert(vec.size() == 0); + + return 0; +} diff --git a/test/libapt/makefile b/test/libapt/makefile new file mode 100644 index 000000000..f61a95f3d --- /dev/null +++ b/test/libapt/makefile @@ -0,0 +1,13 @@ +# -*- make -*- +BASE=../.. +SUBDIR=test/libapt +BASENAME=_libapt_test + +# Bring in the default rules +include ../../buildlib/defaults.mak + +# Program for testing getLanguageCode +PROGRAM = getLanguages${BASENAME} +SLIBS = -lapt-pkg +SOURCE = getlanguages_test.cc +include $(PROGRAM_H) |