aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-20 20:50:52 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-20 20:50:52 +0000
commit23a06f370f70dad816795a9667aee5057440a232 (patch)
treec09f6a1b0137d687f0c7c2eb544e6801fdb13d3a
parentd2be10be107c51ac1565bc5c1bf4b18f1c288479 (diff)
downloadpaludis-23a06f370f70dad816795a9667aee5057440a232.tar.gz
paludis-23a06f370f70dad816795a9667aee5057440a232.tar.xz
gtest more
-rw-r--r--paludis/Makefile.am.m416
-rw-r--r--paludis/about_TEST.cc75
-rw-r--r--paludis/files.m42
3 files changed, 39 insertions, 54 deletions
diff --git a/paludis/Makefile.am.m4 b/paludis/Makefile.am.m4
index 5c116fb..3b19ce5 100644
--- a/paludis/Makefile.am.m4
+++ b/paludis/Makefile.am.m4
@@ -7,6 +7,7 @@ include $(top_srcdir)/misc/common-makefile.am
define(`filelist', `')dnl
define(`testlist', `')dnl
+define(`gtestlist', `')dnl
define(`headerlist', `')dnl
define(`selist', `')dnl
define(`secleanlist', `')dnl
@@ -21,6 +22,16 @@ $1_TEST_LDADD = \
$(DYNAMIC_LD_LIBS)
$1_TEST_CXXFLAGS = -I$(top_srcdir) $(AM_CXXFLAGS) @PALUDIS_CXXFLAGS_NO_DEBUGGING@
')dnl
+define(`addgtest', `define(`gtestlist', gtestlist `$1_TEST')dnl
+$1_TEST_SOURCES = $1_TEST.cc
+$1_TEST_LDADD = \
+ $(top_builddir)/paludis/util/gtest_runner.o \
+ libpaludis_@PALUDIS_PC_SLOT@.la \
+ $(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \
+ $(DYNAMIC_LD_LIBS)
+$1_TEST_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@
+$1_TEST_CXXFLAGS = -I$(top_srcdir) $(AM_CXXFLAGS) @PALUDIS_CXXFLAGS_NO_DEBUGGING@ @GTESTDEPS_CXXFLAGS@
+')dnl
define(`addtestscript', `define(`testscriptlist', testscriptlist `$1_TEST_setup.sh $1_TEST_cleanup.sh')')dnl
define(`addhh', `define(`filelist', filelist `$1.hh')define(`headerlist', headerlist `$1.hh')')dnl
define(`addfwd', `define(`filelist', filelist `$1-fwd.hh')define(`headerlist', headerlist `$1-fwd.hh')')dnl
@@ -45,6 +56,7 @@ ifelse(`$2', `cc', `addcc(`$1')', `')dnl
ifelse(`$2', `se', `addse(`$1')', `')dnl
ifelse(`$2', `impl', `addimpl(`$1')', `')dnl
ifelse(`$2', `test', `addtest(`$1')', `')dnl
+ifelse(`$2', `gtest', `addgtest(`$1')', `')dnl
ifelse(`$2', `testscript', `addtestscript(`$1')', `')')dnl
define(`add', `addthis(`$1',`$2')addthis(`$1',`$3')addthis(`$1',`$4')dnl
addthis(`$1',`$5')addthis(`$1',`$6')addthis(`$1',`$7')addthis(`$1',`$8')')dnl
@@ -127,7 +139,11 @@ libpaludis_@PALUDIS_PC_SLOT@_la_LIBADD = \
@DYNAMIC_LD_LIBS@ \
$(PTHREAD_LIBS)
+if HAVE_GTEST
+TESTS = testlist gtestlist
+else
TESTS = testlist
+endif
check_PROGRAMS = $(TESTS) stripper_TEST_binary
check_SCRIPTS = testscriptlist
diff --git a/paludis/about_TEST.cc b/paludis/about_TEST.cc
index de0091b..c4110b9 100644
--- a/paludis/about_TEST.cc
+++ b/paludis/about_TEST.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 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
@@ -18,66 +18,35 @@
*/
#include <paludis/about.hh>
-#include <test/test_framework.hh>
-#include <test/test_runner.hh>
-using namespace test;
-using namespace paludis;
+#include <gtest/gtest.h>
-/**
- * \file
- * Test cases for about.hh .
- *
- */
-
-namespace test_cases
+TEST(About, Version)
{
- /**
- * \test Version tests.
- *
- */
- struct VersionTest : TestCase
- {
- VersionTest() : TestCase("about test") { }
-
- void run()
- {
- TEST_CHECK(PALUDIS_VERSION_MAJOR >= 0);
- TEST_CHECK(PALUDIS_VERSION_MAJOR <= 9);
+ EXPECT_TRUE(PALUDIS_VERSION_MAJOR >= 0);
+ EXPECT_TRUE(PALUDIS_VERSION_MAJOR <= 9);
- TEST_CHECK(PALUDIS_VERSION_MINOR >= 0);
- TEST_CHECK(PALUDIS_VERSION_MINOR <= 99);
+ EXPECT_TRUE(PALUDIS_VERSION_MINOR >= 0);
+ EXPECT_TRUE(PALUDIS_VERSION_MINOR <= 99);
- TEST_CHECK(PALUDIS_VERSION_MICRO >= 0);
- TEST_CHECK(PALUDIS_VERSION_MICRO <= 99);
+ EXPECT_TRUE(PALUDIS_VERSION_MICRO >= 0);
+ EXPECT_TRUE(PALUDIS_VERSION_MICRO <= 99);
- TEST_CHECK(PALUDIS_VERSION >= 0);
- TEST_CHECK(PALUDIS_VERSION <= 99999);
- TEST_CHECK_EQUAL(PALUDIS_VERSION, 10000 * PALUDIS_VERSION_MAJOR +
- 100 * PALUDIS_VERSION_MINOR + PALUDIS_VERSION_MICRO);
+ EXPECT_TRUE(PALUDIS_VERSION >= 0);
+ EXPECT_TRUE(PALUDIS_VERSION <= 99999);
+ EXPECT_EQ(PALUDIS_VERSION, 10000 * PALUDIS_VERSION_MAJOR + 100 * PALUDIS_VERSION_MINOR + PALUDIS_VERSION_MICRO);
- TEST_CHECK(std::string(PALUDIS_GIT_HEAD) != "i am a fish");
- }
- } test_case_about;
-
- /**
- * \test Build info tests.
- *
- */
- struct BuildInfoTest : TestCase
- {
- BuildInfoTest() : TestCase("build info test") { }
+ EXPECT_TRUE(std::string(PALUDIS_GIT_HEAD) != "i am a fish");
+}
- void run()
- {
- TEST_CHECK(! std::string(PALUDIS_BUILD_CXX).empty());
- TEST_CHECK(! std::string(PALUDIS_BUILD_CXXFLAGS).empty());
- TEST_CHECK(std::string(PALUDIS_BUILD_LDFLAGS) != "i am a fish");
+TEST(About, BuildInfo)
+{
+ EXPECT_TRUE(! std::string(PALUDIS_BUILD_CXX).empty());
+ EXPECT_TRUE(! std::string(PALUDIS_BUILD_CXXFLAGS).empty());
+ EXPECT_TRUE(std::string(PALUDIS_BUILD_LDFLAGS) != "i am a fish");
- TEST_CHECK(! std::string(PALUDIS_BUILD_USER).empty());
- TEST_CHECK(! std::string(PALUDIS_BUILD_HOST).empty());
- TEST_CHECK(! std::string(PALUDIS_BUILD_DATE).empty());
- }
- } test_case_build_info;
+ EXPECT_TRUE(! std::string(PALUDIS_BUILD_USER).empty());
+ EXPECT_TRUE(! std::string(PALUDIS_BUILD_HOST).empty());
+ EXPECT_TRUE(! std::string(PALUDIS_BUILD_DATE).empty());
}
diff --git a/paludis/files.m4 b/paludis/files.m4
index fc99f9b..79be05b 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -8,7 +8,7 @@ dnl the base filename with no extension; later parameters can be `hh', `cc',
dnl `test', `impl', `testscript'. Note that there isn't much error checking done
dnl on this file at present...
-add(`about', `hh', `test')
+add(`about', `hh', `gtest')
add(`about_metadata', `hh', `cc', `fwd')
add(`action', `hh', `cc', `fwd', `se')
add(`action_names', `hh', `cc', `fwd')