From 4b70f9d213e8cb71bc225a73494625e31dfaa721 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 4 Dec 2014 23:05:44 +0100 Subject: util/DivideString: add option "strip" --- test/DivideStringTest.hxx | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test') diff --git a/test/DivideStringTest.hxx b/test/DivideStringTest.hxx index 83c54dc56..f6c01bdde 100644 --- a/test/DivideStringTest.hxx +++ b/test/DivideStringTest.hxx @@ -15,6 +15,7 @@ class DivideStringTest : public CppUnit::TestFixture { CPPUNIT_TEST(TestBasic); CPPUNIT_TEST(TestEmpty); CPPUNIT_TEST(TestFail); + CPPUNIT_TEST(TestStrip); CPPUNIT_TEST_SUITE_END(); public: @@ -41,4 +42,13 @@ public: const DivideString ds(input, '.'); CPPUNIT_ASSERT(!ds.IsDefined()); } + + void TestStrip() { + constexpr char input[] = " foo\t.\nbar\r"; + const DivideString ds(input, '.', true); + CPPUNIT_ASSERT(ds.IsDefined()); + CPPUNIT_ASSERT(!ds.IsEmpty()); + CPPUNIT_ASSERT_EQUAL(0, strcmp(ds.GetFirst(), "foo")); + CPPUNIT_ASSERT_EQUAL(input + 7, ds.GetSecond()); + } }; -- cgit v1.2.3