summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/gil/test/unit_test_utility.hpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
commit483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch)
treee5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/boost/libs/gil/test/unit_test_utility.hpp
parentInitial commit. (diff)
downloadceph-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/gil/test/unit_test_utility.hpp')
-rw-r--r--src/boost/libs/gil/test/unit_test_utility.hpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/boost/libs/gil/test/unit_test_utility.hpp b/src/boost/libs/gil/test/unit_test_utility.hpp
new file mode 100644
index 00000000..b7ff3baa
--- /dev/null
+++ b/src/boost/libs/gil/test/unit_test_utility.hpp
@@ -0,0 +1,67 @@
+//
+// Copyright 2019 Mateusz Loskot <mateusz at loskot dot net>
+//
+// Distribtted 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
+//
+#ifndef BOOST_GIL_TEST_UNIT_TEST_UTILITY_HPP
+#define BOOST_GIL_TEST_UNIT_TEST_UTILITY_HPP
+
+#include <boost/gil/color_base_algorithm.hpp> // static_for_each
+#include <boost/gil/pixel.hpp>
+#include <boost/gil/promote_integral.hpp>
+
+#include <boost/core/typeinfo.hpp>
+
+#include <cstdint>
+#include <ostream>
+
+namespace boost { namespace gil {
+
+namespace detail {
+
+struct print_color_base
+{
+ std::ostream& os_;
+ std::size_t element_index_{0};
+ print_color_base(std::ostream& os) : os_(os) {}
+
+ template <typename Element>
+ void operator()(Element& c)
+ {
+ typename ::boost::gil::promote_integral<Element>::type const v(c);
+ if (element_index_ > 0) os_ << ", ";
+ os_ << "v" << element_index_ << "=" << v;
+ ++element_index_;
+ }
+};
+
+} // namespace detail
+
+// Make `point` printable for BOOST_TEST()
+template <typename T>
+std::ostream& operator<<(std::ostream& os, point<T> const& p)
+{
+ os << "point<" << boost::core::demangled_name(typeid(T)) << ">";
+ os << "(" << p.x << ", " << p.y << ")" << std::endl;
+ return os;
+}
+
+// Make `pixel` printable for BOOST_TEST()
+template <typename ChannelValue, typename Layout>
+std::ostream& operator<<(std::ostream& os, pixel<ChannelValue, Layout> const& p)
+{
+ os << "pixel<"
+ << "Channel=" << boost::core::demangled_name(typeid(ChannelValue))
+ << ", Layout=" << boost::core::demangled_name(typeid(Layout))
+ << ">(";
+
+ static_for_each(p, detail::print_color_base{os});
+ os << ")" << std::endl;
+ return os;
+}
+
+}} // namespace boost::gil
+
+#endif