]>
git.saurik.com Git - apt.git/blob - test/libapt/getlanguages_test.cc
3 #include <apt-pkg/aptconfiguration.h>
4 #include <apt-pkg/configuration.h>
12 int main(int argc
,char *argv
[])
15 std::cout
<< "One parameter expected - given " << argc
<< std::endl
;
20 env
[0] = "de_DE.UTF-8";
23 std::vector
<std::string
> vec
= APT::Configuration::getLanguages(false, false, env
);
24 equals(vec
.size(), 3);
25 equals(vec
[0], "de_DE");
29 // Special: Check if the cache is actually in use
30 env
[0] = "en_GB.UTF-8";
31 vec
= APT::Configuration::getLanguages(false, true, env
);
32 equals(vec
.size(), 3);
33 equals(vec
[0], "de_DE");
37 env
[0] = "en_GB.UTF-8";
38 vec
= APT::Configuration::getLanguages(false, false, env
);
39 equals(vec
.size(), 2);
40 equals(vec
[0], "en_GB");
45 vec
= APT::Configuration::getLanguages(false, false, env
);
46 equals(vec
.size(), 2);
50 env
[0] = "tr_DE@euro";
51 vec
= APT::Configuration::getLanguages(false, false, env
);
52 equals(vec
.size(), 3);
53 equals(vec
[0], "tr_DE");
58 env
[1] = "de_NO:en_GB:nb_NO:nb:no_NO:no:nn_NO:nn:da:sv:en";
59 vec
= APT::Configuration::getLanguages(false, false, env
);
60 equals(vec
.size(), 6);
61 equals(vec
[0], "de_NO");
63 equals(vec
[2], "en_GB");
64 equals(vec
[3], "nb_NO");
68 env
[0] = "pt_PR.UTF-8";
70 vec
= APT::Configuration::getLanguages(false, false, env
);
71 equals(vec
.size(), 3);
72 equals(vec
[0], "pt_PR");
76 env
[0] = "ast_DE.UTF-8";
77 vec
= APT::Configuration::getLanguages(false, false, env
); // bogus, but syntactical correct
78 equals(vec
.size(), 3);
79 equals(vec
[0], "ast_DE");
80 equals(vec
[1], "ast");
84 vec
= APT::Configuration::getLanguages(false, false, env
);
85 equals(vec
.size(), 1);
88 _config
->Set("Acquire::Languages", "none");
90 vec
= APT::Configuration::getLanguages(false, false, env
);
91 equals(vec
.size(), 0);
93 _config
->Set("Acquire::Languages", "environment");
95 vec
= APT::Configuration::getLanguages(false, false, env
);
96 equals(vec
.size(), 1);
99 _config
->Set("Acquire::Languages", "de");
101 vec
= APT::Configuration::getLanguages(false, false, env
);
102 equals(vec
.size(), 1);
103 equals(vec
[0], "de");
105 _config
->Set("Acquire::Languages", "fr");
106 env
[0] = "ast_DE.UTF-8";
107 vec
= APT::Configuration::getLanguages(false, false, env
);
108 equals(vec
.size(), 1);
109 equals(vec
[0], "fr");
111 _config
->Set("Acquire::Languages", "environment,en");
112 env
[0] = "de_DE.UTF-8";
113 vec
= APT::Configuration::getLanguages(false, false, env
);
114 equals(vec
.size(), 3);
115 equals(vec
[0], "de_DE");
116 equals(vec
[1], "de");
117 equals(vec
[2], "en");
118 _config
->Set("Acquire::Languages", "");
120 _config
->Set("Acquire::Languages::1", "environment");
121 _config
->Set("Acquire::Languages::2", "en");
122 env
[0] = "de_DE.UTF-8";
123 vec
= APT::Configuration::getLanguages(false, false, env
);
124 equals(vec
.size(), 3);
125 equals(vec
[0], "de_DE");
126 equals(vec
[1], "de");
127 equals(vec
[2], "en");
129 _config
->Set("Acquire::Languages::3", "de");
130 env
[0] = "de_DE.UTF-8";
131 vec
= APT::Configuration::getLanguages(false, false, env
);
132 equals(vec
.size(), 3);
133 equals(vec
[0], "de_DE");
134 equals(vec
[1], "de");
135 equals(vec
[2], "en");
137 _config
->Set("Dir::State::lists", argv
[1]);
138 vec
= APT::Configuration::getLanguages(true, false, env
);
139 equals(vec
.size(), 8);
140 equals(vec
[0], "de_DE");
141 equals(vec
[1], "de");
142 equals(vec
[2], "en");
143 equals(vec
[3], "none");
144 equalsOr4(vec
[4], "pt", "tr", "ast_DE", "tlh_DE");
145 equalsOr4(vec
[5], "tr", "pt", "ast_DE", "tlh_DE");
146 equalsOr4(vec
[6], "tr", "pt", "ast_DE", "tlh_DE");
147 equalsOr4(vec
[7], "tr", "pt", "ast_DE", "tlh_DE");
148 equalsNot(vec
[4], vec
[5]);
149 equalsNot(vec
[4], vec
[6]);
150 equalsNot(vec
[4], vec
[7]);
151 equalsNot(vec
[5], vec
[6]);
152 equalsNot(vec
[5], vec
[7]);
153 equalsNot(vec
[6], vec
[7]);
155 _config
->Set("Acquire::Languages", "none");
156 vec
= APT::Configuration::getLanguages(true, false, env
);
157 equals(vec
.size(), 1);
158 equals(vec
[0], "none");
159 _config
->Set("Acquire::Languages", "");
161 _config
->Set("Dir::State::lists", "/non-existing-dir");
162 _config
->Set("Acquire::Languages::1", "none");
163 env
[0] = "de_DE.UTF-8";
164 vec
= APT::Configuration::getLanguages(false, false, env
);
165 equals(vec
.size(), 0);
166 env
[0] = "de_DE.UTF-8";
167 vec
= APT::Configuration::getLanguages(true, false, env
);
168 equals(vec
.size(), 2);
169 equals(vec
[0], "en");
170 equals(vec
[1], "de");
172 _config
->Set("Acquire::Languages::1", "fr");
173 _config
->Set("Acquire::Languages", "de_DE");
174 env
[0] = "de_DE.UTF-8";
175 vec
= APT::Configuration::getLanguages(false, false, env
);
176 equals(vec
.size(), 1);
177 equals(vec
[0], "de_DE");
179 _config
->Set("Acquire::Languages", "none");
180 env
[0] = "de_DE.UTF-8";
181 vec
= APT::Configuration::getLanguages(true, false, env
);
182 equals(vec
.size(), 1);
183 equals(vec
[0], "none");
185 _config
->Set("Acquire::Languages", "");
186 //FIXME: Remove support for this deprecated setting
187 _config
->Set("APT::Acquire::Translation", "ast_DE");
188 env
[0] = "de_DE.UTF-8";
189 vec
= APT::Configuration::getLanguages(true, false, env
);
190 equals(vec
.size(), 2);
191 equals(vec
[0], "ast_DE");
192 equals(vec
[1], "en");
193 _config
->Set("APT::Acquire::Translation", "none");
194 env
[0] = "de_DE.UTF-8";
195 vec
= APT::Configuration::getLanguages(true, false, env
);
196 equals(vec
.size(), 1);
197 equals(vec
[0], "en");