]>
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 std::cout
<< "One parameter expected - given " << argc
<< std::endl
;
25 env
[0] = "de_DE.UTF-8";
28 std::vector
<std::string
> vec
= APT::Configuration::getLanguages(false, false, env
);
29 equals(vec
.size(), 2);
33 // Special: Check if the cache is actually in use
34 env
[0] = "en_GB.UTF-8";
35 vec
= APT::Configuration::getLanguages(false, true, env
);
36 equals(vec
.size(), 2);
40 env
[0] = "en_GB.UTF-8";
41 vec
= APT::Configuration::getLanguages(false, false, env
);
42 equals(vec
.size(), 2);
43 equals(vec
[0], "en_GB");
48 vec
= APT::Configuration::getLanguages(false, false, env
);
49 equals(vec
.size(), 2);
53 env
[0] = "tr_DE@euro";
54 vec
= APT::Configuration::getLanguages(false, false, env
);
55 equals(vec
.size(), 2);
60 env
[1] = "se_NO:en_GB:nb_NO:nb:no_NO:no:nn_NO:nn:da:sv:en";
61 vec
= APT::Configuration::getLanguages(false, false, env
);
62 equals(vec
.size(), 5);
64 equals(vec
[1], "en_GB");
69 env
[0] = "pt_PR.UTF-8";
71 vec
= APT::Configuration::getLanguages(false, false, env
);
72 equals(vec
.size(), 3);
73 equals(vec
[0], "pt_PR");
77 env
[0] = "ast_DE.UTF-8";
78 vec
= APT::Configuration::getLanguages(false, false, env
); // bogus, but syntactical correct
79 equals(vec
.size(), 2);
80 equals(vec
[0], "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");
110 _config
->Set("Acquire::Languages", "");
112 _config
->Set("Acquire::Languages::1", "environment");
113 _config
->Set("Acquire::Languages::2", "en");
114 env
[0] = "de_DE.UTF-8";
115 vec
= APT::Configuration::getLanguages(false, false, env
);
116 equals(vec
.size(), 2);
117 equals(vec
[0], "de");
118 equals(vec
[1], "en");
120 _config
->Set("Acquire::Languages::3", "de");
121 env
[0] = "de_DE.UTF-8";
122 vec
= APT::Configuration::getLanguages(false, false, env
);
123 equals(vec
.size(), 2);
124 equals(vec
[0], "de");
125 equals(vec
[1], "en");
127 _config
->Set("Dir::State::lists", argv
[1]);
128 vec
= APT::Configuration::getLanguages(true, false, env
);
129 equals(vec
.size(), 5);
130 equals(vec
[0], "de");
131 equals(vec
[1], "en");
132 equals(vec
[2], "none");
133 equals(vec
[3], "pt");
134 equals(vec
[4], "tr");
136 _config
->Set("Dir::State::lists", "/non-existing-dir");
137 _config
->Set("Acquire::Languages::1", "none");
138 env
[0] = "de_DE.UTF-8";
139 vec
= APT::Configuration::getLanguages(false, false, env
);
140 equals(vec
.size(), 0);
141 env
[0] = "de_DE.UTF-8";
142 vec
= APT::Configuration::getLanguages(true, false, env
);
143 equals(vec
[0], "en");
144 equals(vec
[1], "de");
146 _config
->Set("Acquire::Languages::1", "fr");
147 _config
->Set("Acquire::Languages", "de_DE");
148 env
[0] = "de_DE.UTF-8";
149 vec
= APT::Configuration::getLanguages(false, false, env
);
150 equals(vec
.size(), 1);
151 equals(vec
[0], "de_DE");
153 _config
->Set("Acquire::Languages", "none");
154 env
[0] = "de_DE.UTF-8";
155 vec
= APT::Configuration::getLanguages(true, false, env
);
156 equals(vec
.size(), 0);
158 _config
->Set("Acquire::Languages", "");
159 //FIXME: Remove support for this deprecated setting
160 _config
->Set("APT::Acquire::Translation", "ast_DE");
161 env
[0] = "de_DE.UTF-8";
162 vec
= APT::Configuration::getLanguages(true, false, env
);
163 equals(vec
.size(), 2);
164 equals(vec
[0], "ast_DE");
165 equals(vec
[1], "en");
166 _config
->Set("APT::Acquire::Translation", "none");
167 env
[0] = "de_DE.UTF-8";
168 vec
= APT::Configuration::getLanguages(true, false, env
);
169 equals(vec
.size(), 1);
170 equals(vec
[0], "en");