1215 |
07 Mar 08 |
peter |
1 |
#ifndef _theplu_yat_test_suite_ |
1215 |
07 Mar 08 |
peter |
2 |
#define _theplu_yat_test_suite_ |
1215 |
07 Mar 08 |
peter |
3 |
|
1215 |
07 Mar 08 |
peter |
// $Id$ |
1215 |
07 Mar 08 |
peter |
5 |
|
1215 |
07 Mar 08 |
peter |
6 |
/* |
2119 |
12 Dec 09 |
peter |
Copyright (C) 2008 Jari Häkkinen, Peter Johansson |
4359 |
23 Aug 23 |
peter |
Copyright (C) 2009, 2010, 2011, 2013, 2014, 2015, 2016, 2018, 2019, 2020, 2021, 2022, 2023 Peter Johansson |
1215 |
07 Mar 08 |
peter |
9 |
|
1437 |
25 Aug 08 |
peter |
This file is part of the yat library, http://dev.thep.lu.se/yat |
1215 |
07 Mar 08 |
peter |
11 |
|
1215 |
07 Mar 08 |
peter |
The yat library is free software; you can redistribute it and/or |
1215 |
07 Mar 08 |
peter |
modify it under the terms of the GNU General Public License as |
1486 |
09 Sep 08 |
jari |
published by the Free Software Foundation; either version 3 of the |
1215 |
07 Mar 08 |
peter |
License, or (at your option) any later version. |
1215 |
07 Mar 08 |
peter |
16 |
|
1215 |
07 Mar 08 |
peter |
The yat library is distributed in the hope that it will be useful, |
1215 |
07 Mar 08 |
peter |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
1215 |
07 Mar 08 |
peter |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1215 |
07 Mar 08 |
peter |
General Public License for more details. |
1215 |
07 Mar 08 |
peter |
21 |
|
1215 |
07 Mar 08 |
peter |
You should have received a copy of the GNU General Public License |
1487 |
10 Sep 08 |
jari |
along with yat. If not, see <http://www.gnu.org/licenses/>. |
1215 |
07 Mar 08 |
peter |
24 |
*/ |
1215 |
07 Mar 08 |
peter |
25 |
|
3439 |
20 Nov 15 |
peter |
// ensure that config.h always is included first |
3439 |
20 Nov 15 |
peter |
27 |
#ifndef YAT_VERSION |
3439 |
20 Nov 15 |
peter |
28 |
#error header 'config.h' not included |
3439 |
20 Nov 15 |
peter |
29 |
#endif |
3439 |
20 Nov 15 |
peter |
30 |
|
3439 |
20 Nov 15 |
peter |
31 |
#include <yat/utility/config_public.h> |
3439 |
20 Nov 15 |
peter |
32 |
|
2649 |
14 Nov 11 |
peter |
33 |
#define YAT_TEST_PROLOGUE "\n=== " << __func__ << " ===\n" |
2649 |
14 Nov 11 |
peter |
34 |
|
2943 |
04 Jan 13 |
peter |
// used to tell automake that test should be skipped |
2943 |
04 Jan 13 |
peter |
36 |
#define EXIT_SKIP 77 |
3846 |
13 Sep 19 |
peter |
37 |
#define EXIT_HARD_FAILURE 99 |
2943 |
04 Jan 13 |
peter |
38 |
|
2960 |
17 Jan 13 |
peter |
// SKIP_BAM_TEST is defined if we should skip bam tests |
3883 |
24 Mar 20 |
peter |
40 |
#if !defined (YAT_HAVE_HTSLIB) || !defined (HAVE_SAMTOOLS_EXECUTABLE) |
2960 |
17 Jan 13 |
peter |
41 |
#define SKIP_BAM_TEST |
2960 |
17 Jan 13 |
peter |
42 |
#endif |
2960 |
17 Jan 13 |
peter |
43 |
|
4280 |
27 Jan 23 |
peter |
44 |
#include <yat/utility/Matrix.h> |
2339 |
16 Oct 10 |
peter |
45 |
#include <yat/utility/VectorMutable.h> |
3538 |
22 Dec 16 |
peter |
46 |
#include <yat/utility/WeightedIteratorArchetype.h> |
2339 |
16 Oct 10 |
peter |
47 |
#include <yat/classifier/Target.h> |
2339 |
16 Oct 10 |
peter |
48 |
|
2338 |
16 Oct 10 |
peter |
49 |
#include <boost/concept_archetype.hpp> |
3273 |
04 Jul 14 |
peter |
50 |
#include <boost/concept_check.hpp> |
3458 |
19 Jan 16 |
peter |
51 |
#include <boost/iterator/iterator_categories.hpp> |
3273 |
04 Jul 14 |
peter |
52 |
#include <boost/iterator/iterator_concepts.hpp> |
2338 |
16 Oct 10 |
peter |
53 |
|
1569 |
13 Oct 08 |
jari |
54 |
#include <iosfwd> |
1360 |
26 Jun 08 |
peter |
55 |
#include <sstream> |
2339 |
16 Oct 10 |
peter |
56 |
#include <vector> |
1215 |
07 Mar 08 |
peter |
57 |
|
1215 |
07 Mar 08 |
peter |
58 |
namespace theplu { |
1215 |
07 Mar 08 |
peter |
59 |
namespace yat { |
1215 |
07 Mar 08 |
peter |
60 |
namespace test { |
1215 |
07 Mar 08 |
peter |
61 |
|
1215 |
07 Mar 08 |
peter |
62 |
/** |
1215 |
07 Mar 08 |
peter |
\internal utility class for tests |
1215 |
07 Mar 08 |
peter |
64 |
*/ |
1215 |
07 Mar 08 |
peter |
65 |
class Suite |
1215 |
07 Mar 08 |
peter |
66 |
{ |
1215 |
07 Mar 08 |
peter |
67 |
public: |
3201 |
03 May 14 |
peter |
68 |
Suite(int argc, char* argv[], bool require_bam=false); |
1215 |
07 Mar 08 |
peter |
69 |
|
1215 |
07 Mar 08 |
peter |
70 |
/** |
1215 |
07 Mar 08 |
peter |
71 |
*/ |
1215 |
07 Mar 08 |
peter |
72 |
~Suite(void); |
1215 |
07 Mar 08 |
peter |
73 |
|
1215 |
07 Mar 08 |
peter |
74 |
/** |
4200 |
19 Aug 22 |
peter |
set ok to 'b && ok' |
1304 |
14 May 08 |
peter |
76 |
|
1304 |
14 May 08 |
peter |
\return b |
1232 |
15 Mar 08 |
peter |
78 |
*/ |
1304 |
14 May 08 |
peter |
79 |
bool add(bool b); |
1232 |
15 Mar 08 |
peter |
80 |
|
1232 |
15 Mar 08 |
peter |
81 |
/** |
1215 |
07 Mar 08 |
peter |
\return In verbose mode std::cerr, else a ofstream to "/dev/null". |
1215 |
07 Mar 08 |
peter |
83 |
*/ |
1215 |
07 Mar 08 |
peter |
84 |
std::ostream& err(void) const; |
1215 |
07 Mar 08 |
peter |
85 |
|
1215 |
07 Mar 08 |
peter |
86 |
/** |
1234 |
15 Mar 08 |
peter |
\return true if \f$ |a-b| <= N * \epsilon * min(|a|,|b|) \f$ |
1234 |
15 Mar 08 |
peter |
where \f$ \epsilon \f$ is std::numeric_limits<double>().epsilon() |
1234 |
15 Mar 08 |
peter |
89 |
*/ |
1244 |
17 Mar 08 |
peter |
90 |
bool equal(double a, double b, unsigned long int N=1); |
1234 |
15 Mar 08 |
peter |
91 |
|
1247 |
17 Mar 08 |
peter |
92 |
/** |
4200 |
19 Aug 22 |
peter |
\return true if |\a a - \a b| <= \a margin |
1658 |
17 Dec 08 |
peter |
94 |
*/ |
1658 |
17 Dec 08 |
peter |
95 |
bool equal_fix(double a, double b, double margin=0); |
1658 |
17 Dec 08 |
peter |
96 |
|
1658 |
17 Dec 08 |
peter |
97 |
/** |
1247 |
17 Mar 08 |
peter |
\return true if \f$ |a-b| <= N * sqrt(\epsilon) * min(|a|,|b|) \f$ |
1247 |
17 Mar 08 |
peter |
where \f$ \epsilon \f$ is std::numeric_limits<double>().epsilon() |
1247 |
17 Mar 08 |
peter |
100 |
*/ |
1247 |
17 Mar 08 |
peter |
101 |
bool equal_sqrt(double a, double b, unsigned long int N=1); |
1247 |
17 Mar 08 |
peter |
102 |
|
3723 |
05 Feb 18 |
peter |
103 |
template<class MATRIX1, class MATRIX2> |
3723 |
05 Feb 18 |
peter |
104 |
bool equal_matrix(const MATRIX1& a, const MATRIX2& b,unsigned long int N=1); |
3723 |
05 Feb 18 |
peter |
105 |
|
1658 |
17 Dec 08 |
peter |
106 |
/** |
1658 |
17 Dec 08 |
peter |
apply equal on ranges [first1, last1) and [first2, ...) |
1658 |
17 Dec 08 |
peter |
108 |
*/ |
1239 |
16 Mar 08 |
peter |
109 |
template<typename Iterator1, typename Iterator2> |
1239 |
16 Mar 08 |
peter |
110 |
bool equal_range(Iterator1 first1, Iterator1 last1, Iterator2 first2, |
1239 |
16 Mar 08 |
peter |
111 |
unsigned int N=1); |
1234 |
15 Mar 08 |
peter |
112 |
|
1234 |
15 Mar 08 |
peter |
113 |
/** |
1658 |
17 Dec 08 |
peter |
apply equal_fix on ranges [first1, last1) and [first2, ...) |
1658 |
17 Dec 08 |
peter |
115 |
*/ |
1658 |
17 Dec 08 |
peter |
116 |
template<typename Iterator1, typename Iterator2> |
1658 |
17 Dec 08 |
peter |
117 |
bool equal_range_fix(Iterator1 first1, Iterator1 last1, Iterator2 first2, |
1658 |
17 Dec 08 |
peter |
118 |
double margin); |
1658 |
17 Dec 08 |
peter |
119 |
|
1658 |
17 Dec 08 |
peter |
120 |
/** |
1215 |
07 Mar 08 |
peter |
\return true if test is ok |
1215 |
07 Mar 08 |
peter |
122 |
*/ |
1215 |
07 Mar 08 |
peter |
123 |
bool ok(void) const; |
1215 |
07 Mar 08 |
peter |
124 |
|
1215 |
07 Mar 08 |
peter |
125 |
/** |
1215 |
07 Mar 08 |
peter |
\return In verbose mode std::cout, else a ofstream to "/dev/null". |
1215 |
07 Mar 08 |
peter |
127 |
*/ |
1215 |
07 Mar 08 |
peter |
128 |
std::ostream& out(void) const; |
3201 |
03 May 14 |
peter |
129 |
|
1215 |
07 Mar 08 |
peter |
130 |
/** |
4252 |
18 Nov 22 |
peter |
Call this function from tests that require file data/foo.vcf.gz |
4252 |
18 Nov 22 |
peter |
132 |
|
4252 |
18 Nov 22 |
peter |
If bcftools is not available call exit(EXIT_SKIP). |
4252 |
18 Nov 22 |
peter |
134 |
*/ |
4252 |
18 Nov 22 |
peter |
135 |
void require_foo_vcf_gz(void) const; |
4252 |
18 Nov 22 |
peter |
136 |
|
4252 |
18 Nov 22 |
peter |
137 |
/** |
1215 |
07 Mar 08 |
peter |
In verbose mode a final message is sent to std::cout. |
1215 |
07 Mar 08 |
peter |
139 |
|
1215 |
07 Mar 08 |
peter |
If ok() is true: "Test is ok." otherwise |
1215 |
07 Mar 08 |
peter |
"Test failed." |
1215 |
07 Mar 08 |
peter |
142 |
|
1215 |
07 Mar 08 |
peter |
\return 0 if ok. |
1215 |
07 Mar 08 |
peter |
144 |
*/ |
1215 |
07 Mar 08 |
peter |
145 |
int return_value(void) const; |
1215 |
07 Mar 08 |
peter |
146 |
|
1877 |
21 Mar 09 |
peter |
147 |
template<typename TrivialIterator> |
1877 |
21 Mar 09 |
peter |
148 |
void test_trivial_iterator(const TrivialIterator&); |
3149 |
23 Dec 13 |
peter |
149 |
|
1877 |
21 Mar 09 |
peter |
150 |
template<typename InputIterator> |
1877 |
21 Mar 09 |
peter |
151 |
void test_input_iterator(InputIterator&); |
3149 |
23 Dec 13 |
peter |
152 |
|
1877 |
21 Mar 09 |
peter |
153 |
template<typename OutputIterator> |
1877 |
21 Mar 09 |
peter |
154 |
void test_output_iterator(OutputIterator&); |
3149 |
23 Dec 13 |
peter |
155 |
|
4343 |
16 Apr 23 |
peter |
// assumes that value_type has operator== |
1877 |
21 Mar 09 |
peter |
157 |
template<typename ForwardIterator> |
1877 |
21 Mar 09 |
peter |
158 |
void test_forward_iterator(ForwardIterator); |
3149 |
23 Dec 13 |
peter |
159 |
|
4343 |
16 Apr 23 |
peter |
// assumes that value_type has operator== |
1877 |
21 Mar 09 |
peter |
161 |
template<typename BidirectionalIterator> |
1877 |
21 Mar 09 |
peter |
162 |
void test_bidirectional_iterator(BidirectionalIterator); |
3149 |
23 Dec 13 |
peter |
163 |
|
4343 |
16 Apr 23 |
peter |
// assumes that value_type has operator== |
1877 |
21 Mar 09 |
peter |
165 |
template<typename RandomAccessIterator> |
1877 |
21 Mar 09 |
peter |
166 |
void test_random_access_iterator(RandomAccessIterator); |
1877 |
21 Mar 09 |
peter |
167 |
|
2143 |
15 Jan 10 |
peter |
168 |
template<typename Container2D> |
2143 |
15 Jan 10 |
peter |
169 |
void test_concept_container2d(const Container2D&); |
2143 |
15 Jan 10 |
peter |
170 |
|
2143 |
15 Jan 10 |
peter |
171 |
template<typename MutableContainer2D> |
2143 |
15 Jan 10 |
peter |
172 |
void test_concept_mutable_container2d(MutableContainer2D&); |
2143 |
15 Jan 10 |
peter |
173 |
|
1360 |
26 Jun 08 |
peter |
174 |
/** |
1360 |
26 Jun 08 |
peter |
Function writes to a stream using operator<<, creates a new |
1360 |
26 Jun 08 |
peter |
object using stream constructor, and the new object is written |
1360 |
26 Jun 08 |
peter |
to another stream, and function check if the two outputs are |
1360 |
26 Jun 08 |
peter |
equal. |
1360 |
26 Jun 08 |
peter |
179 |
*/ |
1360 |
26 Jun 08 |
peter |
180 |
template<class T> |
1360 |
26 Jun 08 |
peter |
181 |
bool test_stream(const T&) const; |
1360 |
26 Jun 08 |
peter |
182 |
|
1509 |
17 Sep 08 |
peter |
183 |
/** |
1509 |
17 Sep 08 |
peter |
This function is similar to add(bool) and could be used to |
1509 |
17 Sep 08 |
peter |
detect/count known issues. When the issue is fixed, one can |
1509 |
17 Sep 08 |
peter |
replace the call to xadd(bool) with a call to add(bool). |
1509 |
17 Sep 08 |
peter |
187 |
|
1509 |
17 Sep 08 |
peter |
If \a b is false a counter is incremented, which is used to in |
1509 |
17 Sep 08 |
peter |
return_value() to generate some printout on how many known |
1509 |
17 Sep 08 |
peter |
issues were detected. |
1509 |
17 Sep 08 |
peter |
191 |
|
1509 |
17 Sep 08 |
peter |
If \a b is true, ok_ is set to false, becasue the known issue |
1509 |
17 Sep 08 |
peter |
is no longer an issue and one should replace the call with a |
1509 |
17 Sep 08 |
peter |
call to add(bool). |
1509 |
17 Sep 08 |
peter |
195 |
*/ |
1509 |
17 Sep 08 |
peter |
196 |
bool xadd(bool b); |
1509 |
17 Sep 08 |
peter |
197 |
|
1215 |
07 Mar 08 |
peter |
198 |
private: |
1509 |
17 Sep 08 |
peter |
199 |
unsigned int known_issues_; |
1509 |
17 Sep 08 |
peter |
200 |
bool ok_; |
1215 |
07 Mar 08 |
peter |
201 |
}; |
1215 |
07 Mar 08 |
peter |
202 |
|
4058 |
20 Apr 21 |
peter |
203 |
|
4058 |
20 Apr 21 |
peter |
204 |
struct Generator |
4058 |
20 Apr 21 |
peter |
205 |
{ |
4058 |
20 Apr 21 |
peter |
206 |
Generator(void); |
4058 |
20 Apr 21 |
peter |
207 |
double operator()(void); |
4058 |
20 Apr 21 |
peter |
208 |
private: |
4058 |
20 Apr 21 |
peter |
209 |
size_t k_; |
4058 |
20 Apr 21 |
peter |
210 |
}; |
4058 |
20 Apr 21 |
peter |
211 |
|
4280 |
27 Jan 23 |
peter |
212 |
utility::Matrix generate_Matrix(size_t row, size_t col, double seed); |
4280 |
27 Jan 23 |
peter |
213 |
|
1249 |
20 Mar 08 |
peter |
214 |
/** |
3987 |
26 Aug 20 |
peter |
If top source directory is located in /home/strangelove/yat, |
3987 |
26 Aug 20 |
peter |
function returns "/home/strangelove/yat" + "test/" + local_path |
2455 |
29 Mar 11 |
peter |
217 |
|
1249 |
20 Mar 08 |
peter |
\return absolute path to file |
1249 |
20 Mar 08 |
peter |
\param local_path path relative to srcdir |
1249 |
20 Mar 08 |
peter |
220 |
*/ |
1249 |
20 Mar 08 |
peter |
221 |
std::string filename(const std::string& local_path); |
1249 |
20 Mar 08 |
peter |
222 |
|
2147 |
17 Jan 10 |
peter |
223 |
/* |
2147 |
17 Jan 10 |
peter |
class to test (at compile time) that a function (or class) works |
2147 |
17 Jan 10 |
peter |
with a Container2D. Do not run any test using this class because |
2147 |
17 Jan 10 |
peter |
the class is not really functional at run time. |
2147 |
17 Jan 10 |
peter |
227 |
|
2147 |
17 Jan 10 |
peter |
\see boost/concept_archetype.hpp |
2147 |
17 Jan 10 |
peter |
229 |
*/ |
2147 |
17 Jan 10 |
peter |
230 |
template<typename T> |
2147 |
17 Jan 10 |
peter |
231 |
class container2d_archetype |
2147 |
17 Jan 10 |
peter |
232 |
{ |
2147 |
17 Jan 10 |
peter |
233 |
public: |
2147 |
17 Jan 10 |
peter |
234 |
typedef T value_type; |
2147 |
17 Jan 10 |
peter |
235 |
typedef const T& const_reference; |
3149 |
23 Dec 13 |
peter |
236 |
typedef const T* const_iterator; |
2147 |
17 Jan 10 |
peter |
237 |
typedef const_iterator const_column_iterator; |
2147 |
17 Jan 10 |
peter |
238 |
typedef const_iterator const_row_iterator; |
2147 |
17 Jan 10 |
peter |
239 |
const_iterator begin(void) const { return &element_; } |
2147 |
17 Jan 10 |
peter |
240 |
const_column_iterator begin_column(size_t) const { return &element_; } |
2147 |
17 Jan 10 |
peter |
241 |
const_iterator begin_row(size_t) const { return &element_; } |
2147 |
17 Jan 10 |
peter |
242 |
const_iterator end(void) const { return NULL; } |
2147 |
17 Jan 10 |
peter |
243 |
const_column_iterator end_column(size_t) const { return NULL; } |
2147 |
17 Jan 10 |
peter |
244 |
const_iterator end_row(size_t) const { return NULL; } |
2147 |
17 Jan 10 |
peter |
245 |
size_t columns(void) const { return 0; } |
2147 |
17 Jan 10 |
peter |
246 |
size_t rows(void) const { return 0; } |
3149 |
23 Dec 13 |
peter |
247 |
const_reference operator()(size_t row, size_t column) const |
2147 |
17 Jan 10 |
peter |
248 |
{ return element_; } |
2147 |
17 Jan 10 |
peter |
249 |
|
2147 |
17 Jan 10 |
peter |
250 |
protected: |
2147 |
17 Jan 10 |
peter |
251 |
T element_; |
2147 |
17 Jan 10 |
peter |
252 |
}; |
2147 |
17 Jan 10 |
peter |
253 |
|
2147 |
17 Jan 10 |
peter |
254 |
/* |
2147 |
17 Jan 10 |
peter |
class to test (at compile time) that a function (or class) works |
2147 |
17 Jan 10 |
peter |
with a MutableContainer2D. Do not run any test using this class because |
2147 |
17 Jan 10 |
peter |
the class is not really functional at run time. |
2147 |
17 Jan 10 |
peter |
258 |
|
2147 |
17 Jan 10 |
peter |
\see boost/concept_archetype.hpp |
2147 |
17 Jan 10 |
peter |
260 |
*/ |
2147 |
17 Jan 10 |
peter |
261 |
template<typename T> |
2147 |
17 Jan 10 |
peter |
262 |
class mutable_container2d_archetype : public container2d_archetype<T> |
2147 |
17 Jan 10 |
peter |
263 |
{ |
2147 |
17 Jan 10 |
peter |
264 |
public: |
2147 |
17 Jan 10 |
peter |
265 |
typedef T& reference; |
3149 |
23 Dec 13 |
peter |
266 |
typedef T* iterator; |
2147 |
17 Jan 10 |
peter |
267 |
typedef iterator column_iterator; |
2147 |
17 Jan 10 |
peter |
268 |
typedef iterator row_iterator; |
2147 |
17 Jan 10 |
peter |
269 |
iterator begin(void) { return &this->element_; } |
2147 |
17 Jan 10 |
peter |
270 |
column_iterator begin_column(size_t) { return &this->element_; } |
2147 |
17 Jan 10 |
peter |
271 |
iterator begin_row(size_t) { return &this->element_; } |
2147 |
17 Jan 10 |
peter |
272 |
iterator end(void) { return NULL; } |
2147 |
17 Jan 10 |
peter |
273 |
column_iterator end_column(size_t) { return NULL; } |
2147 |
17 Jan 10 |
peter |
274 |
iterator end_row(size_t) { return NULL; } |
2260 |
25 May 10 |
peter |
275 |
reference operator()(size_t row, size_t column) |
2147 |
17 Jan 10 |
peter |
276 |
{ return this->element_; } |
2147 |
17 Jan 10 |
peter |
277 |
}; |
2147 |
17 Jan 10 |
peter |
278 |
|
2338 |
16 Oct 10 |
peter |
279 |
/* |
2338 |
16 Oct 10 |
peter |
class to test (at compile time) that a function (or class) works |
2338 |
16 Oct 10 |
peter |
with a Distance. Do not run any test using this class because |
2338 |
16 Oct 10 |
peter |
the class is not really functional at run time. |
2338 |
16 Oct 10 |
peter |
283 |
|
2338 |
16 Oct 10 |
peter |
\see boost/concept_archetype.hpp |
2338 |
16 Oct 10 |
peter |
285 |
*/ |
2338 |
16 Oct 10 |
peter |
286 |
class distance_archetype |
2338 |
16 Oct 10 |
peter |
287 |
{ |
2338 |
16 Oct 10 |
peter |
288 |
public: |
2338 |
16 Oct 10 |
peter |
/// class must be constructible somehow, but we don't wanna assume |
2338 |
16 Oct 10 |
peter |
/// void constructor or any other common constructor so we use the |
2338 |
16 Oct 10 |
peter |
/// signature to allow construction without assuming too much. |
2338 |
16 Oct 10 |
peter |
292 |
distance_archetype(const boost::detail::dummy_constructor&) {}; |
2338 |
16 Oct 10 |
peter |
293 |
distance_archetype(const distance_archetype&) {}; |
2338 |
16 Oct 10 |
peter |
294 |
template<typename T1, typename T2> |
2338 |
16 Oct 10 |
peter |
295 |
double operator()(T1 first1, T1 last1, T2 first2) const { return 0.0; } |
2338 |
16 Oct 10 |
peter |
296 |
private: |
2338 |
16 Oct 10 |
peter |
297 |
distance_archetype(void); |
2338 |
16 Oct 10 |
peter |
298 |
distance_archetype& operator=(const distance_archetype&); |
2338 |
16 Oct 10 |
peter |
299 |
}; |
2338 |
16 Oct 10 |
peter |
300 |
|
2339 |
16 Oct 10 |
peter |
301 |
/* |
2339 |
16 Oct 10 |
peter |
class to test (at compile time) that a function (or class) works |
2339 |
16 Oct 10 |
peter |
with a NeighborWeighting. Do not run any test using this class because |
2339 |
16 Oct 10 |
peter |
the class is not really functional at run time. |
2339 |
16 Oct 10 |
peter |
305 |
|
2339 |
16 Oct 10 |
peter |
\see boost/concept_archetype.hpp |
2339 |
16 Oct 10 |
peter |
307 |
*/ |
2339 |
16 Oct 10 |
peter |
308 |
class neighbor_weighting_archetype |
2339 |
16 Oct 10 |
peter |
309 |
{ |
2339 |
16 Oct 10 |
peter |
310 |
public: |
2339 |
16 Oct 10 |
peter |
311 |
neighbor_weighting_archetype(void) {} |
3149 |
23 Dec 13 |
peter |
312 |
void operator()(const utility::VectorBase& distance, |
2339 |
16 Oct 10 |
peter |
313 |
const std::vector<size_t>& k_sorted, |
3149 |
23 Dec 13 |
peter |
314 |
const classifier::Target& target, |
2339 |
16 Oct 10 |
peter |
315 |
utility::VectorMutable& prediction) const {} |
2339 |
16 Oct 10 |
peter |
316 |
neighbor_weighting_archetype& operator=(const neighbor_weighting_archetype&) |
2339 |
16 Oct 10 |
peter |
317 |
{ return *this; } |
2339 |
16 Oct 10 |
peter |
318 |
private: |
2339 |
16 Oct 10 |
peter |
319 |
neighbor_weighting_archetype(const neighbor_weighting_archetype&) {}; |
2339 |
16 Oct 10 |
peter |
320 |
}; |
2339 |
16 Oct 10 |
peter |
321 |
|
3458 |
19 Jan 16 |
peter |
322 |
|
3459 |
21 Jan 16 |
peter |
// compilation tests on iterators |
3458 |
19 Jan 16 |
peter |
324 |
|
3273 |
04 Jul 14 |
peter |
325 |
template<typename Iterator> |
3273 |
04 Jul 14 |
peter |
326 |
void test_readable_iterator(Iterator iterator) |
3273 |
04 Jul 14 |
peter |
327 |
{ |
3273 |
04 Jul 14 |
peter |
328 |
BOOST_CONCEPT_ASSERT((boost_concepts::ReadableIterator<Iterator>)); |
3273 |
04 Jul 14 |
peter |
329 |
} |
3273 |
04 Jul 14 |
peter |
330 |
|
3458 |
19 Jan 16 |
peter |
331 |
|
3273 |
04 Jul 14 |
peter |
332 |
template<typename Iterator> |
3273 |
04 Jul 14 |
peter |
333 |
void test_writable_iterator(Iterator iterator) |
3458 |
19 Jan 16 |
peter |
334 |
{ |
3458 |
19 Jan 16 |
peter |
335 |
BOOST_CONCEPT_ASSERT((boost_concepts::WritableIterator<Iterator>)); |
3458 |
19 Jan 16 |
peter |
336 |
} |
3273 |
04 Jul 14 |
peter |
337 |
|
3458 |
19 Jan 16 |
peter |
338 |
|
3273 |
04 Jul 14 |
peter |
339 |
template<typename Iterator> |
3273 |
04 Jul 14 |
peter |
340 |
void test_swappable_iterator(Iterator iterator) |
3273 |
04 Jul 14 |
peter |
341 |
{ |
3273 |
04 Jul 14 |
peter |
342 |
BOOST_CONCEPT_ASSERT((boost_concepts::SwappableIterator<Iterator>)); |
3273 |
04 Jul 14 |
peter |
343 |
} |
3273 |
04 Jul 14 |
peter |
344 |
|
3273 |
04 Jul 14 |
peter |
345 |
template<typename Iterator> |
3273 |
04 Jul 14 |
peter |
346 |
void test_lvalue_iterator(Iterator iterator) |
3273 |
04 Jul 14 |
peter |
347 |
{ |
3273 |
04 Jul 14 |
peter |
348 |
BOOST_CONCEPT_ASSERT((boost_concepts::LvalueIterator<Iterator>)); |
3273 |
04 Jul 14 |
peter |
349 |
} |
3273 |
04 Jul 14 |
peter |
350 |
|
3273 |
04 Jul 14 |
peter |
351 |
template<typename Iterator> |
3273 |
04 Jul 14 |
peter |
352 |
void test_incrementable_iterator(Iterator iterator) |
3273 |
04 Jul 14 |
peter |
353 |
{ |
3273 |
04 Jul 14 |
peter |
354 |
BOOST_CONCEPT_ASSERT((boost_concepts::IncrementableIterator<Iterator>)); |
3273 |
04 Jul 14 |
peter |
355 |
} |
3273 |
04 Jul 14 |
peter |
356 |
|
3273 |
04 Jul 14 |
peter |
357 |
template<typename Iterator> |
3273 |
04 Jul 14 |
peter |
358 |
void test_single_pass_iterator(Iterator iterator) |
3273 |
04 Jul 14 |
peter |
359 |
{ |
3273 |
04 Jul 14 |
peter |
360 |
BOOST_CONCEPT_ASSERT((boost_concepts::SinglePassIterator<Iterator>)); |
3273 |
04 Jul 14 |
peter |
361 |
} |
3273 |
04 Jul 14 |
peter |
362 |
|
3273 |
04 Jul 14 |
peter |
363 |
|
3273 |
04 Jul 14 |
peter |
364 |
template<typename Iterator> |
3273 |
04 Jul 14 |
peter |
365 |
void test_forward_traversal_iterator(Iterator iterator) |
3273 |
04 Jul 14 |
peter |
366 |
{ |
3273 |
04 Jul 14 |
peter |
367 |
BOOST_CONCEPT_ASSERT((boost_concepts::ForwardTraversal<Iterator>)); |
3273 |
04 Jul 14 |
peter |
368 |
} |
3273 |
04 Jul 14 |
peter |
369 |
|
3273 |
04 Jul 14 |
peter |
370 |
|
3273 |
04 Jul 14 |
peter |
371 |
template<typename Iterator> |
3273 |
04 Jul 14 |
peter |
372 |
void test_bidirectional_traversal_iterator(Iterator iterator) |
3273 |
04 Jul 14 |
peter |
373 |
{ |
3273 |
04 Jul 14 |
peter |
374 |
BOOST_CONCEPT_ASSERT((boost_concepts::BidirectionalTraversal<Iterator>)); |
3273 |
04 Jul 14 |
peter |
375 |
} |
3273 |
04 Jul 14 |
peter |
376 |
|
3273 |
04 Jul 14 |
peter |
377 |
|
3273 |
04 Jul 14 |
peter |
378 |
template<typename Iterator> |
3273 |
04 Jul 14 |
peter |
379 |
void test_random_access_traversal_iterator(Iterator iterator) |
3273 |
04 Jul 14 |
peter |
380 |
{ |
3273 |
04 Jul 14 |
peter |
381 |
BOOST_CONCEPT_ASSERT((boost_concepts::RandomAccessTraversal<Iterator>)); |
3273 |
04 Jul 14 |
peter |
382 |
} |
3273 |
04 Jul 14 |
peter |
383 |
|
3458 |
19 Jan 16 |
peter |
384 |
|
3458 |
19 Jan 16 |
peter |
// This function pulls out the iterator_category and checks that the |
3458 |
19 Jan 16 |
peter |
// iterator has implemented what is promised in the category. |
3458 |
19 Jan 16 |
peter |
387 |
// |
3459 |
21 Jan 16 |
peter |
// Likewise it pulls out the boost::iterator_traversal type and |
3459 |
21 Jan 16 |
peter |
// checks that the traversal is implemented as promised. |
3459 |
21 Jan 16 |
peter |
390 |
// |
3459 |
21 Jan 16 |
peter |
// Iterator is a model of input iterator (output iterator makes no |
3459 |
21 Jan 16 |
peter |
// sense as a const iterator) |
3458 |
19 Jan 16 |
peter |
393 |
template<typename Iterator> |
3458 |
19 Jan 16 |
peter |
394 |
void test_const_iterator(Iterator iterator); |
3458 |
19 Jan 16 |
peter |
395 |
|
3458 |
19 Jan 16 |
peter |
396 |
|
3459 |
21 Jan 16 |
peter |
// Similar to test_const_iterator but function also works for |
3459 |
21 Jan 16 |
peter |
// output_iterator and it tests that the iterator is mutable. |
3458 |
19 Jan 16 |
peter |
399 |
template<typename Iterator> |
3458 |
19 Jan 16 |
peter |
400 |
void test_mutable_iterator(Iterator iterator); |
3458 |
19 Jan 16 |
peter |
401 |
|
3459 |
21 Jan 16 |
peter |
// functions used by test_const_iterator and test_mutable_iterator |
3458 |
19 Jan 16 |
peter |
403 |
namespace detail { |
3458 |
19 Jan 16 |
peter |
404 |
|
3458 |
19 Jan 16 |
peter |
405 |
template<typename Iterator> |
3459 |
21 Jan 16 |
peter |
406 |
void test_iterator_traversal(Iterator iterator, |
3459 |
21 Jan 16 |
peter |
407 |
boost::incrementable_traversal_tag tag) |
3458 |
19 Jan 16 |
peter |
408 |
{ |
3459 |
21 Jan 16 |
peter |
409 |
test_incrementable_iterator(iterator); |
3458 |
19 Jan 16 |
peter |
410 |
} |
3458 |
19 Jan 16 |
peter |
411 |
|
3458 |
19 Jan 16 |
peter |
412 |
|
3458 |
19 Jan 16 |
peter |
413 |
template<typename Iterator> |
3459 |
21 Jan 16 |
peter |
414 |
void test_iterator_traversal(Iterator iterator, |
3459 |
21 Jan 16 |
peter |
415 |
boost::single_pass_traversal_tag tag) |
3458 |
19 Jan 16 |
peter |
416 |
{ |
3459 |
21 Jan 16 |
peter |
417 |
test_single_pass_iterator(iterator); |
3458 |
19 Jan 16 |
peter |
418 |
} |
3458 |
19 Jan 16 |
peter |
419 |
|
3458 |
19 Jan 16 |
peter |
420 |
|
3458 |
19 Jan 16 |
peter |
421 |
template<typename Iterator> |
3459 |
21 Jan 16 |
peter |
422 |
void test_iterator_traversal(Iterator iterator, |
3459 |
21 Jan 16 |
peter |
423 |
boost::forward_traversal_tag tag) |
3458 |
19 Jan 16 |
peter |
424 |
{ |
3459 |
21 Jan 16 |
peter |
425 |
test_forward_traversal_iterator(iterator); |
3458 |
19 Jan 16 |
peter |
426 |
} |
3458 |
19 Jan 16 |
peter |
427 |
|
3458 |
19 Jan 16 |
peter |
428 |
|
3458 |
19 Jan 16 |
peter |
429 |
template<typename Iterator> |
3459 |
21 Jan 16 |
peter |
430 |
void test_iterator_traversal(Iterator iterator, |
3459 |
21 Jan 16 |
peter |
431 |
boost::bidirectional_traversal_tag tag) |
3458 |
19 Jan 16 |
peter |
432 |
{ |
3459 |
21 Jan 16 |
peter |
433 |
test_bidirectional_traversal_iterator(iterator); |
3458 |
19 Jan 16 |
peter |
434 |
} |
3458 |
19 Jan 16 |
peter |
435 |
|
3458 |
19 Jan 16 |
peter |
436 |
|
3458 |
19 Jan 16 |
peter |
437 |
template<typename Iterator> |
3459 |
21 Jan 16 |
peter |
438 |
void test_iterator_traversal(Iterator iterator, |
3459 |
21 Jan 16 |
peter |
439 |
boost::random_access_traversal_tag tag) |
3458 |
19 Jan 16 |
peter |
440 |
{ |
3459 |
21 Jan 16 |
peter |
441 |
test_random_access_traversal_iterator(iterator); |
3458 |
19 Jan 16 |
peter |
442 |
} |
3458 |
19 Jan 16 |
peter |
443 |
|
3458 |
19 Jan 16 |
peter |
444 |
|
3458 |
19 Jan 16 |
peter |
445 |
template<typename Iterator> |
3459 |
21 Jan 16 |
peter |
446 |
void test_iterator(Iterator iterator, std::forward_iterator_tag tag) |
3458 |
19 Jan 16 |
peter |
447 |
{ |
3458 |
19 Jan 16 |
peter |
448 |
test_lvalue_iterator(iterator); |
4345 |
19 Apr 23 |
peter |
449 |
test_forward_traversal_iterator(iterator); |
3458 |
19 Jan 16 |
peter |
450 |
} |
3458 |
19 Jan 16 |
peter |
451 |
|
3458 |
19 Jan 16 |
peter |
452 |
|
3458 |
19 Jan 16 |
peter |
453 |
template<typename Iterator> |
3459 |
21 Jan 16 |
peter |
454 |
void test_iterator(Iterator iterator, std::bidirectional_iterator_tag tag) |
3458 |
19 Jan 16 |
peter |
455 |
{ |
3459 |
21 Jan 16 |
peter |
456 |
test_lvalue_iterator(iterator); |
4345 |
19 Apr 23 |
peter |
457 |
test_bidirectional_traversal_iterator(iterator); |
3458 |
19 Jan 16 |
peter |
458 |
} |
3458 |
19 Jan 16 |
peter |
459 |
|
3458 |
19 Jan 16 |
peter |
460 |
|
3458 |
19 Jan 16 |
peter |
461 |
template<typename Iterator> |
3459 |
21 Jan 16 |
peter |
462 |
void test_iterator(Iterator iterator, std::random_access_iterator_tag tag) |
3458 |
19 Jan 16 |
peter |
463 |
{ |
3458 |
19 Jan 16 |
peter |
464 |
test_lvalue_iterator(iterator); |
4345 |
19 Apr 23 |
peter |
465 |
test_random_access_traversal_iterator(iterator); |
3458 |
19 Jan 16 |
peter |
466 |
} |
3458 |
19 Jan 16 |
peter |
467 |
|
3458 |
19 Jan 16 |
peter |
468 |
|
3459 |
21 Jan 16 |
peter |
// testing forward iterator (or bidirectional or random access) |
3458 |
19 Jan 16 |
peter |
470 |
template<typename Iterator> |
3459 |
21 Jan 16 |
peter |
471 |
void test_iterator(Iterator iterator) |
3458 |
19 Jan 16 |
peter |
472 |
{ |
3459 |
21 Jan 16 |
peter |
473 |
typename boost::iterator_category<Iterator>::type tag; |
3459 |
21 Jan 16 |
peter |
474 |
test_iterator(iterator, tag); |
3459 |
21 Jan 16 |
peter |
475 |
typename boost::iterator_traversal<Iterator>::type trav_tag; |
3459 |
21 Jan 16 |
peter |
476 |
test_iterator_traversal(iterator, trav_tag); |
3459 |
21 Jan 16 |
peter |
477 |
} |
3459 |
21 Jan 16 |
peter |
478 |
|
3459 |
21 Jan 16 |
peter |
479 |
|
3459 |
21 Jan 16 |
peter |
480 |
template<typename Iterator> |
3459 |
21 Jan 16 |
peter |
481 |
void test_mutable_iterator(Iterator iterator, std::output_iterator_tag tag) |
3459 |
21 Jan 16 |
peter |
482 |
{ |
3458 |
19 Jan 16 |
peter |
483 |
test_incrementable_iterator(iterator); |
3458 |
19 Jan 16 |
peter |
484 |
} |
3458 |
19 Jan 16 |
peter |
485 |
|
3458 |
19 Jan 16 |
peter |
486 |
|
3458 |
19 Jan 16 |
peter |
487 |
template<typename Iterator> |
3459 |
21 Jan 16 |
peter |
488 |
void test_mutable_iterator(Iterator iterator, std::input_iterator_tag tag) |
3458 |
19 Jan 16 |
peter |
489 |
{ |
3458 |
19 Jan 16 |
peter |
490 |
test_single_pass_iterator(iterator); |
3458 |
19 Jan 16 |
peter |
491 |
} |
3458 |
19 Jan 16 |
peter |
492 |
|
3458 |
19 Jan 16 |
peter |
493 |
|
3458 |
19 Jan 16 |
peter |
494 |
template<typename Iterator> |
3459 |
21 Jan 16 |
peter |
495 |
void test_mutable_iterator(Iterator iterator, std::forward_iterator_tag tag) |
3458 |
19 Jan 16 |
peter |
496 |
{ |
3459 |
21 Jan 16 |
peter |
497 |
test_lvalue_iterator(iterator); |
3459 |
21 Jan 16 |
peter |
498 |
test_iterator(iterator); |
3458 |
19 Jan 16 |
peter |
499 |
} |
3458 |
19 Jan 16 |
peter |
500 |
|
3458 |
19 Jan 16 |
peter |
501 |
|
3458 |
19 Jan 16 |
peter |
502 |
template<typename Iterator> |
3459 |
21 Jan 16 |
peter |
503 |
void test_const_iterator(Iterator iterator, std::input_iterator_tag tag) |
3458 |
19 Jan 16 |
peter |
504 |
{ |
3459 |
21 Jan 16 |
peter |
505 |
test_single_pass_iterator(iterator); |
3459 |
21 Jan 16 |
peter |
506 |
test_readable_iterator(iterator); |
3458 |
19 Jan 16 |
peter |
507 |
} |
3458 |
19 Jan 16 |
peter |
508 |
|
3458 |
19 Jan 16 |
peter |
509 |
|
3458 |
19 Jan 16 |
peter |
510 |
template<typename Iterator> |
3459 |
21 Jan 16 |
peter |
511 |
void test_const_iterator(Iterator iterator, std::forward_iterator_tag tag) |
3458 |
19 Jan 16 |
peter |
512 |
{ |
3459 |
21 Jan 16 |
peter |
513 |
test_lvalue_iterator(iterator); |
3459 |
21 Jan 16 |
peter |
514 |
test_iterator(iterator); |
3458 |
19 Jan 16 |
peter |
515 |
} |
3458 |
19 Jan 16 |
peter |
516 |
|
3459 |
21 Jan 16 |
peter |
517 |
|
3458 |
19 Jan 16 |
peter |
518 |
} // end of namespace detail |
3458 |
19 Jan 16 |
peter |
519 |
|
3458 |
19 Jan 16 |
peter |
520 |
|
2147 |
17 Jan 10 |
peter |
// template implementations |
2147 |
17 Jan 10 |
peter |
522 |
|
3723 |
05 Feb 18 |
peter |
523 |
template<class MATRIX1, class MATRIX2> |
3723 |
05 Feb 18 |
peter |
524 |
bool Suite::equal_matrix(const MATRIX1& a, const MATRIX2& b, |
3723 |
05 Feb 18 |
peter |
525 |
unsigned long int N) |
3723 |
05 Feb 18 |
peter |
526 |
{ |
3723 |
05 Feb 18 |
peter |
527 |
if (a.rows() != b.rows() || a.columns() != b.columns()) { |
3723 |
05 Feb 18 |
peter |
528 |
err() << "incorrect dimensions: " |
3723 |
05 Feb 18 |
peter |
529 |
<< a.rows() << " x " << a.columns() << " : " |
3723 |
05 Feb 18 |
peter |
530 |
<< b.rows() << " x " << b.columns() << "\n"; |
3723 |
05 Feb 18 |
peter |
531 |
return false; |
3723 |
05 Feb 18 |
peter |
532 |
} |
3723 |
05 Feb 18 |
peter |
533 |
for (size_t i=0; i<a.rows(); ++i) |
3723 |
05 Feb 18 |
peter |
534 |
for (size_t j=0; j<a.columns(); ++j) |
3723 |
05 Feb 18 |
peter |
535 |
if (!equal(a(i,j), b(i,j), N)) { |
3723 |
05 Feb 18 |
peter |
536 |
err() << " Matrix comparison: row: " << i << " column: " << j |
3723 |
05 Feb 18 |
peter |
537 |
<< "\n"; |
3723 |
05 Feb 18 |
peter |
538 |
return false; |
3723 |
05 Feb 18 |
peter |
539 |
} |
3723 |
05 Feb 18 |
peter |
540 |
return true; |
3723 |
05 Feb 18 |
peter |
541 |
} |
3723 |
05 Feb 18 |
peter |
542 |
|
3723 |
05 Feb 18 |
peter |
543 |
|
1239 |
16 Mar 08 |
peter |
544 |
template<typename Iterator1, typename Iterator2> |
1239 |
16 Mar 08 |
peter |
545 |
bool Suite::equal_range(Iterator1 first1, Iterator1 last1, Iterator2 first2, |
1239 |
16 Mar 08 |
peter |
546 |
unsigned int N) |
1239 |
16 Mar 08 |
peter |
547 |
{ |
1239 |
16 Mar 08 |
peter |
548 |
while (first1!=last1){ |
1239 |
16 Mar 08 |
peter |
549 |
if (!this->equal(*first1, *first2, N) ) { |
1239 |
16 Mar 08 |
peter |
550 |
return false; |
1239 |
16 Mar 08 |
peter |
551 |
} |
1239 |
16 Mar 08 |
peter |
552 |
++first1; |
1239 |
16 Mar 08 |
peter |
553 |
++first2; |
1239 |
16 Mar 08 |
peter |
554 |
} |
1239 |
16 Mar 08 |
peter |
555 |
return true; |
1239 |
16 Mar 08 |
peter |
556 |
} |
1239 |
16 Mar 08 |
peter |
557 |
|
1360 |
26 Jun 08 |
peter |
558 |
|
1658 |
17 Dec 08 |
peter |
559 |
template<typename Iterator1, typename Iterator2> |
4200 |
19 Aug 22 |
peter |
560 |
bool Suite::equal_range_fix(Iterator1 first1, Iterator1 last1, |
1658 |
17 Dec 08 |
peter |
561 |
Iterator2 first2, double margin) |
1658 |
17 Dec 08 |
peter |
562 |
{ |
1658 |
17 Dec 08 |
peter |
563 |
while (first1!=last1){ |
1658 |
17 Dec 08 |
peter |
564 |
if (!this->equal_fix(*first1, *first2, margin) ) { |
1658 |
17 Dec 08 |
peter |
565 |
return false; |
1658 |
17 Dec 08 |
peter |
566 |
} |
1658 |
17 Dec 08 |
peter |
567 |
++first1; |
1658 |
17 Dec 08 |
peter |
568 |
++first2; |
1658 |
17 Dec 08 |
peter |
569 |
} |
1658 |
17 Dec 08 |
peter |
570 |
return true; |
1658 |
17 Dec 08 |
peter |
571 |
} |
1658 |
17 Dec 08 |
peter |
572 |
|
1658 |
17 Dec 08 |
peter |
573 |
|
1998 |
13 Jun 09 |
peter |
// return true if we can write to a write-protected file |
1998 |
13 Jun 09 |
peter |
575 |
bool run_as_root(void); |
1998 |
13 Jun 09 |
peter |
576 |
|
3103 |
02 Nov 13 |
peter |
// function that can be used to avoid warning: '-Wunused-but-set-variable' |
3103 |
02 Nov 13 |
peter |
578 |
template<typename T> |
3322 |
06 Oct 14 |
peter |
579 |
void avoid_compiler_warning(T) {} |
3103 |
02 Nov 13 |
peter |
580 |
|
1360 |
26 Jun 08 |
peter |
581 |
template<class T> |
1360 |
26 Jun 08 |
peter |
582 |
bool Suite::test_stream(const T& t) const |
1360 |
26 Jun 08 |
peter |
583 |
{ |
1360 |
26 Jun 08 |
peter |
584 |
this->err() << "Checking that output stream is valid as an input stream\n"; |
1360 |
26 Jun 08 |
peter |
585 |
std::stringstream ss; |
1360 |
26 Jun 08 |
peter |
586 |
this->err() << "writing to output\n"; |
1360 |
26 Jun 08 |
peter |
587 |
ss << t; |
1360 |
26 Jun 08 |
peter |
588 |
this->err() << "creating a new object from output\n"; |
1360 |
26 Jun 08 |
peter |
589 |
T t2(ss); |
1360 |
26 Jun 08 |
peter |
590 |
std::stringstream ss2; |
1360 |
26 Jun 08 |
peter |
591 |
this->err() << "writing to output\n"; |
1360 |
26 Jun 08 |
peter |
592 |
ss2 << t2; |
1360 |
26 Jun 08 |
peter |
593 |
bool ok = ss2.str()==ss.str(); |
1360 |
26 Jun 08 |
peter |
594 |
if (!ok) { |
3149 |
23 Dec 13 |
peter |
595 |
this->err() << "ERROR: first object gave following output:\n" |
1360 |
26 Jun 08 |
peter |
596 |
<< ss.str() << "\n" |
3149 |
23 Dec 13 |
peter |
597 |
<< "ERROR: and second object gave following output:\n" |
1360 |
26 Jun 08 |
peter |
598 |
<< ss2.str() << "\n"; |
1360 |
26 Jun 08 |
peter |
599 |
} |
1360 |
26 Jun 08 |
peter |
600 |
return ok; |
1360 |
26 Jun 08 |
peter |
601 |
} |
1360 |
26 Jun 08 |
peter |
602 |
|
1877 |
21 Mar 09 |
peter |
603 |
template<typename TrivialIterator> |
1877 |
21 Mar 09 |
peter |
604 |
void Suite::test_trivial_iterator(const TrivialIterator& iter) |
1877 |
21 Mar 09 |
peter |
605 |
{ |
1877 |
21 Mar 09 |
peter |
606 |
err() << " testing Trivial features" << std::endl; |
1877 |
21 Mar 09 |
peter |
607 |
typename std::iterator_traits<TrivialIterator>::value_type tmp = *iter; |
3878 |
12 Mar 20 |
peter |
608 |
avoid_compiler_warning(tmp); |
2202 |
21 Feb 10 |
peter |
609 |
TrivialIterator default_constructed; |
3322 |
06 Oct 14 |
peter |
610 |
avoid_compiler_warning(default_constructed); |
1877 |
21 Mar 09 |
peter |
611 |
} |
3149 |
23 Dec 13 |
peter |
612 |
|
1877 |
21 Mar 09 |
peter |
613 |
template<typename InputIterator> |
1877 |
21 Mar 09 |
peter |
614 |
void Suite::test_input_iterator(InputIterator& iter) |
1877 |
21 Mar 09 |
peter |
615 |
{ |
3273 |
04 Jul 14 |
peter |
616 |
BOOST_CONCEPT_ASSERT((boost::InputIterator<InputIterator>)); |
1877 |
21 Mar 09 |
peter |
617 |
test_trivial_iterator(iter); |
1877 |
21 Mar 09 |
peter |
618 |
err() << " testing Input features" << std::endl; |
1877 |
21 Mar 09 |
peter |
// just to check compilation |
1877 |
21 Mar 09 |
peter |
620 |
if (false) { |
1877 |
21 Mar 09 |
peter |
621 |
++iter; |
1877 |
21 Mar 09 |
peter |
622 |
iter++; |
1877 |
21 Mar 09 |
peter |
623 |
} |
1877 |
21 Mar 09 |
peter |
624 |
} |
3149 |
23 Dec 13 |
peter |
625 |
|
1877 |
21 Mar 09 |
peter |
626 |
template<typename OutputIterator> |
1877 |
21 Mar 09 |
peter |
627 |
void Suite::test_output_iterator(OutputIterator& iter) |
1877 |
21 Mar 09 |
peter |
628 |
{ |
1877 |
21 Mar 09 |
peter |
629 |
err() << " testing Output features" << std::endl; |
3149 |
23 Dec 13 |
peter |
// OutputIterator should be default constructible and assignable |
3149 |
23 Dec 13 |
peter |
631 |
OutputIterator oi; |
3149 |
23 Dec 13 |
peter |
632 |
oi = iter; |
3149 |
23 Dec 13 |
peter |
633 |
++oi; |
1877 |
21 Mar 09 |
peter |
634 |
} |
3149 |
23 Dec 13 |
peter |
635 |
|
1877 |
21 Mar 09 |
peter |
636 |
template<typename ForwardIterator> |
1877 |
21 Mar 09 |
peter |
637 |
void Suite::test_forward_iterator(ForwardIterator iter) |
1877 |
21 Mar 09 |
peter |
638 |
{ |
3273 |
04 Jul 14 |
peter |
639 |
BOOST_CONCEPT_ASSERT((boost::ForwardIterator<ForwardIterator>)); |
1877 |
21 Mar 09 |
peter |
640 |
test_output_iterator(iter); |
1877 |
21 Mar 09 |
peter |
641 |
test_input_iterator(iter); |
1877 |
21 Mar 09 |
peter |
642 |
err() << " testing Forward features" << std::endl; |
3149 |
23 Dec 13 |
peter |
643 |
|
1877 |
21 Mar 09 |
peter |
644 |
typename std::iterator_traits<ForwardIterator>::value_type tmp = *iter; |
1877 |
21 Mar 09 |
peter |
// testing multiple traversing is possible and does not change the data |
1877 |
21 Mar 09 |
peter |
646 |
ForwardIterator iter1 = iter; |
1877 |
21 Mar 09 |
peter |
647 |
++iter1; |
1877 |
21 Mar 09 |
peter |
648 |
add(iter!=iter1); |
1877 |
21 Mar 09 |
peter |
649 |
ForwardIterator iter2 = iter; |
1877 |
21 Mar 09 |
peter |
650 |
++iter2; |
1877 |
21 Mar 09 |
peter |
651 |
add(tmp==*iter); |
1877 |
21 Mar 09 |
peter |
652 |
} |
3149 |
23 Dec 13 |
peter |
653 |
|
1877 |
21 Mar 09 |
peter |
654 |
template<typename BidirectionalIterator> |
1877 |
21 Mar 09 |
peter |
655 |
void Suite::test_bidirectional_iterator(BidirectionalIterator iter) |
1877 |
21 Mar 09 |
peter |
656 |
{ |
3273 |
04 Jul 14 |
peter |
657 |
BOOST_CONCEPT_ASSERT((boost::BidirectionalIterator<BidirectionalIterator>)); |
1877 |
21 Mar 09 |
peter |
658 |
test_forward_iterator(iter); |
1877 |
21 Mar 09 |
peter |
659 |
bool ok_cached = ok(); |
1877 |
21 Mar 09 |
peter |
660 |
err() << " testing Bidirectional features" << std::endl; |
1877 |
21 Mar 09 |
peter |
661 |
const BidirectionalIterator i = iter; |
2070 |
23 Sep 09 |
peter |
662 |
BidirectionalIterator tmp = iter++; |
2070 |
23 Sep 09 |
peter |
663 |
if (!add(tmp==i)) { |
2070 |
23 Sep 09 |
peter |
664 |
err() << "iter++ does not return iter\n"; |
2070 |
23 Sep 09 |
peter |
665 |
} |
2070 |
23 Sep 09 |
peter |
666 |
if (!add(++tmp==iter)) { |
2070 |
23 Sep 09 |
peter |
667 |
err() << "++iter failed\n"; |
2070 |
23 Sep 09 |
peter |
668 |
} |
2070 |
23 Sep 09 |
peter |
669 |
if (!add(--tmp==i)) { |
2070 |
23 Sep 09 |
peter |
670 |
err() << "--iter failed\n"; |
2070 |
23 Sep 09 |
peter |
671 |
} |
2070 |
23 Sep 09 |
peter |
672 |
tmp = iter--; |
2070 |
23 Sep 09 |
peter |
673 |
if (!add(--tmp==iter)) |
2070 |
23 Sep 09 |
peter |
674 |
err() << "iter-- failed" << std::endl; |
1877 |
21 Mar 09 |
peter |
675 |
if (ok_cached && !ok()) |
1877 |
21 Mar 09 |
peter |
676 |
err() << "failed" << std::endl; |
1877 |
21 Mar 09 |
peter |
677 |
} |
1877 |
21 Mar 09 |
peter |
678 |
|
1877 |
21 Mar 09 |
peter |
679 |
template<typename RandomAccessIterator> |
1877 |
21 Mar 09 |
peter |
680 |
void Suite::test_random_access_iterator(RandomAccessIterator iter) |
1877 |
21 Mar 09 |
peter |
681 |
{ |
3273 |
04 Jul 14 |
peter |
682 |
BOOST_CONCEPT_ASSERT((boost::RandomAccessIterator<RandomAccessIterator>)); |
1877 |
21 Mar 09 |
peter |
683 |
test_bidirectional_iterator(iter); |
1877 |
21 Mar 09 |
peter |
684 |
err() << " testing RandomAccess features" << std::endl; |
1877 |
21 Mar 09 |
peter |
685 |
bool ok_cached = ok(); |
1877 |
21 Mar 09 |
peter |
686 |
RandomAccessIterator iter2 = iter; |
1877 |
21 Mar 09 |
peter |
687 |
iter2 += 1; |
1877 |
21 Mar 09 |
peter |
688 |
iter2 -= 1; |
1877 |
21 Mar 09 |
peter |
689 |
RandomAccessIterator& iter3 = (iter2 += 1); |
1877 |
21 Mar 09 |
peter |
690 |
RandomAccessIterator& iter4 = (iter3 -= 1); |
1877 |
21 Mar 09 |
peter |
691 |
if (!add(iter2 == iter4)) |
1877 |
21 Mar 09 |
peter |
692 |
err() << "operator-(int) failed" << std::endl; |
1877 |
21 Mar 09 |
peter |
693 |
add(++iter2 == iter3); |
3149 |
23 Dec 13 |
peter |
694 |
|
1877 |
21 Mar 09 |
peter |
695 |
RandomAccessIterator iter5 = iter + 0; |
1877 |
21 Mar 09 |
peter |
696 |
RandomAccessIterator iter6 = 0 + iter; |
1877 |
21 Mar 09 |
peter |
697 |
add(iter6 == iter5); |
3149 |
23 Dec 13 |
peter |
698 |
|
1877 |
21 Mar 09 |
peter |
699 |
RandomAccessIterator iter7 = iter - 0; |
1877 |
21 Mar 09 |
peter |
700 |
add(iter7 == iter); |
1877 |
21 Mar 09 |
peter |
701 |
add(iter7 - iter == 0); |
1877 |
21 Mar 09 |
peter |
702 |
add(! (iter7<iter)); |
3149 |
23 Dec 13 |
peter |
703 |
|
1877 |
21 Mar 09 |
peter |
704 |
typename RandomAccessIterator::value_type tmp = iter[0]; |
1877 |
21 Mar 09 |
peter |
705 |
typename RandomAccessIterator::value_type tmp2 = *iter; |
4343 |
16 Apr 23 |
peter |
706 |
tmp = tmp; // avoid compiler warning |
4343 |
16 Apr 23 |
peter |
707 |
if (!add(tmp == tmp2)) |
4343 |
16 Apr 23 |
peter |
708 |
err() << "operator[] failed" << std::endl; |
4343 |
16 Apr 23 |
peter |
709 |
if (!add(iter[0] == *iter)) |
4343 |
16 Apr 23 |
peter |
710 |
err() << "operator[] failed" << std::endl; |
1877 |
21 Mar 09 |
peter |
711 |
if (ok_cached && !ok()) |
1877 |
21 Mar 09 |
peter |
712 |
err() << "failed" << std::endl; |
1877 |
21 Mar 09 |
peter |
713 |
} |
1877 |
21 Mar 09 |
peter |
714 |
|
2143 |
15 Jan 10 |
peter |
715 |
template<typename Container2D> |
2143 |
15 Jan 10 |
peter |
716 |
void Suite::test_concept_container2d(const Container2D& c) |
2143 |
15 Jan 10 |
peter |
717 |
{ |
2143 |
15 Jan 10 |
peter |
718 |
typedef typename Container2D::value_type value_type; |
2143 |
15 Jan 10 |
peter |
719 |
typedef typename Container2D::const_reference const_reference; |
2143 |
15 Jan 10 |
peter |
720 |
typedef typename Container2D::const_iterator const_iterator; |
2143 |
15 Jan 10 |
peter |
721 |
typedef typename Container2D::const_column_iterator const_column_iterator; |
2143 |
15 Jan 10 |
peter |
722 |
typedef typename Container2D::const_row_iterator const_row_iterator; |
2143 |
15 Jan 10 |
peter |
723 |
const_iterator ci = c.begin(); |
2143 |
15 Jan 10 |
peter |
724 |
const_column_iterator cci = c.begin_column(0); |
2143 |
15 Jan 10 |
peter |
725 |
const_row_iterator cri = c.begin_row(0); |
2143 |
15 Jan 10 |
peter |
726 |
ci = c.end(); |
2143 |
15 Jan 10 |
peter |
727 |
cci = c.end_column(0); |
2143 |
15 Jan 10 |
peter |
728 |
cri = c.end_row(0); |
2143 |
15 Jan 10 |
peter |
729 |
size_t cols = c.columns(); |
2143 |
15 Jan 10 |
peter |
730 |
size_t rows = c.rows(); |
3103 |
02 Nov 13 |
peter |
// just to avoid compiler warning |
3322 |
06 Oct 14 |
peter |
732 |
avoid_compiler_warning(cols); |
3322 |
06 Oct 14 |
peter |
733 |
avoid_compiler_warning(rows); |
2143 |
15 Jan 10 |
peter |
734 |
const_reference x = c(0,0); |
2143 |
15 Jan 10 |
peter |
735 |
value_type y; |
2143 |
15 Jan 10 |
peter |
736 |
y = x; |
3322 |
06 Oct 14 |
peter |
737 |
avoid_compiler_warning(y); |
2143 |
15 Jan 10 |
peter |
738 |
} |
2143 |
15 Jan 10 |
peter |
739 |
|
2143 |
15 Jan 10 |
peter |
740 |
template<typename MutableContainer2D> |
2143 |
15 Jan 10 |
peter |
741 |
void Suite::test_concept_mutable_container2d(MutableContainer2D& mc) |
2143 |
15 Jan 10 |
peter |
742 |
{ |
2143 |
15 Jan 10 |
peter |
743 |
test_concept_container2d(mc); |
2143 |
15 Jan 10 |
peter |
744 |
typedef typename MutableContainer2D::reference reference; |
2143 |
15 Jan 10 |
peter |
745 |
typedef typename MutableContainer2D::iterator iterator; |
2143 |
15 Jan 10 |
peter |
746 |
typedef typename MutableContainer2D::column_iterator column_iterator; |
2143 |
15 Jan 10 |
peter |
747 |
typedef typename MutableContainer2D::row_iterator row_iterator; |
2143 |
15 Jan 10 |
peter |
748 |
iterator i = mc.begin(); |
2143 |
15 Jan 10 |
peter |
749 |
column_iterator ci = mc.begin_column(0); |
2143 |
15 Jan 10 |
peter |
750 |
row_iterator ri = mc.begin_row(0); |
3149 |
23 Dec 13 |
peter |
751 |
*i = *ci; |
3149 |
23 Dec 13 |
peter |
752 |
*ci = *i; |
3149 |
23 Dec 13 |
peter |
753 |
*ri = *i; |
2143 |
15 Jan 10 |
peter |
754 |
i = mc.end(); |
2143 |
15 Jan 10 |
peter |
755 |
ci = mc.end_column(0); |
2143 |
15 Jan 10 |
peter |
756 |
ri = mc.end_row(0); |
2143 |
15 Jan 10 |
peter |
757 |
reference x = mc(0,0); |
2143 |
15 Jan 10 |
peter |
758 |
x = *mc.begin(); |
2143 |
15 Jan 10 |
peter |
759 |
} |
2143 |
15 Jan 10 |
peter |
760 |
|
3458 |
19 Jan 16 |
peter |
761 |
|
3458 |
19 Jan 16 |
peter |
762 |
template<typename Iterator> |
3458 |
19 Jan 16 |
peter |
763 |
void test_const_iterator(Iterator iterator) |
3458 |
19 Jan 16 |
peter |
764 |
{ |
3459 |
21 Jan 16 |
peter |
765 |
typename boost::iterator_category<Iterator>::type tag; |
3458 |
19 Jan 16 |
peter |
766 |
detail::test_const_iterator(iterator, tag); |
3458 |
19 Jan 16 |
peter |
767 |
} |
3458 |
19 Jan 16 |
peter |
768 |
|
3458 |
19 Jan 16 |
peter |
769 |
|
3458 |
19 Jan 16 |
peter |
770 |
template<typename Iterator> |
3458 |
19 Jan 16 |
peter |
771 |
void test_mutable_iterator(Iterator iterator) |
3458 |
19 Jan 16 |
peter |
772 |
{ |
3458 |
19 Jan 16 |
peter |
773 |
typename boost::iterator_category<Iterator>::type tag; |
3458 |
19 Jan 16 |
peter |
774 |
detail::test_mutable_iterator(iterator, tag); |
3459 |
21 Jan 16 |
peter |
775 |
test_writable_iterator(iterator); |
3458 |
19 Jan 16 |
peter |
776 |
} |
3458 |
19 Jan 16 |
peter |
777 |
|
3458 |
19 Jan 16 |
peter |
778 |
|
3543 |
23 Dec 16 |
peter |
// For convenience to create data iterator. This class typedefs four |
3543 |
23 Dec 16 |
peter |
// classes that can be conveniently constructed in tests |
3543 |
23 Dec 16 |
peter |
// (const/mutable and weighted/unweighted. Traversal |
3539 |
23 Dec 16 |
peter |
// is expected to be one of: |
3543 |
23 Dec 16 |
peter |
//// boost::incrementable_traversal_tag (problematic with unweighted) |
3543 |
23 Dec 16 |
peter |
// boost::single_pass_traversal_tag (problematic with unweighted) |
3538 |
22 Dec 16 |
peter |
// boost::forward_traversal_tag |
3538 |
22 Dec 16 |
peter |
// boost::bidirectional_traversal_tag |
3538 |
22 Dec 16 |
peter |
// boost::random_access_traversal_tag |
3538 |
22 Dec 16 |
peter |
788 |
template<typename Traversal> |
3543 |
23 Dec 16 |
peter |
789 |
struct DataIterator |
3543 |
23 Dec 16 |
peter |
790 |
{ |
3543 |
23 Dec 16 |
peter |
791 |
typedef boost::iterator_archetype< |
3543 |
23 Dec 16 |
peter |
792 |
double, |
3543 |
23 Dec 16 |
peter |
793 |
boost::iterator_archetypes::readable_iterator_t, |
3543 |
23 Dec 16 |
peter |
794 |
Traversal |
3543 |
23 Dec 16 |
peter |
795 |
> unweighted_const_iterator; |
3538 |
22 Dec 16 |
peter |
796 |
|
3543 |
23 Dec 16 |
peter |
797 |
typedef boost::iterator_archetype< |
3543 |
23 Dec 16 |
peter |
798 |
double, |
3543 |
23 Dec 16 |
peter |
799 |
boost::iterator_archetypes::readable_writable_iterator_t, |
3543 |
23 Dec 16 |
peter |
800 |
Traversal |
3543 |
23 Dec 16 |
peter |
801 |
> unweighted_iterator; |
3538 |
22 Dec 16 |
peter |
802 |
|
3538 |
22 Dec 16 |
peter |
803 |
|
3543 |
23 Dec 16 |
peter |
804 |
typedef utility::WeightedIteratorArchetype< |
3543 |
23 Dec 16 |
peter |
805 |
boost::iterator_archetypes::readable_iterator_t, Traversal |
3543 |
23 Dec 16 |
peter |
806 |
> |
3543 |
23 Dec 16 |
peter |
807 |
weighted_const_iterator; |
3538 |
22 Dec 16 |
peter |
808 |
|
3543 |
23 Dec 16 |
peter |
809 |
typedef utility::WeightedIteratorArchetype< |
3543 |
23 Dec 16 |
peter |
810 |
boost::iterator_archetypes::readable_writable_iterator_t, |
3543 |
23 Dec 16 |
peter |
811 |
Traversal |
3543 |
23 Dec 16 |
peter |
812 |
> |
3543 |
23 Dec 16 |
peter |
813 |
weighted_iterator; |
3543 |
23 Dec 16 |
peter |
814 |
}; |
1215 |
07 Mar 08 |
peter |
815 |
}}} |
1215 |
07 Mar 08 |
peter |
816 |
|
1215 |
07 Mar 08 |
peter |
817 |
#endif |