aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-20 13:55:19 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-20 16:20:41 +0000
commit98f23a28abc8d6e4c266c0700b432bfc599fc1ef (patch)
treed7e1f71af9056135e85363e2f2b8278b6c95f222
parent7fcad905fc123550bf03e02ff069aedabdb6e7b0 (diff)
downloadpaludis-98f23a28abc8d6e4c266c0700b432bfc599fc1ef.tar.gz
paludis-98f23a28abc8d6e4c266c0700b432bfc599fc1ef.tar.xz
gtest more
-rw-r--r--paludis/util/files.m42
-rw-r--r--paludis/util/string_list_stream_TEST.cc69
2 files changed, 29 insertions, 42 deletions
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4
index c4b1733..b48f5fd 100644
--- a/paludis/util/files.m4
+++ b/paludis/util/files.m4
@@ -79,7 +79,7 @@ add(`sha256', `hh', `cc', `test')
add(`simple_parser', `hh', `cc', `test', `fwd')
add(`singleton', `hh', `impl', `test')
add(`stringify', `hh', `test')
-add(`string_list_stream', `hh', `cc', `fwd', `test')
+add(`string_list_stream', `hh', `cc', `fwd', `gtest')
add(`strip', `hh', `cc', `gtest')
add(`system', `hh', `cc', `gtest')
add(`tail_output_stream', `hh', `cc', `fwd', `gtest')
diff --git a/paludis/util/string_list_stream_TEST.cc b/paludis/util/string_list_stream_TEST.cc
index c39be1b..f71a8f0 100644
--- a/paludis/util/string_list_stream_TEST.cc
+++ b/paludis/util/string_list_stream_TEST.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2009, 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
@@ -19,11 +19,12 @@
#include <paludis/util/string_list_stream.hh>
#include <paludis/util/thread.hh>
-#include <test/test_runner.hh>
-#include <test/test_framework.hh>
+#include <paludis/util/stringify.hh>
+
#include <functional>
-using namespace test;
+#include <gtest/gtest.h>
+
using namespace paludis;
namespace
@@ -40,52 +41,38 @@ namespace
}
}
-namespace test_cases
+TEST(StringListStream, Works)
{
- struct StringListStreamTest : TestCase
- {
- StringListStreamTest() : TestCase("string list stream") { }
+ StringListStream s;
+ s << "foo" << std::endl << "bar" << std::endl << "baz" << std::endl;
+ s.nothing_more_to_write();
- void run()
- {
- StringListStream s;
- s << "foo" << std::endl << "bar" << std::endl << "baz" << std::endl;
- s.nothing_more_to_write();
+ std::string l;
- std::string l;
+ ASSERT_TRUE(std::getline(s, l));
+ EXPECT_EQ("foo", l);
- TEST_CHECK(std::getline(s, l));
- TEST_CHECK_EQUAL(l, "foo");
+ ASSERT_TRUE(std::getline(s, l));
+ EXPECT_EQ("bar", l);
- TEST_CHECK(std::getline(s, l));
- TEST_CHECK_EQUAL(l, "bar");
+ ASSERT_TRUE(std::getline(s, l));
+ EXPECT_EQ("baz", l);
- TEST_CHECK(std::getline(s, l));
- TEST_CHECK_EQUAL(l, "baz");
+ ASSERT_TRUE(! std::getline(s, l));
+}
- TEST_CHECK(! std::getline(s, l));
- }
- } test_string_list_stream;
+TEST(StringListStream, Threads)
+{
+ StringListStream s;
+ Thread t(std::bind(&write_to, std::ref(s)));
- struct StringListStreamThreadsTest : TestCase
+ std::string l;
+ for (int n(0) ; n < 100 ; ++n)
{
- StringListStreamThreadsTest() : TestCase("string list stream threads") { }
+ ASSERT_TRUE(std::getline(s, l));
+ EXPECT_EQ(stringify(n), l);
+ }
- void run()
- {
- StringListStream s;
- Thread t(std::bind(&write_to, std::ref(s)));
-
- std::string l;
- for (int n(0) ; n < 100 ; ++n)
- {
- TestMessageSuffix sx(stringify(n));
- TEST_CHECK(std::getline(s, l));
- TEST_CHECK_EQUAL(l, stringify(n));
- }
-
- TEST_CHECK(! std::getline(s, l));
- }
- } test_string_list_stream_thread;
+ ASSERT_TRUE(! std::getline(s, l));
}