]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/algorithm/test/is_partitioned_until_test.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / algorithm / test / is_partitioned_until_test.cpp
1 /*
2 Copyright (c) Marshall Clow 2011-2012, Alexander Zaitsev <zamazan4ik@gmail.com>, 2017.
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 <iostream>
11
12 #include <boost/config.hpp>
13 #include <boost/algorithm/is_partitioned_until.hpp>
14
15 #define BOOST_TEST_MAIN
16 #include <boost/test/unit_test.hpp>
17
18 #include <string>
19 #include <vector>
20 #include <list>
21
22 namespace ba = boost::algorithm;
23 // namespace ba = boost;
24
25 template <typename T>
26 struct less_than {
27 public:
28 less_than ( T foo ) : val ( foo ) {}
29 less_than ( const less_than &rhs ) : val ( rhs.val ) {}
30
31 bool operator () ( const T &v ) const { return v < val; }
32 private:
33 less_than ();
34 less_than operator = ( const less_than &rhs );
35 T val;
36 };
37
38
39 void test_sequence1 () {
40 std::vector<int> v;
41
42 v.clear ();
43 for ( int i = 5; i < 15; ++i )
44 v.push_back ( i );
45 BOOST_CHECK ( ba::is_partitioned_until ( v, less_than<int>(3)) == v.end()); // no elements
46 BOOST_CHECK ( ba::is_partitioned_until ( v, less_than<int>(6)) == v.end()); // only the first element
47 BOOST_CHECK ( ba::is_partitioned_until ( v, less_than<int>(10)) == v.end()); // in the middle somewhere
48 BOOST_CHECK ( ba::is_partitioned_until ( v, less_than<int>(99)) == v.end()); // all elements satisfy
49 // With bidirectional iterators.
50 std::list<int> l;
51 for ( int i = 5; i < 15; ++i )
52 l.push_back ( i );
53 BOOST_CHECK ( ba::is_partitioned_until ( l.begin (), l.end (), less_than<int>(3)) == l.end()); // no elements
54 BOOST_CHECK ( ba::is_partitioned_until ( l.begin (), l.end (), less_than<int>(6)) == l.end()); // only the first element
55 BOOST_CHECK ( ba::is_partitioned_until ( l.begin (), l.end (), less_than<int>(10)) == l.end()); // in the middle somewhere
56 BOOST_CHECK ( ba::is_partitioned_until ( l.begin (), l.end (), less_than<int>(99)) == l.end()); // all elements satisfy
57 }
58
59
60 BOOST_AUTO_TEST_CASE( test_main )
61 {
62 test_sequence1 ();
63 }