aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-20 13:26:04 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-20 16:20:41 +0000
commit03cf08854d9c1afcf5ad004e32d73411555237a3 (patch)
tree1397d3fe626c948f3e0446113506c3b723851194
parentf8beb74bec8aab4eb0202872f91eddf0f38b8802 (diff)
downloadpaludis-03cf08854d9c1afcf5ad004e32d73411555237a3.tar.gz
paludis-03cf08854d9c1afcf5ad004e32d73411555237a3.tar.xz
gtest more
-rw-r--r--paludis/util/files.m44
-rw-r--r--paludis/util/thread_TEST.cc26
-rw-r--r--paludis/util/thread_pool_TEST.cc32
3 files changed, 23 insertions, 39 deletions
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4
index fe77068..bb016aa 100644
--- a/paludis/util/files.m4
+++ b/paludis/util/files.m4
@@ -84,8 +84,8 @@ add(`strip', `hh', `cc', `test')
add(`system', `hh', `cc', `test')
add(`tail_output_stream', `hh', `cc', `fwd', `test')
add(`tee_output_stream', `hh', `cc', `fwd')
-add(`thread', `hh', `cc', `test')
-add(`thread_pool', `hh', `cc', `test')
+add(`thread', `hh', `cc', `gtest')
+add(`thread_pool', `hh', `cc', `gtest')
add(`timestamp', `hh', `cc', `fwd')
add(`tokeniser', `hh', `cc', `gtest')
add(`tribool', `hh', `cc', `fwd', `gtest')
diff --git a/paludis/util/thread_TEST.cc b/paludis/util/thread_TEST.cc
index 355e5ac..daf2336 100644
--- a/paludis/util/thread_TEST.cc
+++ b/paludis/util/thread_TEST.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 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,11 +18,11 @@
*/
#include <paludis/util/thread.hh>
-#include <test/test_runner.hh>
-#include <test/test_framework.hh>
+
#include <time.h>
-using namespace test;
+#include <gtest/gtest.h>
+
using namespace paludis;
namespace
@@ -33,20 +33,12 @@ namespace
}
}
-namespace test_cases
+TEST(Thread, Works)
{
- struct ThreadTest : TestCase
+ bool x(false);
{
- ThreadTest() : TestCase("thread") { }
-
- void run()
- {
- bool x(false);
- {
- Thread t(std::bind(&make_true, std::ref(x)));
- }
- TEST_CHECK(x);
- }
- } test_thread;
+ Thread t(std::bind(&make_true, std::ref(x)));
+ }
+ EXPECT_TRUE(x);
}
diff --git a/paludis/util/thread_pool_TEST.cc b/paludis/util/thread_pool_TEST.cc
index c2eb9cc..3b51f20 100644
--- a/paludis/util/thread_pool_TEST.cc
+++ b/paludis/util/thread_pool_TEST.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 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,12 +18,12 @@
*/
#include <paludis/util/thread_pool.hh>
-#include <test/test_runner.hh>
-#include <test/test_framework.hh>
+
#include <vector>
#include <algorithm>
-using namespace test;
+#include <gtest/gtest.h>
+
using namespace paludis;
namespace
@@ -34,23 +34,15 @@ namespace
}
}
-namespace test_cases
+TEST(ThreadPool, Works)
{
- struct ThreadPoolTest : TestCase
+ const int n_threads = 10;
+ std::vector<int> t(n_threads, 0);
{
- ThreadPoolTest() : TestCase("thread pool") { }
-
- void run()
- {
- const int n_threads = 10;
- std::vector<int> t(n_threads, 0);
- {
- ThreadPool p;
- for (int x(0) ; x < n_threads ; ++x)
- p.create_thread(std::bind(&make_one, std::ref(t[x])));
- }
- TEST_CHECK(n_threads == std::count(t.begin(), t.end(), 1));
- }
- } test_thread_pool;
+ ThreadPool p;
+ for (int x(0) ; x < n_threads ; ++x)
+ p.create_thread(std::bind(&make_one, std::ref(t[x])));
+ }
+ ASSERT_TRUE(n_threads == std::count(t.begin(), t.end(), 1));
}