]> git.saurik.com Git - apt.git/blobdiff - test/libapt/indexcopytosourcelist_test.cc
CMake: Translations: Build .pot in po binary dir, not project one
[apt.git] / test / libapt / indexcopytosourcelist_test.cc
index e04ab261b863b1db97bd7dda7f30e92999b53b3e..eb6d49edf1716f1f338d5f8b31184baeca352541 100644 (file)
@@ -7,30 +7,35 @@
 #include <string>
 #include <stdio.h>
 
-#include "assert.h"
+#include <gtest/gtest.h>
 
-class NoCopy : public IndexCopy {
-public:
-   std::string ConvertToSourceList(std::string CD,std::string Path) {
-      IndexCopy::ConvertToSourceList(CD, Path);
-      return Path;
-   }
-   bool GetFile(std::string &/*Filename*/, unsigned long long &/*Size*/) { return false; }
-   bool RewriteEntry(FILE * /*Target*/, std::string /*File*/) { return false; }
-   const char *GetFileName() { return NULL; }
-   const char *Type() { return NULL; }
+class NoCopy : private IndexCopy {
+   public:
+      std::string ConvertToSourceList(std::string const &CD,std::string &&Path) {
+        IndexCopy::ConvertToSourceList(CD, Path);
+        return Path;
+      }
+      bool GetFile(std::string &/*Filename*/, unsigned long long &/*Size*/) APT_OVERRIDE { return false; }
+      bool RewriteEntry(FileFd & /*Target*/, std::string const &/*File*/) APT_OVERRIDE { return false; }
+      const char *GetFileName() APT_OVERRIDE { return NULL; }
+      const char *Type() APT_OVERRIDE { return NULL; }
 
 };
 
-int main() {
+TEST(IndexCopyTest, ConvertToSourceList)
+{
    NoCopy ic;
    std::string const CD("/media/cdrom/");
 
    char const * Releases[] = { "unstable", "wheezy-updates", NULL };
    char const * Components[] = { "main", "non-free", NULL };
 
-   for (char const ** Release = Releases; *Release != NULL; ++Release) {
-      for (char const ** Component = Components; *Component != NULL; ++Component) {
+   for (char const ** Release = Releases; *Release != NULL; ++Release)
+   {
+      SCOPED_TRACE(std::string("Release ") + *Release);
+      for (char const ** Component = Components; *Component != NULL; ++Component)
+      {
+        SCOPED_TRACE(std::string("Component ") + *Component);
         std::string const Path = std::string("dists/") + *Release + "/" + *Component + "/";
         std::string const Binary = Path + "binary-";
         std::string const A = Binary + "armel/";
@@ -39,51 +44,66 @@ int main() {
         std::string const S = Path + "source/";
         std::string const List = std::string(*Release) + " " + *Component;
 
+        {
+        SCOPED_TRACE("no archs configured");
         _config->Clear("APT");
+        _config->Set("APT::Architecture", "all");
+        _config->Set("APT::Architectures::", "all");
         APT::Configuration::getArchitectures(false);
-        equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), A);
-        equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), B);
-        equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), C);
-        equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List);
+        EXPECT_EQ(A, ic.ConvertToSourceList("/media/cdrom/", CD + A));
+        EXPECT_EQ(B, ic.ConvertToSourceList("/media/cdrom/", CD + B));
+        EXPECT_EQ(C, ic.ConvertToSourceList("/media/cdrom/", CD + C));
+        EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + S));
+        }
 
+        {
+        SCOPED_TRACE("mips configured");
         _config->Clear("APT");
         _config->Set("APT::Architecture", "mips");
         _config->Set("APT::Architectures::", "mips");
         APT::Configuration::getArchitectures(false);
-        equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), A);
-        equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), List);
-        equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), C);
-        equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List);
+        EXPECT_EQ(A, ic.ConvertToSourceList("/media/cdrom/", CD + A));
+        EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + B));
+        EXPECT_EQ(C, ic.ConvertToSourceList("/media/cdrom/", CD + C));
+        EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + S));
+        }
 
+        {
+        SCOPED_TRACE("kfreebsd-mips configured");
         _config->Clear("APT");
         _config->Set("APT::Architecture", "kfreebsd-mips");
         _config->Set("APT::Architectures::", "kfreebsd-mips");
         APT::Configuration::getArchitectures(false);
-        equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), A);
-        equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), B);
-        equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), List);
-        equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List);
+        EXPECT_EQ(A, ic.ConvertToSourceList("/media/cdrom/", CD + A));
+        EXPECT_EQ(B, ic.ConvertToSourceList("/media/cdrom/", CD + B));
+        EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + C));
+        EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + S));
+        }
 
+        {
+        SCOPED_TRACE("armel configured");
         _config->Clear("APT");
         _config->Set("APT::Architecture", "armel");
         _config->Set("APT::Architectures::", "armel");
         APT::Configuration::getArchitectures(false);
-        equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), List);
-        equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), B);
-        equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), C);
-        equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List);
+        EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + A));
+        EXPECT_EQ(B, ic.ConvertToSourceList("/media/cdrom/", CD + B));
+        EXPECT_EQ(C, ic.ConvertToSourceList("/media/cdrom/", CD + C));
+        EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + S));
+        }
 
+        {
+        SCOPED_TRACE("armel+mips configured");
         _config->Clear("APT");
         _config->Set("APT::Architecture", "armel");
         _config->Set("APT::Architectures::", "armel");
         _config->Set("APT::Architectures::", "mips");
         APT::Configuration::getArchitectures(false);
-        equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), List);
-        equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), List);
-        equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), C);
-        equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List);
+        EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + A));
+        EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + B));
+        EXPECT_EQ(C, ic.ConvertToSourceList("/media/cdrom/", CD + C));
+        EXPECT_EQ(List, ic.ConvertToSourceList("/media/cdrom/", CD + S));
+        }
       }
    }
-
-   return 0;
 }