]>
Commit | Line | Data |
---|---|---|
1 | #include <apt-pkg/aptconfiguration.h> | |
2 | #include <apt-pkg/configuration.h> | |
3 | ||
4 | #include "assert.h" | |
5 | #include <string> | |
6 | #include <vector> | |
7 | ||
8 | #include <iostream> | |
9 | ||
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(); | |
13 | v != vec.end(); v++) | |
14 | std::cout << *v << std::endl; | |
15 | } | |
16 | ||
17 | int main(int argc,char *argv[]) | |
18 | { | |
19 | std::vector<std::string> vec = APT::Configuration::getLanguages(false, false, "de_DE.UTF-8"); | |
20 | equals(vec.size(), 2); | |
21 | equals(vec[0], "de"); | |
22 | equals(vec[1], "en"); | |
23 | ||
24 | // Special: Check if the cache is actually in use | |
25 | vec = APT::Configuration::getLanguages(false, true, "en_GB.UTF-8"); | |
26 | equals(vec.size(), 2); | |
27 | equals(vec[0], "de"); | |
28 | equals(vec[1], "en"); | |
29 | ||
30 | vec = APT::Configuration::getLanguages(false, false, "en_GB.UTF-8"); | |
31 | equals(vec.size(), 2); | |
32 | equals(vec[0], "en_GB"); | |
33 | equals(vec[1], "en"); | |
34 | ||
35 | vec = APT::Configuration::getLanguages(false, false, "pt_PR.UTF-8"); | |
36 | equals(vec.size(), 3); | |
37 | equals(vec[0], "pt_PR"); | |
38 | equals(vec[1], "pt"); | |
39 | equals(vec[2], "en"); | |
40 | ||
41 | vec = APT::Configuration::getLanguages(false, false, "ast_DE.UTF-8"); // bogus, but syntactical correct | |
42 | equals(vec.size(), 2); | |
43 | equals(vec[0], "ast"); | |
44 | equals(vec[1], "en"); | |
45 | ||
46 | vec = APT::Configuration::getLanguages(false, false, "C"); | |
47 | equals(vec.size(), 1); | |
48 | equals(vec[0], "en"); | |
49 | ||
50 | _config->Set("Acquire::Languages::1", "environment"); | |
51 | _config->Set("Acquire::Languages::2", "en"); | |
52 | vec = APT::Configuration::getLanguages(false, false, "de_DE.UTF-8"); | |
53 | equals(vec.size(), 2); | |
54 | equals(vec[0], "de"); | |
55 | equals(vec[1], "en"); | |
56 | ||
57 | _config->Set("Acquire::Languages::3", "de"); | |
58 | vec = APT::Configuration::getLanguages(false, false, "de_DE.UTF-8"); | |
59 | equals(vec.size(), 2); | |
60 | equals(vec[0], "de"); | |
61 | equals(vec[1], "en"); | |
62 | ||
63 | _config->Set("Acquire::Languages::1", "none"); | |
64 | vec = APT::Configuration::getLanguages(false, false, "de_DE.UTF-8"); | |
65 | equals(vec.size(), 0); | |
66 | vec = APT::Configuration::getLanguages(true, false, "de_DE.UTF-8"); | |
67 | equals(vec[0], "en"); | |
68 | equals(vec[1], "de"); | |
69 | ||
70 | _config->Set("Acquire::Languages::1", "fr"); | |
71 | _config->Set("Acquire::Languages", "de_DE"); | |
72 | vec = APT::Configuration::getLanguages(false, false, "de_DE.UTF-8"); | |
73 | equals(vec.size(), 1); | |
74 | equals(vec[0], "de_DE"); | |
75 | ||
76 | _config->Set("Acquire::Languages", "none"); | |
77 | vec = APT::Configuration::getLanguages(true, false, "de_DE.UTF-8"); | |
78 | equals(vec.size(), 0); | |
79 | ||
80 | _config->Set("Acquire::Languages", ""); | |
81 | //FIXME: Remove support for this deprecated setting | |
82 | _config->Set("APT::Acquire::Translation", "ast_DE"); | |
83 | vec = APT::Configuration::getLanguages(true, false, "de_DE.UTF-8"); | |
84 | equals(vec.size(), 1); | |
85 | equals(vec[0], "ast_DE"); | |
86 | _config->Set("APT::Acquire::Translation", "none"); | |
87 | vec = APT::Configuration::getLanguages(true, false, "de_DE.UTF-8"); | |
88 | equals(vec.size(), 0); | |
89 | ||
90 | return 0; | |
91 | } |