]> git.saurik.com Git - apt.git/blob - test/libapt/getarchitectures_test.cc
use the same redirection handling for http and https
[apt.git] / test / libapt / getarchitectures_test.cc
1 #include <config.h>
2
3 #include <apt-pkg/aptconfiguration.h>
4 #include <apt-pkg/configuration.h>
5
6 #include <string>
7 #include <vector>
8
9 #include <gtest/gtest.h>
10
11 TEST(ArchitecturesTest,SimpleLists)
12 {
13 _config->Clear();
14 std::vector<std::string> vec;
15
16 _config->Set("APT::Architectures::1", "i386");
17 _config->Set("APT::Architectures::2", "amd64");
18 vec = APT::Configuration::getArchitectures(false);
19 ASSERT_EQ(2, vec.size());
20 EXPECT_EQ("i386", vec[0]);
21 EXPECT_EQ("amd64", vec[1]);
22
23 _config->Set("APT::Architecture", "i386");
24 vec = APT::Configuration::getArchitectures(false);
25 ASSERT_EQ(2, vec.size());
26 EXPECT_EQ("i386", vec[0]);
27 EXPECT_EQ("amd64", vec[1]);
28
29 _config->Set("APT::Architectures::2", "");
30 vec = APT::Configuration::getArchitectures(false);
31 ASSERT_EQ(1, vec.size());
32 EXPECT_EQ("i386", vec[0]);
33
34 _config->Set("APT::Architecture", "armel");
35 vec = APT::Configuration::getArchitectures(false);
36 ASSERT_EQ(2, vec.size());
37 EXPECT_EQ("armel", vec[0]);
38 EXPECT_EQ("i386", vec[1]);
39
40 _config->Set("APT::Architectures::2", "armel");
41 vec = APT::Configuration::getArchitectures(false);
42 ASSERT_EQ(2, vec.size());
43 EXPECT_EQ("i386", vec[0]);
44 EXPECT_EQ("armel", vec[1]);
45
46 _config->Set("APT::Architectures", "armel,armhf");
47 vec = APT::Configuration::getArchitectures(false);
48 ASSERT_EQ(2, vec.size());
49 EXPECT_EQ("armel", vec[0]);
50 EXPECT_EQ("armhf", vec[1]);
51 _config->Clear();
52 }
53 TEST(ArchitecturesTest,Duplicates)
54 {
55 _config->Clear();
56
57 _config->Set("APT::Architecture", "armel");
58 _config->Set("APT::Architectures::", "i386");
59 _config->Set("APT::Architectures::", "amd64");
60 _config->Set("APT::Architectures::", "i386");
61 _config->Set("APT::Architectures::", "armel");
62 _config->Set("APT::Architectures::", "i386");
63 _config->Set("APT::Architectures::", "amd64");
64 _config->Set("APT::Architectures::", "armel");
65 _config->Set("APT::Architectures::", "armel");
66 _config->Set("APT::Architectures::", "amd64");
67 _config->Set("APT::Architectures::", "amd64");
68 std::vector<std::string> vec = _config->FindVector("APT::Architectures");
69 ASSERT_EQ(10, vec.size());
70 vec = APT::Configuration::getArchitectures(false);
71 ASSERT_EQ(3, vec.size());
72 EXPECT_EQ("i386", vec[0]);
73 EXPECT_EQ("amd64", vec[1]);
74 EXPECT_EQ("armel", vec[2]);
75
76 _config->Clear();
77 }