Skip to content

Commit

Permalink
Add array_typedef_test.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
pdimov committed Jan 9, 2025
1 parent fd24e05 commit f9bb980
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import testing ;
import-search /boost/config/checks ;
import config : requires ;

#

run array0.cpp ;
run array1.cpp ;
run array2.cpp ;
Expand All @@ -24,4 +26,10 @@ compile-fail array_getfail2.cpp ;
run array_hash.cpp
: : : [ requires cxx11_noexcept ] ;

#

run array_typedef_test.cpp ;

#

run quick.cpp ;
43 changes: 43 additions & 0 deletions test/array_typedef_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)

#include <boost/array.hpp>
#include <boost/core/lightweight_test_trait.hpp>
#include <boost/core/lightweight_test.hpp>
#include <iterator>
#include <cstddef>

template<class T, std::size_t N> void test()
{
typedef boost::array<T, N> A;

BOOST_TEST_TRAIT_SAME(typename A::value_type, T);

BOOST_TEST_TRAIT_SAME(typename A::iterator, T*);
BOOST_TEST_TRAIT_SAME(typename A::const_iterator, T const*);

BOOST_TEST_TRAIT_SAME(typename A::reverse_iterator, std::reverse_iterator<T*>);
BOOST_TEST_TRAIT_SAME(typename A::const_reverse_iterator, std::reverse_iterator<T const*>);

BOOST_TEST_TRAIT_SAME(typename A::reference, T&);
BOOST_TEST_TRAIT_SAME(typename A::const_reference, T const&);

BOOST_TEST_TRAIT_SAME(typename A::size_type, std::size_t);
BOOST_TEST_TRAIT_SAME(typename A::difference_type, std::ptrdiff_t);

BOOST_TEST_EQ(A::static_size, N);
}

int main()
{
test<int, 0>();
test<int, 1>();
test<int, 7>();

test<int const, 0>();
test<int const, 1>();
test<int const, 7>();

return boost::report_errors();
}

0 comments on commit f9bb980

Please sign in to comment.