summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Leigh <rleigh@debian.org>2013-09-08 10:55:00 +0100
committerRoger Leigh <rleigh@debian.org>2013-09-08 18:17:30 +0100
commit836318f6be5158638cdeff66f1ca5975698d9dac (patch)
tree9be1a064fe2e2d3d93820faaf0eac723d1b8f8f3
parent47b573a4dc2b30b10b8bdec3d790107eed683891 (diff)
downloadschroot-836318f6be5158638cdeff66f1ca5975698d9dac.tar.gz
test: Convert test/sbuild/run-parts to use gtest
-rw-r--r--test/Makefile.am2
-rw-r--r--test/sbuild/run-parts.cc138
2 files changed, 59 insertions, 81 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index 23759b1e..7fba775a 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -172,7 +172,7 @@ test_sbuild_regex_SOURCES = test/sbuild/regex.cc
test_sbuild_regex_LDADD = lib/test/libtest2.la
test_sbuild_run_parts_SOURCES = test/sbuild/run-parts.cc
-test_sbuild_run_parts_LDADD = lib/test/libtest.la
+test_sbuild_run_parts_LDADD = lib/test/libtest2.la
test_sbuild_util_SOURCES = test/sbuild/util.cc
test_sbuild_util_LDADD = lib/test/libtest2.la
diff --git a/test/sbuild/run-parts.cc b/test/sbuild/run-parts.cc
index 225fc56f..397977bc 100644
--- a/test/sbuild/run-parts.cc
+++ b/test/sbuild/run-parts.cc
@@ -16,6 +16,8 @@
*
*********************************************************************/
+#include <gtest/gtest.h>
+
#include <sbuild/nostream.h>
#include <sbuild/run-parts.h>
#include <sbuild/util.h>
@@ -25,108 +27,84 @@
#include <boost/filesystem/operations.hpp>
-#include <cppunit/extensions/HelperMacros.h>
-
-using namespace CppUnit;
-
-class test_run_parts : public TestFixture
+class RunParts : public ::testing::Test
{
- CPPUNIT_TEST_SUITE(test_run_parts);
- CPPUNIT_TEST(test_construction);
- CPPUNIT_TEST_EXCEPTION(test_construction_fail, boost::filesystem::filesystem_error);
- CPPUNIT_TEST(test_run);
- CPPUNIT_TEST(test_run2);
- CPPUNIT_TEST(test_run3);
- CPPUNIT_TEST_SUITE_END();
-
+public:
std::streambuf *saved;
sbuild::basic_nbuf<char> *monitor;
-public:
- test_run_parts():
- TestFixture()
- {}
-
- void setUp()
- {
- this->monitor = new sbuild::basic_nbuf<char>();
- this->saved = std::cerr.std::ios::rdbuf(this->monitor);
- }
-
- void tearDown()
- {
- std::cerr.std::ios::rdbuf(this->saved);
- delete this->monitor;
- }
-
-
- virtual ~test_run_parts()
- {}
-
- void
- test_construction()
+ void SetUp()
{
- sbuild::run_parts rp(TESTDATADIR "/run-parts.ex1");
+ monitor = new sbuild::basic_nbuf<char>();
+ saved = std::cerr.std::ios::rdbuf(monitor);
}
- void
- test_construction_fail()
+ void TearDown()
{
- sbuild::run_parts rp(TESTDATADIR "/invalid_dir");
+ std::cerr.std::ios::rdbuf(saved);
+ delete monitor;
}
+};
- void test_run()
- {
- sbuild::run_parts rp(TESTDATADIR "/run-parts.ex1");
+TEST_F(RunParts, Construct)
+{
+ ASSERT_NO_THROW(sbuild::run_parts rp(TESTDATADIR "/run-parts.ex1"));
+}
- int status;
+TEST_F(RunParts, ConstructFail)
+{
+ ASSERT_THROW(sbuild::run_parts rp(TESTDATADIR "/invalid_dir"),
+ boost::filesystem::filesystem_error);
+}
- sbuild::string_list command;
- sbuild::environment env(environ);
+TEST_F(RunParts, Run1)
+{
+ sbuild::run_parts rp(TESTDATADIR "/run-parts.ex1");
- command.push_back("ok");
- status = rp.run(command, env);
- CPPUNIT_ASSERT(status == EXIT_SUCCESS);
+ int status;
- command.clear();
- command.push_back("fail");
- status = rp.run(command, env);
- CPPUNIT_ASSERT(status == EXIT_FAILURE);
+ sbuild::string_list command;
+ sbuild::environment env(environ);
- command.clear();
- command.push_back("fail2");
- status = rp.run(command, env);
- CPPUNIT_ASSERT(status == EXIT_FAILURE);
- }
+ command.push_back("ok");
+ status = rp.run(command, env);
+ ASSERT_EQ(status, EXIT_SUCCESS);
- void test_run2()
- {
- sbuild::run_parts rp(TESTDATADIR "/run-parts.ex2");
+ command.clear();
+ command.push_back("fail");
+ status = rp.run(command, env);
+ ASSERT_EQ(status, EXIT_FAILURE);
- int status;
+ command.clear();
+ command.push_back("fail2");
+ status = rp.run(command, env);
+ ASSERT_EQ(status, EXIT_FAILURE);
+}
- sbuild::string_list command;
- sbuild::environment env(environ);
+TEST_F(RunParts, Run2)
+{
+ sbuild::run_parts rp(TESTDATADIR "/run-parts.ex2");
- command.push_back("ok");
- status = rp.run(command, env);
- CPPUNIT_ASSERT(status == EXIT_SUCCESS);
- }
+ int status;
- void test_run3()
- {
- sbuild::run_parts rp(TESTDATADIR "/run-parts.ex3");
+ sbuild::string_list command;
+ sbuild::environment env(environ);
- int status;
+ command.push_back("ok");
+ status = rp.run(command, env);
+ ASSERT_EQ(status, EXIT_SUCCESS);
+}
- sbuild::string_list command;
- sbuild::environment env(environ);
+TEST_F(RunParts, Run3)
+{
+ sbuild::run_parts rp(TESTDATADIR "/run-parts.ex3");
- command.push_back("ok");
- status = rp.run(command, env);
- CPPUNIT_ASSERT(status == EXIT_FAILURE);
- }
+ int status;
-};
+ sbuild::string_list command;
+ sbuild::environment env(environ);
-CPPUNIT_TEST_SUITE_REGISTRATION(test_run_parts);
+ command.push_back("ok");
+ status = rp.run(command, env);
+ ASSERT_EQ(status, EXIT_FAILURE);
+}