]> git.saurik.com Git - apt.git/blame - test/libapt/getlanguages_test.cc
Add a GetListOfFilesInDir() helper method which replaces the old
[apt.git] / test / libapt / getlanguages_test.cc
CommitLineData
45df0ad2
DK
1#include <apt-pkg/aptconfiguration.h>
2#include <apt-pkg/configuration.h>
3
9c562bc9 4#include "assert.h"
45df0ad2
DK
5#include <string>
6#include <vector>
7
8#include <iostream>
9
10// simple helper to quickly output a vector of strings
11void 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
17int main(int argc,char *argv[])
18{
19 std::vector<std::string> vec = APT::Configuration::getLanguages(false, false, "de_DE.UTF-8");
9c562bc9
DK
20 equals(vec.size(), 2);
21 equals(vec[0], "de");
22 equals(vec[1], "en");
45df0ad2
DK
23
24 // Special: Check if the cache is actually in use
25 vec = APT::Configuration::getLanguages(false, true, "en_GB.UTF-8");
9c562bc9
DK
26 equals(vec.size(), 2);
27 equals(vec[0], "de");
28 equals(vec[1], "en");
45df0ad2
DK
29
30 vec = APT::Configuration::getLanguages(false, false, "en_GB.UTF-8");
9c562bc9
DK
31 equals(vec.size(), 2);
32 equals(vec[0], "en_GB");
33 equals(vec[1], "en");
45df0ad2
DK
34
35 vec = APT::Configuration::getLanguages(false, false, "pt_PR.UTF-8");
9c562bc9
DK
36 equals(vec.size(), 3);
37 equals(vec[0], "pt_PR");
38 equals(vec[1], "pt");
39 equals(vec[2], "en");
45df0ad2
DK
40
41 vec = APT::Configuration::getLanguages(false, false, "ast_DE.UTF-8"); // bogus, but syntactical correct
9c562bc9
DK
42 equals(vec.size(), 2);
43 equals(vec[0], "ast");
44 equals(vec[1], "en");
45df0ad2
DK
45
46 vec = APT::Configuration::getLanguages(false, false, "C");
9c562bc9
DK
47 equals(vec.size(), 1);
48 equals(vec[0], "en");
45df0ad2
DK
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");
9c562bc9
DK
53 equals(vec.size(), 2);
54 equals(vec[0], "de");
55 equals(vec[1], "en");
45df0ad2
DK
56
57 _config->Set("Acquire::Languages::3", "de");
58 vec = APT::Configuration::getLanguages(false, false, "de_DE.UTF-8");
9c562bc9
DK
59 equals(vec.size(), 2);
60 equals(vec[0], "de");
61 equals(vec[1], "en");
45df0ad2
DK
62
63 _config->Set("Acquire::Languages::1", "none");
64 vec = APT::Configuration::getLanguages(false, false, "de_DE.UTF-8");
9c562bc9 65 equals(vec.size(), 0);
45df0ad2 66 vec = APT::Configuration::getLanguages(true, false, "de_DE.UTF-8");
9c562bc9
DK
67 equals(vec[0], "en");
68 equals(vec[1], "de");
45df0ad2
DK
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");
9c562bc9
DK
73 equals(vec.size(), 1);
74 equals(vec[0], "de_DE");
45df0ad2
DK
75
76 _config->Set("Acquire::Languages", "none");
77 vec = APT::Configuration::getLanguages(true, false, "de_DE.UTF-8");
9c562bc9 78 equals(vec.size(), 0);
45df0ad2
DK
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");
9c562bc9
DK
84 equals(vec.size(), 1);
85 equals(vec[0], "ast_DE");
45df0ad2
DK
86 _config->Set("APT::Acquire::Translation", "none");
87 vec = APT::Configuration::getLanguages(true, false, "de_DE.UTF-8");
9c562bc9 88 equals(vec.size(), 0);
45df0ad2
DK
89
90 return 0;
91}