diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
commit | 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch) | |
tree | e5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/boost/libs/container/test/container_common_tests.hpp | |
parent | Initial commit. (diff) | |
download | ceph-upstream.tar.xz ceph-upstream.zip |
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/container/test/container_common_tests.hpp')
-rw-r--r-- | src/boost/libs/container/test/container_common_tests.hpp | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/src/boost/libs/container/test/container_common_tests.hpp b/src/boost/libs/container/test/container_common_tests.hpp new file mode 100644 index 00000000..63e15477 --- /dev/null +++ b/src/boost/libs/container/test/container_common_tests.hpp @@ -0,0 +1,86 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2014-2014. 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) +// +// See http://www.boost.org/libs/container for documentation. +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_CONTAINER_TEST_CONTAINER_COMMON_TESTS_HPP +#define BOOST_CONTAINER_TEST_CONTAINER_COMMON_TESTS_HPP + +#include <boost/container/detail/config_begin.hpp> + +namespace boost{ +namespace container { +namespace test{ + + +template<class Container> +const Container &as_const(Container &c) +{ return c; } + +//nth, index_of +template<class Container> +bool test_nth_index_of(Container &c) +{ + typename Container::iterator it; + typename Container::const_iterator cit; + typename Container::size_type sz, csz; + //index 0 + it = c.nth(0); + sz = c.index_of(it); + cit = (as_const)(c).nth(0); + csz = (as_const)(c).index_of(cit); + + if(it != c.begin()) + return false; + if(cit != c.cbegin()) + return false; + if(sz != 0) + return false; + if(csz != 0) + return false; + + //index size()/2 + const typename Container::size_type sz_div_2 = c.size()/2; + it = c.nth(sz_div_2); + sz = c.index_of(it); + cit = (as_const)(c).nth(sz_div_2); + csz = (as_const)(c).index_of(cit); + + if(it != (c.begin()+sz_div_2)) + return false; + if(cit != (c.cbegin()+sz_div_2)) + return false; + if(sz != sz_div_2) + return false; + if(csz != sz_div_2) + return false; + + //index size() + it = c.nth(c.size()); + sz = c.index_of(it); + cit = (as_const)(c).nth(c.size()); + csz = (as_const)(c).index_of(cit); + + if(it != c.end()) + return false; + if(cit != c.cend()) + return false; + if(sz != c.size()) + return false; + if(csz != c.size()) + return false; + return true; +} + +} //namespace test{ +} //namespace container { +} //namespace boost{ + +#include <boost/container/detail/config_end.hpp> + +#endif //#ifndef BOOST_CONTAINER_TEST_CONTAINER_COMMON_TESTS_HPP |