diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2015-04-08 03:09:47 +0000 |
---|---|---|
committer | <> | 2015-05-05 14:37:32 +0000 |
commit | f2541bb90af059680aa7036f315f052175999355 (patch) | |
tree | a5b214744b256f07e1dc2bd7273035a7808c659f /libs/container/test/container_common_tests.hpp | |
parent | ed232fdd34968697a68783b3195b1da4226915b5 (diff) | |
download | boost-tarball-master.tar.gz |
Imported from /home/lorry/working-area/delta_boost-tarball/boost_1_58_0.tar.bz2.HEADboost_1_58_0master
Diffstat (limited to 'libs/container/test/container_common_tests.hpp')
-rw-r--r-- | libs/container/test/container_common_tests.hpp | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/libs/container/test/container_common_tests.hpp b/libs/container/test/container_common_tests.hpp new file mode 100644 index 000000000..af57eb640 --- /dev/null +++ b/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 |