]>
git.saurik.com Git - apt.git/blob - test/libapt/getlanguages_test.cc
274cf4aa400c95662e5fc621f37f4b77c4969a69
1 #include <apt-pkg/aptconfiguration.h>
2 #include <apt-pkg/configuration.h>
10 int main(int argc
,char *argv
[])
13 std::cout
<< "One parameter expected - given " << argc
<< std::endl
;
18 env
[0] = "de_DE.UTF-8";
21 std::vector
<std::string
> vec
= APT::Configuration::getLanguages(false, false, env
);
22 equals(vec
.size(), 3);
23 equals(vec
[0], "de_DE");
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(), 3);
31 equals(vec
[0], "de_DE");
35 env
[0] = "en_GB.UTF-8";
36 vec
= APT::Configuration::getLanguages(false, false, env
);
37 equals(vec
.size(), 2);
38 equals(vec
[0], "en_GB");
43 vec
= APT::Configuration::getLanguages(false, false, env
);
44 equals(vec
.size(), 2);
48 env
[0] = "tr_DE@euro";
49 vec
= APT::Configuration::getLanguages(false, false, env
);
50 equals(vec
.size(), 3);
51 equals(vec
[0], "tr_DE");
56 env
[1] = "de_NO:en_GB:nb_NO:nb:no_NO:no:nn_NO:nn:da:sv:en";
57 vec
= APT::Configuration::getLanguages(false, false, env
);
58 equals(vec
.size(), 6);
59 equals(vec
[0], "de_NO");
61 equals(vec
[2], "en_GB");
62 equals(vec
[3], "nb_NO");
66 env
[0] = "pt_PR.UTF-8";
68 vec
= APT::Configuration::getLanguages(false, false, env
);
69 equals(vec
.size(), 3);
70 equals(vec
[0], "pt_PR");
74 env
[0] = "ast_DE.UTF-8";
75 vec
= APT::Configuration::getLanguages(false, false, env
); // bogus, but syntactical correct
76 equals(vec
.size(), 3);
77 equals(vec
[0], "ast_DE");
78 equals(vec
[1], "ast");
82 vec
= APT::Configuration::getLanguages(false, false, env
);
83 equals(vec
.size(), 1);
86 _config
->Set("Acquire::Languages", "none");
88 vec
= APT::Configuration::getLanguages(false, false, env
);
89 equals(vec
.size(), 0);
91 _config
->Set("Acquire::Languages", "environment");
93 vec
= APT::Configuration::getLanguages(false, false, env
);
94 equals(vec
.size(), 1);
97 _config
->Set("Acquire::Languages", "de");
99 vec
= APT::Configuration::getLanguages(false, false, env
);
100 equals(vec
.size(), 1);
101 equals(vec
[0], "de");
103 _config
->Set("Acquire::Languages", "fr");
104 env
[0] = "ast_DE.UTF-8";
105 vec
= APT::Configuration::getLanguages(false, false, env
);
106 equals(vec
.size(), 1);
107 equals(vec
[0], "fr");
108 _config
->Set("Acquire::Languages", "");
110 _config
->Set("Acquire::Languages::1", "environment");
111 _config
->Set("Acquire::Languages::2", "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");
119 _config
->Set("Acquire::Languages::3", "de");
120 env
[0] = "de_DE.UTF-8";
121 vec
= APT::Configuration::getLanguages(false, false, env
);
122 equals(vec
.size(), 3);
123 equals(vec
[0], "de_DE");
124 equals(vec
[1], "de");
125 equals(vec
[2], "en");
127 _config
->Set("Dir::State::lists", argv
[1]);
128 vec
= APT::Configuration::getLanguages(true, false, env
);
129 equals(vec
.size(), 8);
130 equals(vec
[0], "de_DE");
131 equals(vec
[1], "de");
132 equals(vec
[2], "en");
133 equals(vec
[3], "none");
134 equalsOr4(vec
[4], "pt", "tr", "ast_DE", "tlh_DE");
135 equalsOr4(vec
[5], "tr", "pt", "ast_DE", "tlh_DE");
136 equalsOr4(vec
[6], "tr", "pt", "ast_DE", "tlh_DE");
137 equalsOr4(vec
[7], "tr", "pt", "ast_DE", "tlh_DE");
138 equalsNot(vec
[4], vec
[5]);
139 equalsNot(vec
[4], vec
[6]);
140 equalsNot(vec
[4], vec
[7]);
141 equalsNot(vec
[5], vec
[6]);
142 equalsNot(vec
[5], vec
[7]);
143 equalsNot(vec
[6], vec
[7]);
145 _config
->Set("Acquire::Languages", "none");
146 vec
= APT::Configuration::getLanguages(true, false, env
);
147 equals(vec
.size(), 0);
148 _config
->Set("Acquire::Languages", "");
150 _config
->Set("Dir::State::lists", "/non-existing-dir");
151 _config
->Set("Acquire::Languages::1", "none");
152 env
[0] = "de_DE.UTF-8";
153 vec
= APT::Configuration::getLanguages(false, false, env
);
154 equals(vec
.size(), 0);
155 env
[0] = "de_DE.UTF-8";
156 vec
= APT::Configuration::getLanguages(true, false, env
);
157 equals(vec
.size(), 2);
158 equals(vec
[0], "en");
159 equals(vec
[1], "de");
161 _config
->Set("Acquire::Languages::1", "fr");
162 _config
->Set("Acquire::Languages", "de_DE");
163 env
[0] = "de_DE.UTF-8";
164 vec
= APT::Configuration::getLanguages(false, false, env
);
165 equals(vec
.size(), 1);
166 equals(vec
[0], "de_DE");
168 _config
->Set("Acquire::Languages", "none");
169 env
[0] = "de_DE.UTF-8";
170 vec
= APT::Configuration::getLanguages(true, false, env
);
171 equals(vec
.size(), 0);
173 _config
->Set("Acquire::Languages", "");
174 //FIXME: Remove support for this deprecated setting
175 _config
->Set("APT::Acquire::Translation", "ast_DE");
176 env
[0] = "de_DE.UTF-8";
177 vec
= APT::Configuration::getLanguages(true, false, env
);
178 equals(vec
.size(), 2);
179 equals(vec
[0], "ast_DE");
180 equals(vec
[1], "en");
181 _config
->Set("APT::Acquire::Translation", "none");
182 env
[0] = "de_DE.UTF-8";
183 vec
= APT::Configuration::getLanguages(true, false, env
);
184 equals(vec
.size(), 1);
185 equals(vec
[0], "en");