1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/configuration.h>
#include "assert.h"
#include <string>
#include <vector>
#include <iostream>
// simple helper to quickly output a vector of strings
void dumpVector(std::vector<std::string> vec) {
for (std::vector<std::string>::const_iterator v = vec.begin();
v != vec.end(); v++)
std::cout << *v << std::endl;
}
int main(int argc,char *argv[])
{
char const* env[2];
env[0] = "de_DE.UTF-8";
env[1] = "";
std::vector<std::string> vec = APT::Configuration::getLanguages(false, false, env);
equals(vec.size(), 2);
equals(vec[0], "de");
equals(vec[1], "en");
// Special: Check if the cache is actually in use
env[0] = "en_GB.UTF-8";
vec = APT::Configuration::getLanguages(false, true, env);
equals(vec.size(), 2);
equals(vec[0], "de");
equals(vec[1], "en");
env[0] = "en_GB.UTF-8";
vec = APT::Configuration::getLanguages(false, false, env);
equals(vec.size(), 2);
equals(vec[0], "en_GB");
equals(vec[1], "en");
env[0] = "tr_DE@euro";
vec = APT::Configuration::getLanguages(false, false, env);
equals(vec.size(), 2);
equals(vec[0], "tr");
equals(vec[1], "en");
env[0] = "de_NO";
env[1] = "se_NO:en_GB:nb_NO:nb:no_NO:no:nn_NO:nn:da:sv:en";
vec = APT::Configuration::getLanguages(false, false, env);
equals(vec.size(), 5);
equals(vec[0], "de");
equals(vec[1], "en_GB");
equals(vec[2], "nb");
equals(vec[3], "no");
equals(vec[4], "en");
env[0] = "pt_PR.UTF-8";
env[1] = "";
vec = APT::Configuration::getLanguages(false, false, env);
equals(vec.size(), 3);
equals(vec[0], "pt_PR");
equals(vec[1], "pt");
equals(vec[2], "en");
env[0] = "ast_DE.UTF-8";
vec = APT::Configuration::getLanguages(false, false, env); // bogus, but syntactical correct
equals(vec.size(), 2);
equals(vec[0], "ast");
equals(vec[1], "en");
env[0] = "C";
vec = APT::Configuration::getLanguages(false, false, env);
equals(vec.size(), 1);
equals(vec[0], "en");
_config->Set("Acquire::Languages::1", "environment");
_config->Set("Acquire::Languages::2", "en");
env[0] = "de_DE.UTF-8";
vec = APT::Configuration::getLanguages(false, false, env);
equals(vec.size(), 2);
equals(vec[0], "de");
equals(vec[1], "en");
_config->Set("Acquire::Languages::3", "de");
env[0] = "de_DE.UTF-8";
vec = APT::Configuration::getLanguages(false, false, env);
equals(vec.size(), 2);
equals(vec[0], "de");
equals(vec[1], "en");
_config->Set("Acquire::Languages::1", "none");
env[0] = "de_DE.UTF-8";
vec = APT::Configuration::getLanguages(false, false, env);
equals(vec.size(), 0);
env[0] = "de_DE.UTF-8";
vec = APT::Configuration::getLanguages(true, false, env);
equals(vec[0], "en");
equals(vec[1], "de");
_config->Set("Acquire::Languages::1", "fr");
_config->Set("Acquire::Languages", "de_DE");
env[0] = "de_DE.UTF-8";
vec = APT::Configuration::getLanguages(false, false, env);
equals(vec.size(), 1);
equals(vec[0], "de_DE");
_config->Set("Acquire::Languages", "none");
env[0] = "de_DE.UTF-8";
vec = APT::Configuration::getLanguages(true, false, env);
equals(vec.size(), 0);
_config->Set("Acquire::Languages", "");
//FIXME: Remove support for this deprecated setting
_config->Set("APT::Acquire::Translation", "ast_DE");
env[0] = "de_DE.UTF-8";
vec = APT::Configuration::getLanguages(true, false, env);
equals(vec.size(), 1);
equals(vec[0], "ast_DE");
_config->Set("APT::Acquire::Translation", "none");
env[0] = "de_DE.UTF-8";
vec = APT::Configuration::getLanguages(true, false, env);
equals(vec.size(), 0);
return 0;
}
|