From f0bb05ff116fe202b5071091125411b28ba6b782 Mon Sep 17 00:00:00 2001 From: Ciaran McCreesh Date: Sun, 20 Mar 2011 13:29:17 +0000 Subject: gtest more --- paludis/util/files.m4 | 2 +- paludis/util/tail_output_stream_TEST.cc | 101 +++++++++++++++----------------- 2 files changed, 47 insertions(+), 56 deletions(-) diff --git a/paludis/util/files.m4 b/paludis/util/files.m4 index bb016aa9f..0169ce813 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 24c71c0e8..e50023674 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 #include #include -#include -#include + +#include using namespace paludis; -using namespace test; -namespace test_cases +TEST(TailOutputStream, Works) { - struct TailOutputStreamTest : TestCase + TailOutputStream s(5); + + { + std::shared_ptr > a(s.tail(false)); + EXPECT_EQ("", join(a->begin(), a->end(), "/")); + } + + s << "one" << std::endl; + + { + std::shared_ptr > 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 > a(s.tail(false)); + EXPECT_EQ("one/two/three/four/five", join(a->begin(), a->end(), "/")); + } + + s << "six" << std::endl; + + { + std::shared_ptr > a(s.tail(true)); + EXPECT_EQ("two/three/four/five/six", join(a->begin(), a->end(), "/")); + } + + { + std::shared_ptr > 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 > a(s.tail(false)); - TEST_CHECK_EQUAL(join(a->begin(), a->end(), "/"), ""); - } - - s << "one" << std::endl; - - { - std::shared_ptr > 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 > a(s.tail(false)); - TEST_CHECK_EQUAL(join(a->begin(), a->end(), "/"), "one/two/three/four/five"); - } - - s << "six" << std::endl; - - { - std::shared_ptr > a(s.tail(true)); - TEST_CHECK_EQUAL(join(a->begin(), a->end(), "/"), "two/three/four/five/six"); - } - - { - std::shared_ptr > a(s.tail(false)); - TEST_CHECK_EQUAL(join(a->begin(), a->end(), "/"), ""); - } - - s << "seven" << std::endl; - s << "eight" << std::endl; - - { - std::shared_ptr > a(s.tail(false)); - TEST_CHECK_EQUAL(join(a->begin(), a->end(), "/"), "seven/eight"); - } - } - } test_tail_output_stream; + std::shared_ptr > a(s.tail(false)); + EXPECT_EQ("seven/eight", join(a->begin(), a->end(), "/")); + } } -- cgit v1.2.3