diff options
author | Daniel Burrows <dburrows@debian.org> | 2010-03-21 09:46:15 -0700 |
---|---|---|
committer | Daniel Burrows <dburrows@debian.org> | 2010-03-21 09:46:15 -0700 |
commit | 15a74c9c8702878f1fd01ced757df9d723031f52 (patch) | |
tree | 45d081cb1b5c4ecdea74f88428cb9d22553cb334 /tests/test_parsers.cc | |
parent | 6640dcf3e7973afc659d229b2725ac86e12f4b62 (diff) | |
download | aptitude-15a74c9c8702878f1fd01ced757df9d723031f52.tar.gz |
Add an explicit test that trailing separators don't confuse the parse library.
Diffstat (limited to 'tests/test_parsers.cc')
-rw-r--r-- | tests/test_parsers.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/test_parsers.cc b/tests/test_parsers.cc index 5fb9b707..6770e45a 100644 --- a/tests/test_parsers.cc +++ b/tests/test_parsers.cc @@ -114,6 +114,7 @@ class ParsersTest : public CppUnit::TestFixture CPPUNIT_TEST(testSepByFailureInFirstElement); CPPUNIT_TEST(testSepByFailureInSeparator); CPPUNIT_TEST(testSepByFailureInSecondElement); + CPPUNIT_TEST(testSepByTrailingSeparator); CPPUNIT_TEST(testLexemeSuccess); CPPUNIT_TEST(testLexemeFailure); CPPUNIT_TEST(testBetweenSuccess); @@ -1350,6 +1351,17 @@ public: } } + void testSepByTrailingSeparator() + { + { + std::string input = "ab,cd,"; + std::string::const_iterator begin = input.begin(), end = input.end(); + + CPPUNIT_ASSERT_THROW(sepBy(str(","), manyOne(alpha())).parse(begin, end), ParseException); + CPPUNIT_ASSERT_EQUAL((iter_difftype)6, begin - input.begin()); + } + } + void testLexemeSuccess() { { |