From 8f0390dfa6d66ed322f6d4ad2306353c1669bfac Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 1 Jun 2018 01:23:55 +0300 Subject: Remove redundant assertion in path_match(path, path, dir_path) --- tests/wildcard/driver.cxx | 61 ++++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 27 deletions(-) (limited to 'tests/wildcard') diff --git a/tests/wildcard/driver.cxx b/tests/wildcard/driver.cxx index bbe75a8..cecee07 100644 --- a/tests/wildcard/driver.cxx +++ b/tests/wildcard/driver.cxx @@ -172,38 +172,45 @@ try else path_search (pattern, *entry, add, start); - // Test search in the directory tree represented by the path. + // It the search succeeds, then test search in the directory tree + // represented by each matched path. Otherwise, if the directory tree is + // specified, then make sure that it doesn't match the pattern. // - for (const auto& p: path_count) + if (!path_count.empty ()) { - // Will match multiple times if the pattern contains several recursive - // components. - // - size_t match_count (0); - - auto check = [&p, &match_count] (path&& pe, const string&, bool interim) + for (const auto& p: path_count) { - if (pe == p.first) + // Will match multiple times if the pattern contains several recursive + // components. + // + size_t match_count (0); + + auto check = [&p, &match_count] (path&& pe, const string&, bool inter) { - if (!interim) - ++match_count; - else - // For self-matching the callback is first called in the interim - // mode (through the preopen function) with an empty path. - // - assert (pe.empty ()); - } - - return true; - }; - - path_search (pattern, p.first, check, start); - assert (match_count == p.second); - - // Test path match. - // - assert (path_match (pattern, p.first, start)); + if (pe == p.first) + { + if (!inter) + ++match_count; + else + // For self-matching the callback is first called in the interim + // mode (through the preopen function) with an empty path. + // + assert (pe.empty ()); + } + + return true; + }; + + path_search (pattern, p.first, check, start); + assert (match_count == p.second); + + // Test path match. + // + assert (path_match (pattern, p.first, start)); + } } + else if (entry) + assert (!path_match (pattern, *entry, start)); // Print the found paths. // -- cgit v1.1