]>
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
[])
20 env
[0] = "de_DE.UTF-8";
22 std::vector
<std::string
> vec
= APT::Configuration::getLanguages(false, false, env
);
23 equals(vec
.size(), 2);
27 // Special: Check if the cache is actually in use
28 env
[0] = "en_GB.UTF-8";
29 vec
= APT::Configuration::getLanguages(false, true, env
);
30 equals(vec
.size(), 2);
34 env
[0] = "en_GB.UTF-8";
35 vec
= APT::Configuration::getLanguages(false, false, env
);
36 equals(vec
.size(), 2);
37 equals(vec
[0], "en_GB");
40 env
[0] = "tr_DE@euro";
41 vec
= APT::Configuration::getLanguages(false, false, env
);
42 equals(vec
.size(), 2);
47 env
[1] = "se_NO:en_GB:nb_NO:nb:no_NO:no:nn_NO:nn:da:sv:en";
48 vec
= APT::Configuration::getLanguages(false, false, env
);
49 equals(vec
.size(), 5);
51 equals(vec
[1], "en_GB");
56 env
[0] = "pt_PR.UTF-8";
58 vec
= APT::Configuration::getLanguages(false, false, env
);
59 equals(vec
.size(), 3);
60 equals(vec
[0], "pt_PR");
64 env
[0] = "ast_DE.UTF-8";
65 vec
= APT::Configuration::getLanguages(false, false, env
); // bogus, but syntactical correct
66 equals(vec
.size(), 2);
67 equals(vec
[0], "ast");
71 vec
= APT::Configuration::getLanguages(false, false, env
);
72 equals(vec
.size(), 1);
75 _config
->Set("Acquire::Languages::1", "environment");
76 _config
->Set("Acquire::Languages::2", "en");
77 env
[0] = "de_DE.UTF-8";
78 vec
= APT::Configuration::getLanguages(false, false, env
);
79 equals(vec
.size(), 2);
83 _config
->Set("Acquire::Languages::3", "de");
84 env
[0] = "de_DE.UTF-8";
85 vec
= APT::Configuration::getLanguages(false, false, env
);
86 equals(vec
.size(), 2);
90 _config
->Set("Acquire::Languages::1", "none");
91 env
[0] = "de_DE.UTF-8";
92 vec
= APT::Configuration::getLanguages(false, false, env
);
93 equals(vec
.size(), 0);
94 env
[0] = "de_DE.UTF-8";
95 vec
= APT::Configuration::getLanguages(true, false, env
);
99 _config
->Set("Acquire::Languages::1", "fr");
100 _config
->Set("Acquire::Languages", "de_DE");
101 env
[0] = "de_DE.UTF-8";
102 vec
= APT::Configuration::getLanguages(false, false, env
);
103 equals(vec
.size(), 1);
104 equals(vec
[0], "de_DE");
106 _config
->Set("Acquire::Languages", "none");
107 env
[0] = "de_DE.UTF-8";
108 vec
= APT::Configuration::getLanguages(true, false, env
);
109 equals(vec
.size(), 0);
111 _config
->Set("Acquire::Languages", "");
112 //FIXME: Remove support for this deprecated setting
113 _config
->Set("APT::Acquire::Translation", "ast_DE");
114 env
[0] = "de_DE.UTF-8";
115 vec
= APT::Configuration::getLanguages(true, false, env
);
116 equals(vec
.size(), 1);
117 equals(vec
[0], "ast_DE");
118 _config
->Set("APT::Acquire::Translation", "none");
119 env
[0] = "de_DE.UTF-8";
120 vec
= APT::Configuration::getLanguages(true, false, env
);
121 equals(vec
.size(), 0);