diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-06-25 22:59:01 +0000 |
---|---|---|
committer | <> | 2013-09-27 11:49:28 +0000 |
commit | 8c4528713d907ee2cfd3bfcbbad272c749867f84 (patch) | |
tree | c09e2ce80f47b90c85cc720f5139089ad9c8cfff /libs/algorithm/test/empty_search_test.cpp | |
download | boost-tarball-baserock/morph.tar.gz |
Imported from /home/lorry/working-area/delta_boost-tarball/boost_1_54_0.tar.bz2.boost_1_54_0baserock/morph
Diffstat (limited to 'libs/algorithm/test/empty_search_test.cpp')
-rw-r--r-- | libs/algorithm/test/empty_search_test.cpp | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/libs/algorithm/test/empty_search_test.cpp b/libs/algorithm/test/empty_search_test.cpp new file mode 100644 index 000000000..22317f136 --- /dev/null +++ b/libs/algorithm/test/empty_search_test.cpp @@ -0,0 +1,81 @@ +/* + Copyright (c) Marshall Clow 2010-2012. + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + For more information, see http://www.boost.org +*/ + +#include <string> + +#include <boost/algorithm/searching/boyer_moore.hpp> +#include <boost/algorithm/searching/boyer_moore_horspool.hpp> +#include <boost/algorithm/searching/knuth_morris_pratt.hpp> + +#define BOOST_TEST_MAIN +#include <boost/test/unit_test.hpp> + +BOOST_AUTO_TEST_CASE( test_main ) +{ + const std::string cs; + std::string estr; + std::string str ( "abc" ); + +// empty corpus, empty pattern + BOOST_CHECK ( + boost::algorithm::boyer_moore_search ( + cs.begin (), cs.end (), estr.begin (), estr.end ()) + == cs.begin () + ); + + BOOST_CHECK ( + boost::algorithm::boyer_moore_horspool_search ( + cs.begin (), cs.end (), estr.begin (), estr.end ()) + == cs.begin () + ); + + BOOST_CHECK ( + boost::algorithm::knuth_morris_pratt_search ( + cs.begin (), cs.end (), estr.begin (), estr.end ()) + == cs.begin () + ); + +// empty corpus, non-empty pattern + BOOST_CHECK ( + boost::algorithm::boyer_moore_search ( + estr.begin (), estr.end (), str.begin (), str.end ()) + == estr.end () + ); + + BOOST_CHECK ( + boost::algorithm::boyer_moore_horspool_search ( + estr.begin (), estr.end (), str.begin (), str.end ()) + == estr.end () + ); + + BOOST_CHECK ( + boost::algorithm::knuth_morris_pratt_search ( + estr.begin (), estr.end (), str.begin (), str.end ()) + == estr.end () + ); + +// non-empty corpus, empty pattern + BOOST_CHECK ( + boost::algorithm::boyer_moore_search ( + str.begin (), str.end (), estr.begin (), estr.end ()) + == str.begin () + ); + + BOOST_CHECK ( + boost::algorithm::boyer_moore_horspool_search ( + str.begin (), str.end (), estr.begin (), estr.end ()) + == str.begin () + ); + + BOOST_CHECK ( + boost::algorithm::knuth_morris_pratt_search ( + str.begin (), str.end (), estr.begin (), estr.end ()) + == str.begin () + ); +} |