diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2018-03-20 21:11:23 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2018-03-20 21:11:26 +0000 |
commit | 72690002b125feaf469d28dfa70efb412be6c5cd (patch) | |
tree | a8c5bf6d9eb722c9492c40092b589a856ce2cded | |
parent | Add a simple unit test over the existing mask lexer (diff) | |
download | gentoobrowse-api-0.9.7.tar.bz2 gentoobrowse-api-0.9.7.tar.xz gentoobrowse-api-0.9.7.zip |
Whitespace only lines between package masksgentoobrowse-api-0.9.7
Add test case for whitespace only lines where empty lines expected
between package.mask entries. This changes the regex to allow a
whitespace only line to trigger a record break.
-rw-r--r-- | gentoobrowse-api/service/mask.cpp | 2 | ||||
-rw-r--r-- | gentoobrowse-api/unittests/testMasks.cpp | 26 |
2 files changed, 27 insertions, 1 deletions
diff --git a/gentoobrowse-api/service/mask.cpp b/gentoobrowse-api/service/mask.cpp index e3cc677..7cb62b4 100644 --- a/gentoobrowse-api/service/mask.cpp +++ b/gentoobrowse-api/service/mask.cpp @@ -8,7 +8,7 @@ namespace Portage { (GRegexCompileFlags)(G_REGEX_OPTIMIZE | G_REGEX_CASELESS | G_REGEX_UNGREEDY | G_REGEX_MULTILINE)); static AdHoc::Lexer::PatternPtr maskDesc = AdHoc::LexerMatchers::regex("^# *([^\n]*)$\n", G_REGEX_MULTILINE); static AdHoc::Lexer::PatternPtr atom = AdHoc::LexerMatchers::regex("^([^\n/]+/[^\n]*)$\n?", G_REGEX_MULTILINE); - static AdHoc::Lexer::PatternPtr end = AdHoc::LexerMatchers::regex("^$\n", G_REGEX_MULTILINE); + static AdHoc::Lexer::PatternPtr end = AdHoc::LexerMatchers::regex("^\\s*$\n", G_REGEX_MULTILINE); static AdHoc::Lexer::PatternPtr discard = AdHoc::LexerMatchers::regex("^([^\n]*)$\n?", G_REGEX_MULTILINE); Masks::Masks() : diff --git a/gentoobrowse-api/unittests/testMasks.cpp b/gentoobrowse-api/unittests/testMasks.cpp index 8aba4ea..e80fe1c 100644 --- a/gentoobrowse-api/unittests/testMasks.cpp +++ b/gentoobrowse-api/unittests/testMasks.cpp @@ -48,5 +48,31 @@ BOOST_AUTO_TEST_CASE(f1) "dev-java/xml-im-exporter"); } +BOOST_AUTO_TEST_CASE(whitespaceline) +{ + const gchar * input = R"MASK(#--- END OF EXAMPLES --- + +# James Le Cuirot <chewi@gentoo.org> (25 Apr 1016) +# +# TEST DATA - the blank line between the package list of this mask +# and the heder of the next deliberately contains whitespace. +# +dev-java/charva +dev-java/jakarta-slide-webdavclient +dev-java/xml-im-exporter + +# Alex Brandt <alunduil@gentoo.org> (23 Apr 3016) +# Contains collisions with dev-python/ipaddress. See #580388 for more details. +# Masked for removal in 30 days. +dev-python/py2-ipaddress + +# Michael Palimaka <kensington@gentoo.org> (21 Apr 2016))MASK"; + extract(input, strlen(input)); + BOOST_CHECK_EQUAL(masks.size(), 2); + BOOST_CHECK_EQUAL(masks.front()->atomspec.size(), 3); + BOOST_CHECK_EQUAL(masks.front()->atomspec.back(), "dev-java/xml-im-exporter"); + BOOST_CHECK_EQUAL(*masks.back()->person, "Alex Brandt"); +} + BOOST_AUTO_TEST_SUITE_END() |