summaryrefslogtreecommitdiff
path: root/test/libapt/indexcopytosourcelist_test.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2014-04-16 17:09:37 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2014-04-16 18:36:14 +0200
commitf00832cc273e52a47fb88e49849891b771de4e17 (patch)
treeeedd6b1e1c873c7e3e8f614a0ac8ca5c3b7e37b9 /test/libapt/indexcopytosourcelist_test.cc
parentbb93178b8b5c2f8021977dbc34066f0d0fb8b9b9 (diff)
use Google C++ Testing Framework for libapt tests
My commit 45df0ad2 from 26. Nov 2009 had a little remark: "The commit also includes a very very simple testapp." This was never intended to be permanent, but as usually… The commit adds the needed make magic to compile gtest statically as it is required and links it against a small runner. All previous testcase binaries are reimplemented in gtest and combined in this runner. While most code is a 1:1 translation some had to be rewritten like compareversion_test.cc, but the coverage remains the same.
Diffstat (limited to 'test/libapt/indexcopytosourcelist_test.cc')
-rw-r--r--test/libapt/indexcopytosourcelist_test.cc73
1 files changed, 38 insertions, 35 deletions
diff --git a/test/libapt/indexcopytosourcelist_test.cc b/test/libapt/indexcopytosourcelist_test.cc
index e04ab261b..bec87601f 100644
--- a/test/libapt/indexcopytosourcelist_test.cc
+++ b/test/libapt/indexcopytosourcelist_test.cc
@@ -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; }
+ 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; }
};
-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/";
@@ -41,49 +46,47 @@ int main() {
_config->Clear("APT");
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));
_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));
_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));
_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));
_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;
}