]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/algorithm/test/empty_search_test.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / algorithm / test / empty_search_test.cpp
1 /*
2 Copyright (c) Marshall Clow 2010-2012.
3
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6
7 For more information, see http://www.boost.org
8 */
9
10 #include <string>
11
12 #include <boost/algorithm/searching/boyer_moore.hpp>
13 #include <boost/algorithm/searching/boyer_moore_horspool.hpp>
14 #include <boost/algorithm/searching/knuth_morris_pratt.hpp>
15
16 #define BOOST_TEST_MAIN
17 #include <boost/test/unit_test.hpp>
18
19 BOOST_AUTO_TEST_CASE( test_main )
20 {
21 const std::string cs;
22 std::string estr;
23 std::string str ( "abc" );
24
25 // empty corpus, empty pattern
26 BOOST_CHECK (
27 boost::algorithm::boyer_moore_search (
28 cs.begin (), cs.end (), estr.begin (), estr.end ())
29 == std::make_pair(cs.begin(), cs.begin())
30 );
31
32 BOOST_CHECK (
33 boost::algorithm::boyer_moore_horspool_search (
34 cs.begin (), cs.end (), estr.begin (), estr.end ())
35 == std::make_pair(cs.begin(), cs.begin())
36 );
37
38 BOOST_CHECK (
39 boost::algorithm::knuth_morris_pratt_search (
40 cs.begin (), cs.end (), estr.begin (), estr.end ())
41 == std::make_pair(cs.begin(), cs.begin())
42 );
43
44 // empty corpus, non-empty pattern
45 BOOST_CHECK (
46 boost::algorithm::boyer_moore_search (
47 estr.begin (), estr.end (), str.begin (), str.end ())
48 == std::make_pair(estr.end(), estr.end())
49 );
50
51 BOOST_CHECK (
52 boost::algorithm::boyer_moore_horspool_search (
53 estr.begin (), estr.end (), str.begin (), str.end ())
54 == std::make_pair(estr.end(), estr.end())
55 );
56
57 BOOST_CHECK (
58 boost::algorithm::knuth_morris_pratt_search (
59 estr.begin (), estr.end (), str.begin (), str.end ())
60 == std::make_pair(estr.end(), estr.end())
61 );
62
63 // non-empty corpus, empty pattern
64 BOOST_CHECK (
65 boost::algorithm::boyer_moore_search (
66 str.begin (), str.end (), estr.begin (), estr.end ())
67 == std::make_pair(str.begin(), str.begin())
68 );
69
70 BOOST_CHECK (
71 boost::algorithm::boyer_moore_horspool_search (
72 str.begin (), str.end (), estr.begin (), estr.end ())
73 == std::make_pair(str.begin(), str.begin())
74 );
75
76 BOOST_CHECK (
77 boost::algorithm::knuth_morris_pratt_search (
78 str.begin (), str.end (), estr.begin (), estr.end ())
79 == std::make_pair(str.begin(), str.begin())
80 );
81 }