/**************************************************************************** * Copyright (c) 2017-2022 by the ArborX authors * * All rights reserved. * * * * This file is part of the ArborX library. ArborX is * * distributed under a BSD 3-clause license. For the licensing terms see * * the LICENSE file in the top-level directory. * * * * SPDX-License-Identifier: BSD-3-Clause * ****************************************************************************/ #ifndef ARBORX_BOOST_TEST_COMPRESSED_STORAGE_COMPARISON_HPP #define ARBORX_BOOST_TEST_COMPRESSED_STORAGE_COMPARISON_HPP #include #include #include #include template struct CompressedStorage { Offsets offsets; Values values; using value_type = typename Values::value_type; using index_type = typename Offsets::value_type; struct ConstForwardIterator { index_type i; CompressedStorage const *p; using value_type = std::multiset; ConstForwardIterator &operator++() { ++i; return *this; } ConstForwardIterator operator++(int) { ConstForwardIterator old{*this}; ++*this; return old; } bool operator==(ConstForwardIterator const &o) { return i == o.i; } bool operator!=(ConstForwardIterator const &o) { return !(*this == o); } value_type operator*() { return {p->values.data() + p->offsets[i], p->values.data() + p->offsets[i + 1]}; } }; ConstForwardIterator cbegin() const { return {static_cast(0), this}; } ConstForwardIterator cend() const { return {static_cast(offsets.size()), this}; } std::size_t size() const { return offsets.size() - 1; } }; template CompressedStorage, std::decay_t> make_compressed_storage(Offsets &&offsets, Values &&values) { return {std::forward(offsets), std::forward(values)}; } namespace boost { namespace unit_test { template struct is_forward_iterable> : public boost::mpl::true_ {}; template struct bt_iterator_traits, true> { using this_type = CompressedStorage; using const_iterator = typename this_type::ConstForwardIterator; using value_type = typename const_iterator::value_type; static const_iterator begin(this_type const &x) { return x.cbegin(); } static const_iterator end(this_type const &x) { return x.cend(); } static std::size_t size(this_type const &x) { return x.size(); } }; } // namespace unit_test } // namespace boost // Customization for logging with Boost.Test namespace std { template std::ostream & boost_test_print_type(std::ostream &os, std::multiset const &s) { os << '('; for (auto const &x : s) { os << ' '; boost::test_tools::tt_detail::print_log_value()(os, x); } os << " )"; return os; } } // namespace std #endif