57#ifndef _RWSTD_NO_EXPLICIT_INSTANTIATION
102 void operator!()
const;
124 res.data_.val_ +=
y.data_.val_;
150template <
class InputIterator,
class OutputIterator>
187 const char*
const itname = alg.
iter_names [0];
188 const char*
const outname = alg.
iter_names [1];
189 const char*
const opname =
"Plus";
192 "std::partial_sum (%s, %1$s, %s%{?}, %s%{;})%{?}, %s%{;}",
193 itname, outname, binop, opname, same_seq,
"first == result");
200 for (std::size_t
i = 0;
i !=
N; ++
i) {
208 const Accumulator*
const pbinop = binop ? &acc : 0;
211 int*
const tmp_val =
new int [
i];
213 tmp_val [
k] = src [
k].data_.val_;
216 alg.
partial_sum (src, src_end, dst, dst_end, pbinop);
221 static const int cwidth =
sizeof (*src);
224 bool success =
res == dst_end;
226 "partial_sum<%s, %s%{?}, %s%{;}>"
227 "({%{X=+*}}, ...) == result + %d, got result %td",
228 itname, outname, binop, opname,
229 cwidth,
int (
i), src, dst_end - dst,
res - dst_end);
232 for (
k = 0;
k <
i; ++
k) {
242 k =
k <
i ?
k :
i - 1;
245 "partial_sum<%s, %s%{?}, %s%{;}>"
246 "({%{X=+*}}, ...) ==> {%{X=+*.*}}, expected %d",
247 itname, outname, binop, opname,
248 cwidth,
int (
i), src,
249 cwidth,
int (
i),
int (
k), dst, sum);
258 const std::size_t exp_plus_ops =
i > 0 ?
i - 1 : 0;
259 success = plus_ops == exp_plus_ops;
261 "partial_sum <%s, %s%{?}, %s%{;}>"
262 "({%{X=+*}}, ...) complexity: got %zu invocations "
263 "of %s, expected %zu",
264 itname, outname, binop, opname,
265 cwidth,
int (
i), src, plus_ops,
266 binop ?
"BinaryPlus" :
"operator+", exp_plus_ops);
290template <
class InputIterator,
class OutputIterator>
306template <
class InputIterator>
331 "template <class %s, class %s%{?}, class %s%{;}> "
332 "%2$s partial_sum (%1$s, %1$s, %2$s%{?}, %s%{;})",
333 "InputIterator",
"OutputIterator", binop,
"BinaryOperation",
334 binop,
"BinaryOperation");
337 rw_note (0, 0, 0,
"OutputIterator test disabled");
340 rw_note (0, 0, 0,
"InputIterator test disabled");
345 rw_note (0, 0, 0,
"ForwardIterator test disabled");
350 rw_note (0, 0, 0,
"BidirectionalIterator test disabled");
355 rw_note (0, 0, 0,
"RandomAccessIterator test disabled");
372 "partial_sum with binary operation test disabled");
381int main (
int argc,
char *argv[])
383 return rw_test (argc, argv, __FILE__,
389 "|-no-InputIterator# "
390 "|-no-OutputIterator# "
391 "|-no-ForwardIterator# "
392 "|-no-BidirectionalIterator# "
393 "|-no-RandomAccessIterator#",
void run_test(const ForwardIterator &dummy, T *, Predicate *pred)
const plus< T > & operator+(const plus< T > &lhs, const plus< T > &rhs)
void gen_partial_sum_test(const std::size_t N, const InputIterator &, const OutputIterator &, bool binop)
int rw_opt_no_output_iter
void test_partial_sum(const std::size_t N, const PartialSumBase &alg, bool binop, bool same_seq)
#define _RWSTD_UNUSED(arg)
#define _RWSTD_NAMESPACE(name)
_TEST_EXPORT int gen_seq()
_TEST_EXPORT int rw_test(int argc, char *argv[], const char *filename, const char *clause, const char *comment, int(*testfun)(int, char **), const char *optspec,...)
_TEST_EXPORT int rw_info(int, const char *, int, const char *,...)
_TEST_EXPORT int rw_note(int, const char *, int, const char *,...)
_TEST_EXPORT int rw_assert(int, const char *, int, const char *,...)
conv_to_T< Y > operator()(const Y &x, const Y &y)
static std::size_t funcalls_
virtual ~PartialSumBase()
virtual UserClass * partial_sum(const UserClass *xsrc, const UserClass *xsrc_end, UserClass *xdst, const UserClass *xdst_end, const Accumulator *op) const =0
const char * iter_names[2]
virtual UserClass * partial_sum(const UserClass *xsrc, const UserClass *xsrc_end, UserClass *xdst, const UserClass *xdst_end, const Accumulator *op) const
static _RWSTD_SIZE_T n_total_op_plus_assign_
static conv_to_T make(T val)