From 3cc4107d01b152bc2417d434b6fa22925a34aecd Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Sun, 23 Sep 2018 12:37:21 +0300 Subject: [PATCH] Added a test for compatibility of boost::distance between Range and Iterator. This functionality is used in core Boost components, so it is preferable to test it in Boost.Iterator, even if it's already tested in Boost.Range, to discover problems as early as possible. The test verifies that boost::distance implemented in Boost.Range can invoke boost::distance in Boost.Iterator (i.e. the function lookup succeeds). --- test/Jamfile.v2 | 1 + test/range_distance_compat_test.cpp | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 test/range_distance_compat_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 2a0eea0..14b7b2a 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -60,6 +60,7 @@ test-suite iterator [ run advance_test.cpp ] [ run distance_test.cpp ] [ compile adl_test.cpp ] + [ compile range_distance_compat_test.cpp ] [ run shared_iterator_test.cpp ] ; diff --git a/test/range_distance_compat_test.cpp b/test/range_distance_compat_test.cpp new file mode 100644 index 0000000..ef7e301 --- /dev/null +++ b/test/range_distance_compat_test.cpp @@ -0,0 +1,22 @@ +// Copyright (C) 2018 Andrey Semashev +// +// 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) + +#include +#include +#include + +int main() +{ + // Test that boost::distance from Boost.Range works with boost::distance from Boost.Iterator + // (https://github.com/boostorg/iterator/commit/b844c8df530c474ec1856870b9b0de5f487b84d4#commitcomment-30603668) + + typedef boost::iterator_range range_type; + range_type range; + + (void)boost::distance(range); + + return 0; +}