Boost logo

Boost :

From: Angus Leeming (angus.leeming_at_[hidden])
Date: 2004-09-24 16:42:57


Rob Stewart wrote:

> From: Angus Leeming <angus.leeming_at_[hidden]>
>>
>> Currently my 'test' directory contains:
>> $ ls .oo* foo*
>> foo1bar foo bar foo!bar foo]bar foo*bar foocbar foo.hpp
>> fooabar foo-bar foo?bar foo{bar foo\bar foo.cpp .oobar
>> foo^bar foo,bar foo[bar foo}bar foobbar foo.cxx
>>
>> All 20 of these files have zero size; the idea is to test boost::glob's
>> ability to find matches. However, I'd rather not have them as part of
>> the library. How do I get the test framework to create them for me
>> before running a test?
>
> I don't know how to do what you ask, but you need more cases than
> shown. You should test with special characters at the start,
> middle, and end of the filename. You might even test with them
> in those positions of the suffix and the rest of the filename.
> Also, you should test with longer filenames and with multiple
> suffixes.

I know, but it's a start.

The real work is actually done by Boost.Filesystem and Boost.Regex. All I
do is transform the glob into an equivalent regex using Boost.Spirit and
then loop recursively over the "pattern tree" to build up the list of
matching files. I think I've got all the corner cases covered, but the
test suite will evolve...

Regards,
Angus

PS, here's the test at the moment. "succeeded" means that the expected
number of matches were found.

$ ls -a
../../../bin/boost/libs/glob/test/test_glob.test/gcc/debug/glob_test_dir/
. fooabar foo-bar foo?bar foo{bar foobbar foo.cxx
.. foo^bar foo,bar foo[bar foo}bar foocbar foo.hpp
foo1bar foo bar foo!bar foo]bar foo*bar foo.cpp .oobar

$ ../../../bin/boost/libs/glob/test/test_glob.test/gcc/debug/test_glob
Matching glob_te*/fooabar succeeded. 1 match found.
Matching glob_te*/foo bar succeeded. 1 match found.
Matching glob_te*/foo?bar succeeded. 15 matches found.
Matching glob_te*/foo*bar succeeded. 15 matches found.
Matching glob_te*/?oo?bar succeeded. 15 matches found.
Matching glob_te*/*bar succeeded. 15 matches found.
Matching glob_te*/.*bar succeeded. 1 match found.
Matching glob_te*/foo[[:alpha:]]bar succeeded. 3 matches found.
Matching glob_te*/foo[!]bar succeeded. 0 matches found.
Matching glob_te*/foo[\!]bar succeeded. 1 match found.
Matching glob_te*/foo[!!]bar succeeded. 14 matches found.
Matching glob_te*/foo[]]bar succeeded. 1 match found.
Matching glob_te*/foo[!]]bar succeeded. 14 matches found.
Matching glob_te*/foo[a]]bar succeeded. 0 matches found.
Matching glob_te*/foo[]a]bar succeeded. 2 matches found.
Matching glob_te*/foo[^]bar succeeded. 1 match found.
Matching glob_te*/foo[\^]bar succeeded. 1 match found.
Matching glob_te*/foo[!^]bar succeeded. 14 matches found.
Matching glob_te*/foo[!\^]bar succeeded. 14 matches found.
Matching glob_te*/foo[*]bar succeeded. 1 match found.
Matching glob_te*/foo[\*]bar succeeded. 1 match found.
Matching glob_te*/foo[{]bar succeeded. 1 match found.
Matching glob_te*/foo[a-]bar succeeded. 2 matches found.
Matching glob_te*/foo[a-c]bar succeeded. 3 matches found.
Matching glob_te*/foo.{c{pp,xx},hpp} succeeded. 3 matches found.
Matching glob_te*/foo.{c*,hpp} succeeded. 3 matches found.

*** No errors detected


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk