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
|
#include <config.h>
#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/configuration.h>
#include <string>
#include <vector>
#include <gtest/gtest.h>
TEST(ArchitecturesTest,SimpleLists)
{
_config->Clear();
std::vector<std::string> vec;
_config->Set("APT::Architectures::1", "i386");
_config->Set("APT::Architectures::2", "amd64");
vec = APT::Configuration::getArchitectures(false);
ASSERT_EQ(2u, vec.size());
EXPECT_EQ("i386", vec[0]);
EXPECT_EQ("amd64", vec[1]);
_config->Set("APT::Architecture", "i386");
vec = APT::Configuration::getArchitectures(false);
ASSERT_EQ(2u, vec.size());
EXPECT_EQ("i386", vec[0]);
EXPECT_EQ("amd64", vec[1]);
_config->Set("APT::Architectures::2", "");
vec = APT::Configuration::getArchitectures(false);
ASSERT_EQ(1u, vec.size());
EXPECT_EQ("i386", vec[0]);
_config->Set("APT::Architecture", "armel");
vec = APT::Configuration::getArchitectures(false);
ASSERT_EQ(2u, vec.size());
EXPECT_EQ("armel", vec[0]);
EXPECT_EQ("i386", vec[1]);
_config->Set("APT::Architectures::2", "armel");
vec = APT::Configuration::getArchitectures(false);
ASSERT_EQ(2u, vec.size());
EXPECT_EQ("i386", vec[0]);
EXPECT_EQ("armel", vec[1]);
_config->Set("APT::Architectures", "armel,armhf");
vec = APT::Configuration::getArchitectures(false);
ASSERT_EQ(2u, vec.size());
EXPECT_EQ("armel", vec[0]);
EXPECT_EQ("armhf", vec[1]);
_config->Clear();
}
TEST(ArchitecturesTest,Duplicates)
{
_config->Clear();
_config->Set("APT::Architecture", "armel");
_config->Set("APT::Architectures::", "i386");
_config->Set("APT::Architectures::", "amd64");
_config->Set("APT::Architectures::", "i386");
_config->Set("APT::Architectures::", "armel");
_config->Set("APT::Architectures::", "i386");
_config->Set("APT::Architectures::", "amd64");
_config->Set("APT::Architectures::", "armel");
_config->Set("APT::Architectures::", "armel");
_config->Set("APT::Architectures::", "amd64");
_config->Set("APT::Architectures::", "amd64");
std::vector<std::string> vec = _config->FindVector("APT::Architectures");
ASSERT_EQ(10u, vec.size());
vec = APT::Configuration::getArchitectures(false);
ASSERT_EQ(3u, vec.size());
EXPECT_EQ("i386", vec[0]);
EXPECT_EQ("amd64", vec[1]);
EXPECT_EQ("armel", vec[2]);
_config->Clear();
}
TEST(ArchitecturesTest,VeryForeign)
{
_config->Clear();
_config->Set("APT::Architectures::", "i386");
_config->Set("APT::Architectures::", "amd64");
_config->Set("APT::Architectures::", "armel");
auto vec = APT::Configuration::getArchitectures(false);
ASSERT_EQ(3u, vec.size());
EXPECT_EQ("i386", vec[0]);
EXPECT_EQ("amd64", vec[1]);
EXPECT_EQ("armel", vec[2]);
_config->Set("APT::BarbarianArchitectures::", "mipsel");
vec = APT::Configuration::getArchitectures(false);
ASSERT_EQ(3u, vec.size());
EXPECT_EQ("i386", vec[0]);
EXPECT_EQ("amd64", vec[1]);
EXPECT_EQ("armel", vec[2]);
_config->Set("APT::BarbarianArchitectures::", "armel");
vec = APT::Configuration::getArchitectures(false);
ASSERT_EQ(2u, vec.size());
EXPECT_EQ("i386", vec[0]);
EXPECT_EQ("amd64", vec[1]);
_config->Clear();
}
|