aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-20 15:15:53 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-20 16:20:42 +0000
commit064eb1193cd95639c3728e58b503ee32eaa05dca (patch)
treeafc47987bcabe812d74e685aa61448402eb4f378
parent6d16f1563c4c584302229ed72ffcff506ae06f6f (diff)
downloadpaludis-064eb1193cd95639c3728e58b503ee32eaa05dca.tar.gz
paludis-064eb1193cd95639c3728e58b503ee32eaa05dca.tar.xz
gtest more
-rw-r--r--paludis/util/files.m42
-rw-r--r--paludis/util/realpath_TEST.cc69
2 files changed, 33 insertions, 38 deletions
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4
index fd2231f..0a31ee9 100644
--- a/paludis/util/files.m4
+++ b/paludis/util/files.m4
@@ -65,7 +65,7 @@ add(`pretty_print', `hh', `cc', `test')
add(`process', `hh', `cc', `fwd', `test', `testscript')
add(`pty', `hh', `cc', `test')
add(`random', `hh', `cc', `test')
-add(`realpath', `hh', `cc', `test', `testscript')
+add(`realpath', `hh', `cc', `gtest', `testscript')
add(`remove_shared_ptr', `hh')
add(`return_literal_function', `hh', `cc', `fwd', `gtest')
add(`rmd160', `hh', `cc', `gtest')
diff --git a/paludis/util/realpath_TEST.cc b/paludis/util/realpath_TEST.cc
index 6f573ba..800580e 100644
--- a/paludis/util/realpath_TEST.cc
+++ b/paludis/util/realpath_TEST.cc
@@ -2,6 +2,7 @@
/*
* Copyright (c) 2007 David Leverton
+ * Copyright (c) 2011 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -20,49 +21,43 @@
#include <paludis/util/realpath.hh>
#include <paludis/util/fs_path.hh>
#include <paludis/util/fs_error.hh>
+#include <paludis/util/stringify.hh>
-#include <test/test_runner.hh>
-#include <test/test_framework.hh>
+#include <gtest/gtest.h>
-using namespace test;
using namespace paludis;
-namespace test_cases
+namespace
{
- struct RealpathWithCurrentAndRootTest : TestCase
+ FSPath resolve(const FSPath & symlink, const FSPath & root)
{
- RealpathWithCurrentAndRootTest() : TestCase("realpath_with_current_and_root") {}
-
- FSPath resolve(const FSPath & symlink, const FSPath & root)
- {
- return realpath_with_current_and_root(FSPath((root / symlink).readlink()), symlink.dirname(), root);
- }
-
- void run()
- {
- FSPath root("realpath_TEST_dir");
-
- TEST_CHECK_STRINGIFY_EQUAL(resolve(FSPath("/usr/lib64/libfoo.so"), root), "/usr/lib64/libfoo.so.1");
- TEST_CHECK_STRINGIFY_EQUAL(resolve(FSPath("/usr/lib64/libbar.so"), root), "/usr/lib64/libbar.so.1");
- TEST_CHECK_STRINGIFY_EQUAL(resolve(FSPath("/usr/lib64/libbaz.so"), root), "/usr/lib64/libbaz.so.1");
- TEST_CHECK_STRINGIFY_EQUAL(resolve(FSPath("/usr/lib64/libxyzzy.so"), root), "/usr/lib64/libxyzzy.so.1");
- TEST_CHECK_STRINGIFY_EQUAL(resolve(FSPath("/usr/lib64/libplugh.so"), root), "/usr/lib64/libplugh.so.1");
- TEST_CHECK_STRINGIFY_EQUAL(resolve(FSPath("/usr/lib64/libplover.so"), root), "/usr/lib64/libplover.so.1");
- TEST_CHECK_STRINGIFY_EQUAL(resolve(FSPath("/usr/lib64/libblast.so"), root), "/usr/lib64/libblast.so.1");
- TEST_CHECK_STRINGIFY_EQUAL(resolve(FSPath("/usr/lib64/libquux.so"), root), "/usr/lib64/libquux.so.1");
- TEST_CHECK_STRINGIFY_EQUAL(resolve(FSPath("/usr/lib64/libnarf.so"), root), "/usr/lib64/libnarf.so.1");
- TEST_CHECK_STRINGIFY_EQUAL(resolve(FSPath("/usr/lib64/libblech.so"), root), "/usr/lib64/libblech.so.1");
- TEST_CHECK_STRINGIFY_EQUAL(resolve(FSPath("/usr/lib64/libstab.so"), root), "/usr/lib64/libstab.so.1");
- TEST_CHECK_STRINGIFY_EQUAL(resolve(FSPath("/usr/lib64/libsnark.so"), root), "/usr/lib64/libsnark.so.1");
- TEST_CHECK_STRINGIFY_EQUAL(resolve(FSPath("/usr/lib64/libfool.so"), root), "/usr/lib32/libfool.so.1");
- TEST_CHECK_STRINGIFY_EQUAL(resolve(FSPath("/usr/lib64/libbarf.so"), root), "/usr/lib64/barf/libbarf.so.1");
- TEST_CHECK_STRINGIFY_EQUAL(resolve(FSPath("/usr/lib64/libblip.so"), root), "/usr/lib64/libblip.so.1.0.1");
- TEST_CHECK_STRINGIFY_EQUAL(resolve(FSPath("/usr/lib64/libpoing.so"), root), "/usr/lib64/libpoing.so.1.0.1");
- TEST_CHECK_STRINGIFY_EQUAL(resolve(FSPath("/usr/lib64/x/liby.so"), root), "/usr/lib64/x/liby.so.1");
+ return realpath_with_current_and_root(FSPath((root / symlink).readlink()), symlink.dirname(), root);
+ }
+}
- TEST_CHECK_THROWS(resolve(FSPath("/usr/lib64/libouch.so"), root), FSError);
- TEST_CHECK_THROWS(resolve(FSPath("/usr/lib64/libping.so"), root), FSError);
- }
- } realpath_with_current_and_root_test;
+TEST(Realpath, CurrentAndRoot)
+{
+ FSPath root("realpath_TEST_dir");
+
+ EXPECT_EQ("/usr/lib64/libfoo.so.1", stringify(resolve(FSPath("/usr/lib64/libfoo.so"), root)));
+ EXPECT_EQ("/usr/lib64/libbar.so.1", stringify(resolve(FSPath("/usr/lib64/libbar.so"), root)));
+ EXPECT_EQ("/usr/lib64/libbaz.so.1", stringify(resolve(FSPath("/usr/lib64/libbaz.so"), root)));
+ EXPECT_EQ("/usr/lib64/libxyzzy.so.1", stringify(resolve(FSPath("/usr/lib64/libxyzzy.so"), root)));
+ EXPECT_EQ("/usr/lib64/libplugh.so.1", stringify(resolve(FSPath("/usr/lib64/libplugh.so"), root)));
+ EXPECT_EQ("/usr/lib64/libplover.so.1", stringify(resolve(FSPath("/usr/lib64/libplover.so"), root)));
+ EXPECT_EQ("/usr/lib64/libblast.so.1", stringify(resolve(FSPath("/usr/lib64/libblast.so"), root)));
+ EXPECT_EQ("/usr/lib64/libquux.so.1", stringify(resolve(FSPath("/usr/lib64/libquux.so"), root)));
+ EXPECT_EQ("/usr/lib64/libnarf.so.1", stringify(resolve(FSPath("/usr/lib64/libnarf.so"), root)));
+ EXPECT_EQ("/usr/lib64/libblech.so.1", stringify(resolve(FSPath("/usr/lib64/libblech.so"), root)));
+ EXPECT_EQ("/usr/lib64/libstab.so.1", stringify(resolve(FSPath("/usr/lib64/libstab.so"), root)));
+ EXPECT_EQ("/usr/lib64/libsnark.so.1", stringify(resolve(FSPath("/usr/lib64/libsnark.so"), root)));
+ EXPECT_EQ("/usr/lib32/libfool.so.1", stringify(resolve(FSPath("/usr/lib64/libfool.so"), root)));
+ EXPECT_EQ("/usr/lib64/barf/libbarf.so.1", stringify(resolve(FSPath("/usr/lib64/libbarf.so"), root)));
+ EXPECT_EQ("/usr/lib64/libblip.so.1.0.1", stringify(resolve(FSPath("/usr/lib64/libblip.so"), root)));
+ EXPECT_EQ("/usr/lib64/libpoing.so.1.0.1", stringify(resolve(FSPath("/usr/lib64/libpoing.so"), root)));
+ EXPECT_EQ("/usr/lib64/x/liby.so.1", stringify(resolve(FSPath("/usr/lib64/x/liby.so"), root)));
+
+ EXPECT_THROW(resolve(FSPath("/usr/lib64/libouch.so"), root), FSError);
+ EXPECT_THROW(resolve(FSPath("/usr/lib64/libping.so"), root), FSError);
}