sl@0
|
1 |
// Copyright 2002 The Trustees of Indiana University.
|
sl@0
|
2 |
|
sl@0
|
3 |
// Use, modification and distribution is subject to the Boost Software
|
sl@0
|
4 |
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
sl@0
|
5 |
// http://www.boost.org/LICENSE_1_0.txt)
|
sl@0
|
6 |
|
sl@0
|
7 |
// Boost.MultiArray Library
|
sl@0
|
8 |
// Authors: Ronald Garcia
|
sl@0
|
9 |
// Jeremy Siek
|
sl@0
|
10 |
// Andrew Lumsdaine
|
sl@0
|
11 |
// See http://www.boost.org/libs/multi_array for documentation.
|
sl@0
|
12 |
|
sl@0
|
13 |
//
|
sl@0
|
14 |
// idxset1.cpp - testing the code for index_gen
|
sl@0
|
15 |
//
|
sl@0
|
16 |
/*
|
sl@0
|
17 |
* © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
|
sl@0
|
18 |
*/
|
sl@0
|
19 |
|
sl@0
|
20 |
#include "boost/multi_array/index_gen.hpp"
|
sl@0
|
21 |
#include "boost/multi_array/index_range.hpp"
|
sl@0
|
22 |
#include "boost/multi_array/types.hpp"
|
sl@0
|
23 |
#include "boost/test/minimal.hpp"
|
sl@0
|
24 |
|
sl@0
|
25 |
#include "boost/array.hpp"
|
sl@0
|
26 |
|
sl@0
|
27 |
#ifdef __SYMBIAN32__
|
sl@0
|
28 |
#include "std_log_result.h"
|
sl@0
|
29 |
#define LOG_FILENAME_LINE __FILE__, __LINE__
|
sl@0
|
30 |
#endif
|
sl@0
|
31 |
typedef boost::detail::multi_array::index index_type;
|
sl@0
|
32 |
typedef boost::detail::multi_array::size_type size_type;
|
sl@0
|
33 |
typedef boost::detail::multi_array::index_range<index_type,size_type> range;
|
sl@0
|
34 |
|
sl@0
|
35 |
template <int NumRanges, int NumDims>
|
sl@0
|
36 |
void check(const boost::detail::multi_array::
|
sl@0
|
37 |
index_gen<NumRanges,NumDims>&) { }
|
sl@0
|
38 |
|
sl@0
|
39 |
bool operator==(const range& lhs,const range& rhs) {
|
sl@0
|
40 |
return lhs.start_ == rhs.start_ &&
|
sl@0
|
41 |
lhs.finish_ == rhs.finish_ &&
|
sl@0
|
42 |
lhs.stride_ == rhs.stride_ &&
|
sl@0
|
43 |
lhs.degenerate_ == rhs.degenerate_;
|
sl@0
|
44 |
}
|
sl@0
|
45 |
|
sl@0
|
46 |
int
|
sl@0
|
47 |
test_main(int,char*[])
|
sl@0
|
48 |
{
|
sl@0
|
49 |
|
sl@0
|
50 |
boost::detail::multi_array::index_gen<0,0> indices;
|
sl@0
|
51 |
|
sl@0
|
52 |
|
sl@0
|
53 |
check<1,1>(indices[range()]);
|
sl@0
|
54 |
check<2,2>(indices[range()][range()]);
|
sl@0
|
55 |
check<3,3>(indices[range()][range()][range()]);
|
sl@0
|
56 |
|
sl@0
|
57 |
check<1,0>(indices[0]);
|
sl@0
|
58 |
check<2,0>(indices[0][0]);
|
sl@0
|
59 |
check<2,1>(indices[range()][0]);
|
sl@0
|
60 |
check<2,1>(indices[0][range()]);
|
sl@0
|
61 |
check<3,0>(indices[0][0][0]);
|
sl@0
|
62 |
check<3,1>(indices[range()][0][0]);
|
sl@0
|
63 |
check<3,1>(indices[0][range()][0]);
|
sl@0
|
64 |
check<3,1>(indices[0][0][range()]);
|
sl@0
|
65 |
check<3,2>(indices[range()][range()][0]);
|
sl@0
|
66 |
check<3,2>(indices[range()][0][range()]);
|
sl@0
|
67 |
check<3,2>(indices[0][range()][range()]);
|
sl@0
|
68 |
|
sl@0
|
69 |
{
|
sl@0
|
70 |
boost::detail::multi_array::index_gen<3,3> is1 =
|
sl@0
|
71 |
indices[range(0,1,2)][range(1,2,3)][range(2,3,4)];
|
sl@0
|
72 |
BOOST_CHECK(is1.ranges_[0] == range(0,1,2));
|
sl@0
|
73 |
BOOST_CHECK(is1.ranges_[1] == range(1,2,3));
|
sl@0
|
74 |
BOOST_CHECK(is1.ranges_[2] == range(2,3,4));
|
sl@0
|
75 |
}
|
sl@0
|
76 |
|
sl@0
|
77 |
{
|
sl@0
|
78 |
boost::detail::multi_array::index_gen<3,2> is2 =
|
sl@0
|
79 |
indices[range(0,1,2)][2][range(2,3,4)];
|
sl@0
|
80 |
BOOST_CHECK(is2.ranges_[0] == range(0,1,2));
|
sl@0
|
81 |
BOOST_CHECK(is2.ranges_[1] == range(2));
|
sl@0
|
82 |
BOOST_CHECK(is2.ranges_[1].is_degenerate());
|
sl@0
|
83 |
BOOST_CHECK(is2.ranges_[2] == range(2,3,4));
|
sl@0
|
84 |
}
|
sl@0
|
85 |
#ifdef __SYMBIAN32__
|
sl@0
|
86 |
if(boost::minimal_test::errors_counter() != 0)
|
sl@0
|
87 |
assert_failed = true;
|
sl@0
|
88 |
testResultXml("idxgen1");
|
sl@0
|
89 |
close_log_file();
|
sl@0
|
90 |
#endif
|
sl@0
|
91 |
return boost::exit_success;
|
sl@0
|
92 |
}
|
sl@0
|
93 |
|