aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Mark Loeser <halcy0n@gentoo.org> 2006-01-19 04:35:21 +0000
committerAvatar Mark Loeser <halcy0n@gentoo.org> 2006-01-19 04:35:21 +0000
commitf399ff1a78164702d15ae2a153e6d35972b22e7d (patch)
tree79b2c59c19fda60278c420e5b90dd764d668b83b
parent816a7e448592c0719934b21c810195195d0940f1 (diff)
downloadpaludis-f399ff1a78164702d15ae2a153e6d35972b22e7d.tar.gz
paludis-f399ff1a78164702d15ae2a153e6d35972b22e7d.tar.xz
StripAdapter's member is no longer a reference. Add testcases for StripAdapter as well
-rw-r--r--paludis/strip.hh2
-rw-r--r--paludis/strip_TEST.cc81
2 files changed, 78 insertions, 5 deletions
diff --git a/paludis/strip.hh b/paludis/strip.hh
index 88dd973..b6983bc 100644
--- a/paludis/strip.hh
+++ b/paludis/strip.hh
@@ -21,7 +21,7 @@ namespace paludis
public std::unary_function<std::string, const std::string>
{
private:
- const std::string & _second;
+ const std::string _second;
public:
StripAdapter(const std::string & second) :
diff --git a/paludis/strip_TEST.cc b/paludis/strip_TEST.cc
index 12b7f3f..8bc924b 100644
--- a/paludis/strip_TEST.cc
+++ b/paludis/strip_TEST.cc
@@ -1,5 +1,23 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+/*
+ * Copyright (c) 2006 Mark Loeser <halcy0n@gentoo.org>
+ *
+ * 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
#include "strip.hh"
#include <test/test_framework.hh>
#include <test/test_runner.hh>
@@ -11,14 +29,69 @@ using namespace test;
namespace test_cases
{
- struct StripTest : TestCase
+ struct StripLeadingStringTest : TestCase
{
- StripTest() : TestCase("strip") { }
+ StripLeadingStringTest() : TestCase("StripLeadingString") { }
void run()
{
- /// \todo
+ StripLeadingString a("foo");
+
+ TEST_CHECK("bar" == a("foobar"));
+ TEST_CHECK("fishbar" == a("fishbar"));
+ TEST_CHECK("" == a("foo"));
+ TEST_CHECK("fishfoobar" == a("fishfoobar"));
+ TEST_CHECK("blahfoo" == a("blahfoo"));
}
- } test_strip;
+ } test_strip_leading_string;
+
+ struct StripLeadingTest : TestCase
+ {
+ StripLeadingTest() : TestCase("StripLeading") {}
+
+ void run()
+ {
+ StripLeading a("foo");
+
+ TEST_CHECK("bar" == a("foobar"));
+ TEST_CHECK("ishbar" == a("fishbar"));
+ TEST_CHECK("" == a("foo"));
+ TEST_CHECK("ishfoobar" == a("fishfoobar"));
+ TEST_CHECK("blahfoo" == a("blahfoo"));
+ }
+ } test_strip_leading;
+
+ struct StripTrailingStringTest : TestCase
+ {
+ StripTrailingStringTest() : TestCase("StripTrailingString") { }
+
+ void run()
+ {
+ StripTrailingString a("foo");
+
+ TEST_CHECK("foobar" == a("foobar"));
+ TEST_CHECK("fishbar" == a("fishbar"));
+ TEST_CHECK("" == a("foo"));
+ TEST_CHECK("fishfoobar" == a("fishfoobar"));
+ TEST_CHECK("blah" == a("blahfoo"));
+ }
+ } test_strip_trailing_string;
+
+ struct StripTrailingTest : TestCase
+ {
+ StripTrailingTest() : TestCase("StripTrailing") {}
+
+ void run()
+ {
+ StripTrailing a("foo");
+
+ TEST_CHECK("foobar" == a("foobar"));
+ TEST_CHECK("fishbar" == a("fishbar"));
+ TEST_CHECK("" == a("foo"));
+ TEST_CHECK("fishfoobar" == a("fishfoobar"));
+ TEST_CHECK("blah" == a("blahfoo"));
+ }
+ } test_strip_trailing;
+
}