From 0db07e94550340e742b33f680f98e1ac5f2fec4e Mon Sep 17 00:00:00 2001 From: Jeremy Siek Date: Sun, 11 Jan 2004 17:45:33 +0000 Subject: [PATCH] added concept checks [SVN r21603] --- test/filter_iterator_test.cpp | 15 +++--- test/reverse_iterator_test.cpp | 92 +++++++++++++++++++++++++++++++--- 2 files changed, 93 insertions(+), 14 deletions(-) diff --git a/test/filter_iterator_test.cpp b/test/filter_iterator_test.cpp index a3c847b..dbee3d7 100644 --- a/test/filter_iterator_test.cpp +++ b/test/filter_iterator_test.cpp @@ -1,8 +1,10 @@ -// Copyright David Abrahams 2003. Permission to copy, use, -// modify, sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided -// "as is" without express or implied warranty, and with no claim as -// to its suitability for any purpose. +// Copyright David Abrahams 2003, Jeremy Siek 2004. + +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all +// copies. This software is provided "as is" without express or +// implied warranty, and with no claim as to its suitability for any +// purpose. #include #include @@ -12,6 +14,7 @@ #include #include #include +#include #include #include @@ -184,5 +187,5 @@ int main() std::cout << "test successful " << std::endl; - return 0; + return boost::exit_success; } diff --git a/test/reverse_iterator_test.cpp b/test/reverse_iterator_test.cpp index eb3d12d..85ea467 100644 --- a/test/reverse_iterator_test.cpp +++ b/test/reverse_iterator_test.cpp @@ -1,13 +1,21 @@ -// Copyright Thomas Witt 2003. Permission to copy, use, -// modify, sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided -// "as is" without express or implied warranty, and with no claim as -// to its suitability for any purpose. +// Copyright Thomas Witt 2003, Jeremy Siek 2004. + +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all +// copies. This software is provided "as is" without express or +// implied warranty, and with no claim as to its suitability for any +// purpose. #include #include +#include +#include +#include +#include +#include #include #include +#include using boost::dummyT; @@ -18,7 +26,73 @@ int main() dummyT(3), dummyT(4), dummyT(5) }; const int N = sizeof(array)/sizeof(dummyT); - // Test reverse_iterator_generator + // Concept checks + // Adapting old-style iterators + { + typedef boost::reverse_iterator > Iter; + boost::function_requires< boost::BidirectionalIteratorConcept >(); + boost::function_requires< boost_concepts::ReadableLvalueIteratorConcept >(); + boost::function_requires< boost_concepts::BidirectionalTraversalConcept >(); + } + { + typedef boost::reverse_iterator > Iter; + boost::function_requires< boost::Mutable_BidirectionalIteratorConcept >(); + boost::function_requires< boost_concepts::WritableLvalueIteratorConcept >(); + boost::function_requires< boost_concepts::BidirectionalTraversalConcept >(); + } + // Adapting new-style iterators + { + typedef boost::iterator_archetype< + const dummyT + , boost::iterator_archetypes::readable_iterator_t + , boost::bidirectional_traversal_tag + > Iter; + boost::function_requires< boost::InputIteratorConcept >(); + boost::function_requires< boost_concepts::ReadableIteratorConcept >(); + boost::function_requires< boost_concepts::BidirectionalTraversalConcept >(); + } + { + typedef boost::iterator_archetype< + dummyT + , boost::iterator_archetypes::writable_iterator_t + , boost::bidirectional_traversal_tag + > Iter; + boost::function_requires< boost_concepts::WritableIteratorConcept >(); + boost::function_requires< boost_concepts::BidirectionalTraversalConcept >(); + } + { + typedef boost::iterator_archetype< + dummyT + , boost::iterator_archetypes::readable_writable_iterator_t + , boost::bidirectional_traversal_tag + > Iter; + boost::function_requires< boost::InputIteratorConcept >(); + boost::function_requires< boost_concepts::ReadableIteratorConcept >(); + boost::function_requires< boost_concepts::WritableIteratorConcept >(); + boost::function_requires< boost_concepts::BidirectionalTraversalConcept >(); + } + { + typedef boost::iterator_archetype< + const dummyT + , boost::iterator_archetypes::readable_lvalue_iterator_t + , boost::bidirectional_traversal_tag + > Iter; + boost::function_requires< boost::BidirectionalIteratorConcept >(); + boost::function_requires< boost_concepts::ReadableLvalueIteratorConcept >(); + boost::function_requires< boost_concepts::BidirectionalTraversalConcept >(); + } + { + typedef boost::iterator_archetype< + dummyT + , boost::iterator_archetypes::writable_lvalue_iterator_t + , boost::bidirectional_traversal_tag + > Iter; + boost::function_requires< boost::BidirectionalIteratorConcept >(); + boost::function_requires< boost_concepts::WritableLvalueIteratorConcept >(); + boost::function_requires< boost_concepts::BidirectionalTraversalConcept >(); + } + + // Test reverse_iterator { dummyT reversed[N]; std::copy(array, array + N, reversed); @@ -43,7 +117,7 @@ int main() boost::const_nonconst_iterator_test(i, ++j); } - // Test reverse_iterator_generator again, with traits fully deducible on all platforms + // Test reverse_iterator again, with traits fully deducible on all platforms { std::deque reversed_container; std::reverse_copy(array, array + N, std::back_inserter(reversed_container)); @@ -82,5 +156,7 @@ int main() #endif } - return 0; + + std::cout << "test successful " << std::endl; + return boost::exit_success; }