]> git.saurik.com Git - apt.git/blobdiff - test/libapt/getarchitectures_test.cc
show the conflicting distribution warning again
[apt.git] / test / libapt / getarchitectures_test.cc
index e3ca7bbc21611b1f7bdb9b6d747be2f6b518e5b2..53c00cd8f041e170af9833a756cce9c021811dbd 100644 (file)
@@ -1,67 +1,77 @@
+#include <config.h>
+
 #include <apt-pkg/aptconfiguration.h>
 #include <apt-pkg/configuration.h>
 
-#include "assert.h"
 #include <string>
 #include <vector>
 
-#include <iostream>
-
-// simple helper to quickly output a vector of strings
-void dumpVector(std::vector<std::string> vec) {
-       for (std::vector<std::string>::const_iterator v = vec.begin();
-            v != vec.end(); v++)
-               std::cout << *v << std::endl;
-}
+#include <gtest/gtest.h>
 
-int main(int argc,char *argv[])
+TEST(ArchitecturesTest,SimpleLists)
 {
-       std::vector<std::string> vec;
+   _config->Clear();
+   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::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);
-       equals(vec.size(), 2);
-       equals(vec[0], "i386");
-       equals(vec[1], "amd64");
+   _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);
-       equals(vec.size(), 1);
-       equals(vec[0], "i386");
+   _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);
-       equals(vec.size(), 2);
-       equals(vec[0], "armel");
-       equals(vec[1], "i386");
+   _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);
-       equals(vec.size(), 2);
-       equals(vec[0], "i386");
-       equals(vec[1], "armel");
+   _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::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");
+   _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]);
 
-       return 0;
+   _config->Clear();
 }