]>
git.saurik.com Git - apt.git/blob - test/libapt/getlanguages_test.cc
1 #include <apt-pkg/aptconfiguration.h>
2 #include <apt-pkg/configuration.h>
10 // simple helper to quickly output a vector of strings
11 void dumpVector(std::vector
<std::string
> vec
) {
12 for (std::vector
<std::string
>::const_iterator v
= vec
.begin();
14 std::cout
<< *v
<< std::endl
;
17 int main(int argc
,char *argv
[])
19 std::vector
<std::string
> vec
= APT::Configuration::getLanguages(false, false, "de_DE.UTF-8");
20 equals(vec
.size(), 2);
24 // Special: Check if the cache is actually in use
25 vec
= APT::Configuration::getLanguages(false, true, "en_GB.UTF-8");
26 equals(vec
.size(), 2);
30 vec
= APT::Configuration::getLanguages(false, false, "en_GB.UTF-8");
31 equals(vec
.size(), 2);
32 equals(vec
[0], "en_GB");
35 vec
= APT::Configuration::getLanguages(false, false, "pt_PR.UTF-8");
36 equals(vec
.size(), 3);
37 equals(vec
[0], "pt_PR");
41 vec
= APT::Configuration::getLanguages(false, false, "ast_DE.UTF-8"); // bogus, but syntactical correct
42 equals(vec
.size(), 2);
43 equals(vec
[0], "ast");
46 vec
= APT::Configuration::getLanguages(false, false, "C");
47 equals(vec
.size(), 1);
50 _config
->Set("Acquire::Languages::1", "environment");
51 _config
->Set("Acquire::Languages::2", "en");
52 vec
= APT::Configuration::getLanguages(false, false, "de_DE.UTF-8");
53 equals(vec
.size(), 2);
57 _config
->Set("Acquire::Languages::3", "de");
58 vec
= APT::Configuration::getLanguages(false, false, "de_DE.UTF-8");
59 equals(vec
.size(), 2);
63 _config
->Set("Acquire::Languages::1", "none");
64 vec
= APT::Configuration::getLanguages(false, false, "de_DE.UTF-8");
65 equals(vec
.size(), 0);
66 vec
= APT::Configuration::getLanguages(true, false, "de_DE.UTF-8");
70 _config
->Set("Acquire::Languages::1", "fr");
71 _config
->Set("Acquire::Languages", "de_DE");
72 vec
= APT::Configuration::getLanguages(false, false, "de_DE.UTF-8");
73 equals(vec
.size(), 1);
74 equals(vec
[0], "de_DE");
76 _config
->Set("Acquire::Languages", "none");
77 vec
= APT::Configuration::getLanguages(true, false, "de_DE.UTF-8");
78 equals(vec
.size(), 0);
80 _config
->Set("Acquire::Languages", "");
81 //FIXME: Remove support for this deprecated setting
82 _config
->Set("APT::Acquire::Translation", "ast_DE");
83 vec
= APT::Configuration::getLanguages(true, false, "de_DE.UTF-8");
84 equals(vec
.size(), 1);
85 equals(vec
[0], "ast_DE");
86 _config
->Set("APT::Acquire::Translation", "none");
87 vec
= APT::Configuration::getLanguages(true, false, "de_DE.UTF-8");
88 equals(vec
.size(), 0);