RE: [Cppunit-devel] regular expression match
Brought to you by:
blep
From: Arlo B. <arl...@ho...> - 2002-04-10 16:01:30
|
I've been using the boost libraries for a while, including their regexp stuff. If you're looking for a regexp library, I'd recommend Boost's. In particular, it works well with STLPort, which means that the list of currently supported platforms includes all Windows, Mac OS X, Mac OS 6.something +, a few dozen Linux distros, most Unixes, Amiga, PS2, XBox, and so on. You don't have to worry about platform availability, although you do have to ensure that the developer installs the STLPort and Boost libraries. Likewise, he boost regex was built with Unicode in mind. It performs all matching using char_traits, so should internationalize as well as the rest of the STL (YMMV). It supports most digraphs, and matches umlauted, accented, and otherwise modified characters correctly. I expect it to work with the Asian, Arabic and Hebrew languages, but don't really know. Additionally, it uses a pretty full regex syntax, similar to Perl's. I haven't found much missing, although the regex strings end up as even more line noise than they do in Perl, because you have to escape the backslash character past the C++ processor any time that you put in an escape sequence. There is a learning curve on the boost regexp - it tries to expose a completely generalized interface, which leads to complexity. As most STL things, it defines algorithms that operates on ranges, which means that you can trivially use it to match not only on a string, but also on any container, on files directly, or an a wrapped stream (it requires on bi-directional iterators, so you can't just match on cin directly). However, this adds some complexity to its use - there are lots of results classes, templates, and syntactical garbage to keep track of. For the purposes of CppUnit, you are really only looking for a match / no match result, so you could easily wrap it all in a functor which returns a bool. Then a simple macro to assert on that, and voila. Note, however, the use of you in that sentence. Sorry guys, but I've got a ship date coming up at work, and won't be able to get around to just writing this for a while. Another option would be to have a family of such functors that use the various regex libraries, and have CppUnit select one based on what libs are installed on the developer's machine (either statically or dynamically). I don't know how feasible it would be to check for support on other platforms (haven't tried it), but it's trivial to tell whether Boost & STLPort are installed on a Window box, as they are both DLLs. In any case, static config is simple enough. I agree that it would be good to have these two projects become involved with each other. Note, however, that CppUnit isn't really architected in the way that they're planning to build the test library. Probably both sides will change on this one - as Steve pointed out, they don't have an implementation. Arlo > -----Original Message----- > From: cpp...@li... > > I haven't any real opinion on adding regular expression matching > to CppUnit. I presume one could always call their own favourite > regex matcher wrapped up in CPPUNIT_ASSERT without too much trouble. > > However, since you mentioned the BOOST libraries, I wonder if you have > looked at their implementations of concept checking and testing? The > web page (www.boost.org) indicates that there is not yet any unit test > library. The BOOST code is pretty well designed and the mailing list > is full of very bright people. So it would be a boon to have CppUnit > involved with them. > > I haven't looked at any of this stuff, myself. Has anyone else? |