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/intrusive/test/test_macros.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/intrusive/test/test_macros.hpp')
-rw-r--r-- | src/boost/libs/intrusive/test/test_macros.hpp | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/boost/libs/intrusive/test/test_macros.hpp b/src/boost/libs/intrusive/test/test_macros.hpp new file mode 100644 index 00000000..1f72d978 --- /dev/null +++ b/src/boost/libs/intrusive/test/test_macros.hpp @@ -0,0 +1,81 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2006-2013 +// +// 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/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_TEST_TEST_MACROS_HPP +#define BOOST_INTRUSIVE_TEST_TEST_MACROS_HPP + +#include <boost/intrusive/intrusive_fwd.hpp> +#include <algorithm> //std::unique + +namespace boost{ +namespace intrusive{ +namespace test{ + +template <class T> +struct is_multikey_true +{ + typedef char yes_type; + template<bool IsMultikey> + struct two { yes_type _[1+IsMultikey]; }; + template <class U> static yes_type test(...); + template <class U> static two<U::is_multikey>test(int); + static const bool value = sizeof(test<T>(0)) != sizeof(yes_type); +}; + +} //namespace test{ + +template<class It1, class It2> +bool test_equal(It1 f1, It1 l1, It2 f2) +{ + while(f1 != l1){ + if(*f1 != *f2){ + return false; + } + ++f1; + ++f2; + } + return true; +} + +#define TEST_INTRUSIVE_SEQUENCE( INTVALUES, ITERATOR )\ +{ \ + BOOST_TEST (boost::intrusive::test_equal(&INTVALUES[0], &INTVALUES[0] + sizeof(INTVALUES)/sizeof(INTVALUES[0]), ITERATOR) ); \ +} + +#define TEST_INTRUSIVE_SEQUENCE_EXPECTED( EXPECTEDVECTOR, ITERATOR )\ +{ \ + BOOST_TEST (boost::intrusive::test_equal(EXPECTEDVECTOR.begin(), EXPECTEDVECTOR.end(), ITERATOR) ); \ +} + +namespace test{ + +template<class Container, class Vector> +void test_intrusive_maybe_unique(const Container &c, Vector &v) +{ + if(!is_multikey_true<Container>::value) + v.erase(std::unique(v.begin(), v.end()), v.end()); + BOOST_TEST (boost::intrusive::test_equal(v.begin(), v.end(), c.begin()) ); +} + +} //namespace test{ + +#define TEST_INTRUSIVE_SEQUENCE_MAYBEUNIQUE(INTVALUES, CONTAINER)\ +{\ + boost::container::vector<int>v(&INTVALUES[0], &INTVALUES[0] + sizeof(INTVALUES)/sizeof(INTVALUES[0]));\ + boost::intrusive::test::test_intrusive_maybe_unique(CONTAINER, v);\ +}\ +// + +} //namespace boost{ +} //namespace intrusive{ + +#endif |