diff options
author | Michael Vogt <mvo@debian.org> | 2014-04-25 13:51:50 +0200 |
---|---|---|
committer | Michael Vogt <mvo@debian.org> | 2014-04-25 13:51:50 +0200 |
commit | 15ccc2a685b0b884b393e356f9960e86f97f532d (patch) | |
tree | 920a1fcf6fa2c92a05d0d1d2ccb22eb32b88522e /test/libapt/getarchitectures_test.cc | |
parent | a40c6649b99814c7d30964accdd5ecc4f1ce369a (diff) | |
parent | 506ab3c78fb67f5e452a1748f4870af767de5ebb (diff) |
Merge branch 'debian/sid' into ubuntu/master
Conflicts:
debian/changelog
Diffstat (limited to 'test/libapt/getarchitectures_test.cc')
-rw-r--r-- | test/libapt/getarchitectures_test.cc | 116 |
1 files changed, 66 insertions, 50 deletions
diff --git a/test/libapt/getarchitectures_test.cc b/test/libapt/getarchitectures_test.cc index f4dfc6ae8..53c00cd8f 100644 --- a/test/libapt/getarchitectures_test.cc +++ b/test/libapt/getarchitectures_test.cc @@ -6,56 +6,72 @@ #include <string> #include <vector> -#include "assert.h" +#include <gtest/gtest.h> -int main() +TEST(ArchitecturesTest,SimpleLists) { - std::vector<std::string> vec; - - _config->Set("APT::Architectures::1", "i386"); - _config->Set("APT::Architectures::2", "amd64"); - vec = APT::Configuration::getArchitectures(false); - equals(vec.size(), 2); - equals(vec[0], "i386"); - equals(vec[1], "amd64"); - - _config->Set("APT::Architecture", "i386"); - vec = APT::Configuration::getArchitectures(false); - equals(vec.size(), 2); - equals(vec[0], "i386"); - equals(vec[1], "amd64"); - - _config->Set("APT::Architectures::2", ""); - vec = APT::Configuration::getArchitectures(false); - equals(vec.size(), 1); - equals(vec[0], "i386"); - - _config->Set("APT::Architecture", "armel"); - vec = APT::Configuration::getArchitectures(false); - equals(vec.size(), 2); - equals(vec[0], "armel"); - equals(vec[1], "i386"); - - _config->Set("APT::Architectures::2", "armel"); - vec = APT::Configuration::getArchitectures(false); - equals(vec.size(), 2); - equals(vec[0], "i386"); - equals(vec[1], "armel"); - - _config->Set("APT::Architectures::2", "amd64"); - _config->Set("APT::Architectures::3", "i386"); - _config->Set("APT::Architectures::4", "armel"); - _config->Set("APT::Architectures::5", "i386"); - _config->Set("APT::Architectures::6", "amd64"); - _config->Set("APT::Architectures::7", "armel"); - _config->Set("APT::Architectures::8", "armel"); - _config->Set("APT::Architectures::9", "amd64"); - _config->Set("APT::Architectures::10", "amd64"); - vec = APT::Configuration::getArchitectures(false); - equals(vec.size(), 3); - equals(vec[0], "i386"); - equals(vec[1], "amd64"); - equals(vec[2], "armel"); - - return 0; + _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(2, vec.size()); + EXPECT_EQ("i386", vec[0]); + EXPECT_EQ("amd64", vec[1]); + + _config->Set("APT::Architecture", "i386"); + vec = APT::Configuration::getArchitectures(false); + ASSERT_EQ(2, vec.size()); + EXPECT_EQ("i386", vec[0]); + EXPECT_EQ("amd64", vec[1]); + + _config->Set("APT::Architectures::2", ""); + vec = APT::Configuration::getArchitectures(false); + ASSERT_EQ(1, vec.size()); + EXPECT_EQ("i386", vec[0]); + + _config->Set("APT::Architecture", "armel"); + vec = APT::Configuration::getArchitectures(false); + ASSERT_EQ(2, 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(2, 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(2, 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(10, vec.size()); + vec = APT::Configuration::getArchitectures(false); + ASSERT_EQ(3, vec.size()); + EXPECT_EQ("i386", vec[0]); + EXPECT_EQ("amd64", vec[1]); + EXPECT_EQ("armel", vec[2]); + + _config->Clear(); } |