aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-20 13:29:17 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-20 16:20:41 +0000
commitf0bb05ff116fe202b5071091125411b28ba6b782 (patch)
treee4bac265f35d49d2244278a026b6157e7af1a766
parent03cf08854d9c1afcf5ad004e32d73411555237a3 (diff)
downloadpaludis-f0bb05ff116fe202b5071091125411b28ba6b782.tar.gz
paludis-f0bb05ff116fe202b5071091125411b28ba6b782.tar.xz
gtest more
-rw-r--r--paludis/util/files.m42
-rw-r--r--paludis/util/tail_output_stream_TEST.cc101
2 files changed, 47 insertions, 56 deletions
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4
index bb016aa..0169ce8 100644
--- a/paludis/util/files.m4
+++ b/paludis/util/files.m4
@@ -82,7 +82,7 @@ add(`stringify', `hh', `test')
add(`string_list_stream', `hh', `cc', `fwd', `test')
add(`strip', `hh', `cc', `test')
add(`system', `hh', `cc', `test')
-add(`tail_output_stream', `hh', `cc', `fwd', `test')
+add(`tail_output_stream', `hh', `cc', `fwd', `gtest')
add(`tee_output_stream', `hh', `cc', `fwd')
add(`thread', `hh', `cc', `gtest')
add(`thread_pool', `hh', `cc', `gtest')
diff --git a/paludis/util/tail_output_stream_TEST.cc b/paludis/util/tail_output_stream_TEST.cc
index 24c71c0..e500236 100644
--- a/paludis/util/tail_output_stream_TEST.cc
+++ b/paludis/util/tail_output_stream_TEST.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 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
@@ -20,64 +20,55 @@
#include <paludis/util/tail_output_stream.hh>
#include <paludis/util/join.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
-#include <test/test_framework.hh>
-#include <test/test_runner.hh>
+
+#include <gtest/gtest.h>
using namespace paludis;
-using namespace test;
-namespace test_cases
+TEST(TailOutputStream, Works)
{
- struct TailOutputStreamTest : TestCase
+ TailOutputStream s(5);
+
+ {
+ std::shared_ptr<const Sequence<std::string> > a(s.tail(false));
+ EXPECT_EQ("", join(a->begin(), a->end(), "/"));
+ }
+
+ s << "one" << std::endl;
+
+ {
+ std::shared_ptr<const Sequence<std::string> > a(s.tail(false));
+ EXPECT_EQ("one", join(a->begin(), a->end(), "/"));
+ }
+
+ s << "two" << std::endl;
+ s << "three" << std::endl;
+ s << "four" << std::endl;
+ s << "five" << std::endl;
+
+ {
+ std::shared_ptr<const Sequence<std::string> > a(s.tail(false));
+ EXPECT_EQ("one/two/three/four/five", join(a->begin(), a->end(), "/"));
+ }
+
+ s << "six" << std::endl;
+
+ {
+ std::shared_ptr<const Sequence<std::string> > a(s.tail(true));
+ EXPECT_EQ("two/three/four/five/six", join(a->begin(), a->end(), "/"));
+ }
+
+ {
+ std::shared_ptr<const Sequence<std::string> > a(s.tail(false));
+ EXPECT_EQ("", join(a->begin(), a->end(), "/"));
+ }
+
+ s << "seven" << std::endl;
+ s << "eight" << std::endl;
+
{
- TailOutputStreamTest() : TestCase("tail output stream") { }
-
- void run()
- {
- TailOutputStream s(5);
-
- {
- std::shared_ptr<const Sequence<std::string> > a(s.tail(false));
- TEST_CHECK_EQUAL(join(a->begin(), a->end(), "/"), "");
- }
-
- s << "one" << std::endl;
-
- {
- std::shared_ptr<const Sequence<std::string> > a(s.tail(false));
- TEST_CHECK_EQUAL(join(a->begin(), a->end(), "/"), "one");
- }
-
- s << "two" << std::endl;
- s << "three" << std::endl;
- s << "four" << std::endl;
- s << "five" << std::endl;
-
- {
- std::shared_ptr<const Sequence<std::string> > a(s.tail(false));
- TEST_CHECK_EQUAL(join(a->begin(), a->end(), "/"), "one/two/three/four/five");
- }
-
- s << "six" << std::endl;
-
- {
- std::shared_ptr<const Sequence<std::string> > a(s.tail(true));
- TEST_CHECK_EQUAL(join(a->begin(), a->end(), "/"), "two/three/four/five/six");
- }
-
- {
- std::shared_ptr<const Sequence<std::string> > a(s.tail(false));
- TEST_CHECK_EQUAL(join(a->begin(), a->end(), "/"), "");
- }
-
- s << "seven" << std::endl;
- s << "eight" << std::endl;
-
- {
- std::shared_ptr<const Sequence<std::string> > a(s.tail(false));
- TEST_CHECK_EQUAL(join(a->begin(), a->end(), "/"), "seven/eight");
- }
- }
- } test_tail_output_stream;
+ std::shared_ptr<const Sequence<std::string> > a(s.tail(false));
+ EXPECT_EQ("seven/eight", join(a->begin(), a->end(), "/"));
+ }
}