42#ifndef _RWSTD_NO_EXPLICIT_INSTANTIATION
77const char*
const fnames[] = {
"remove",
"remove_copy" };
78const char*
const fnames_if[] = {
"remove_if",
"remove_copy_if" };
114 class ConvertibleToBool {
118 operator bool()
const {
return result_; }
139template <
class Iterator,
class T,
class Predicate>
141 const char *src,
const char val, std::size_t nrem,
146 static const char*
const fname =
tag.use_predicate ?
150 const std::size_t
nsrc = std::strlen (src);
153 T*
const xsrc = T::from_char (src,
nsrc + 1);
157 to_remove.data_.val_ =
val;
171 T::n_total_op_eq_ = 0;
175 ? std::remove_if (first,
last, pred)
176 : std::remove (first,
last, to_remove);
182 static const int cwidth =
sizeof (
T);
185 bool success =
end.cur_ == first.
cur_ + (
nsrc - nrem);
187 "line %d: %s<%s>(\"%s\", ..., %#c) == first + %zu, got %zd",
188 __LINE__, fname, itname, src,
val,
194 for (std::size_t
i = 0;
i !=
nsrc - nrem && success; ++
i) {
195 success =
UChar (
val) != xsrc [
i].data_.val_;
197 "line %d: %s<%s>(\"%s\", ..., %#c) ==> "
198 "\"%{X=*.*}\"; expected element value %#c",
199 __LINE__, fname, itname, src,
val,
200 cwidth,
int (
nsrc),
int (
i), xsrc, src [
i]);
207 for (std::size_t
i = 1;
i <
nsrc - nrem && success; ++
i) {
208 success = xsrc [
i - 1].id_ < xsrc [
i].id_;
210 "line %d: %s<%s>(\"%s\", ..., %#c) ==> \"%{X=#*.*}\"; "
211 "unstable at offset %zu element ids: %d and %d",
212 __LINE__, fname, itname, src,
val,
213 cwidth,
int (
nsrc),
int (
i - 1), xsrc,
214 i - 1, xsrc [
i - 1].id_, xsrc [
i].id_);
221 for (std::size_t
i =
nsrc - nrem;
i !=
nsrc && success; ++
i) {
222 success = src [
i] == xsrc [
i].data_.val_;
224 "line %d: %s<%s>(\"%s\", ..., %#c) ==> "
225 "\"%{X=*.*}\"; expected element value %#c",
226 __LINE__, fname, itname, src,
val,
227 cwidth,
int (
nsrc),
int (
i), xsrc,
val);
232 if (
tag.use_predicate) {
234 "line %d: %s<%s>(\"%s\", ..., %#c) called "
235 "Predicate::operator() %zu times, %zu expected",
236 __LINE__, fname, itname, src,
val,
241 "line %d: %s<%s>(\"%s\", ..., %#c) called "
242 "T::operator< %zu times, %zu expected",
243 __LINE__, fname, itname, src,
val,
244 T::n_total_op_eq_,
nsrc);
253template <
class Iterator,
class OutputIterator,
class Predicate,
class T>
255 const char *src,
const char val, std::size_t nrem,
259 static const char*
const itname =
type_name (it, (
T*)0);
260 static const char*
const fname =
tag.use_predicate ?
263 const std::size_t
nsrc = std::strlen (src);
265 T*
const xsrc = T::from_char (src,
nsrc);
266 T*
const xdst = T::from_char (src,
nsrc);
269 to_remove.data_.val_ =
val;
278 T::n_total_op_eq_ = 0;
281 ? std::remove_copy_if (first,
last,
result, pred)
282 : std::remove_copy (first,
last,
result, to_remove);
288 const int cwidth =
sizeof (
T);
293 "line %d: %s<%s>(\"%s\", ..., %#c) == first + %zu, got %zd",
294 __LINE__, fname, itname, src,
val,
nsrc - nrem,
end.cur_ - xsrc);
299 for (std::size_t
i = 0;
i !=
nsrc - nrem && success; ++
i) {
300 success =
UChar (
val) != xdst [
i].data_.val_;
302 "line %d: %s<%s>(\"%s\", ..., %#c) ==> "
303 "\"%{X=*.*}\"; expected element value %#c",
304 __LINE__, fname, itname, src,
val,
305 cwidth,
int (
nsrc - nrem),
int (
i), xdst, src [
i]);
311 for (std::size_t
i = 1;
i <
nsrc - nrem && success; ++
i) {
312 success = xdst [
i - 1].id_ < xdst [
i].id_;
314 "line %d: %s<%s>(\"%s\", ..., %#c) ==> \"%{X=#*.*}\"; "
315 "unstable at offset %zu: element ids: %d and %d",
316 __LINE__, fname, itname, src,
val,
317 cwidth,
int (
nsrc - nrem),
int (
i - 1), xdst,
318 i - 1, xdst [
i - 1].id_, xdst [
i].id_);
322 if (
tag.use_predicate) {
324 "line %d: %s<%s>(\"%s\", ..., %#c) called "
325 "Predicate::operator() %zu times, %zu expected",
326 __LINE__, fname, itname, src,
val,
331 "line %d: %s<%s>(\"%s\", ..., %#c) called "
332 "T::operator< %zu times, %zu expected",
333 __LINE__, fname, itname, src,
val,
334 T::n_total_op_eq_,
nsrc);
344template <
class Iterator1,
class Iterator2,
class T,
349 static const char*
const it1name =
type_name (it1, (
T*)0);
350 static const char*
const it2name =
type_name (it2, (
T*)0);
354 "std::%s (%s, %2$s, %s, %s)",
355 tag.use_predicate ?
"remove_copy_if" :
"remove_copy",
357 tag.use_predicate ?
"UnaryPredicate" :
"const T&");
361 "std::%s (%s, %2$s, %s)",
362 tag.use_predicate ?
"remove_if" :
"remove",
364 tag.use_predicate ?
"UnaryPredicate" :
"const T&");
367#define TEST(src, val, nremoved) \
368 test_remove (__LINE__, src, val, nremoved, it1, it2, (T*)0, pred, tag)
378 TEST (
"aaa",
'a', 3);
379 TEST (
"aaaa",
'a', 4);
380 TEST (
"aaaaa",
'a', 5);
381 TEST (
"aaaaaa",
'a', 6);
382 TEST (
"aaaaaaa",
'a', 7);
383 TEST (
"aaaaaaaa",
'a', 8);
384 TEST (
"aaaaaaaaa",
'a', 9);
385 TEST (
"aaaaaaaaaa",
'a', 10);
391 TEST (
"abc",
'a', 1);
392 TEST (
"bac",
'a', 1);
393 TEST (
"bca",
'a', 1);
394 TEST (
"aba",
'a', 2);
395 TEST (
"abab",
'a', 2);
396 TEST (
"ababa",
'a', 3);
397 TEST (
"bababa",
'a', 3);
398 TEST (
"bababab",
'a', 3);
399 TEST (
"babababa",
'a', 4);
400 TEST (
"baacaadaaeaa",
'a', 8);
417template <
class T,
class Predicate,
class Tag>
421 "template <class %s, class T> "
422 "std::%s (%1$s, %1$s, %s)",
424 tag.use_predicate ?
"remove_if" :
"remove",
425 tag.use_predicate ?
"Predicate" :
"const T&");
428 rw_note (0, __FILE__, __LINE__,
"ForwardIterator test disabled");
435 rw_note (0, __FILE__, __LINE__,
"BidirectionalIterator test disabled");
442 rw_note (0, __FILE__, __LINE__,
"RandomAccessIterator test disabled");
455 const RemoveTag remove_if_tag = {
true };
458 rw_note (0, __FILE__, __LINE__,
"std::remove test disabled");
466 rw_note (0, __FILE__, __LINE__,
"std::remove_if test disabled");
476template <
class InputIterator,
class T,
class Predicate,
class Tag>
481 rw_note (0, __FILE__, __LINE__,
"OutputIterator test disabled");
488 rw_note (0, __FILE__, __LINE__,
"ForwardIterator test disabled");
495 rw_note (0, __FILE__, __LINE__,
"BidirectionalIterator test disabled");
502 rw_note (0, __FILE__, __LINE__,
"RandomAccessIterator test disabled");
511template <
class T,
class Predicate,
class Tag>
516 "<class InputIterator, class OutputIterator, class T> "
517 "std::%s (InputIterator, InputIterator, "
518 "OutputIterator, %s)",
519 tag.use_predicate ?
"remove_copy_if" :
"remove_copy",
520 tag.use_predicate ?
"Predicate" :
"const T&");
523 rw_note (0, __FILE__, __LINE__,
"InputIterator test disabled");
530 rw_note (0, __FILE__, __LINE__,
"ForwardIterator test disabled");
537 rw_note (0, __FILE__, __LINE__,
"BidirectionalIterator test disabled");
544 rw_note (0, __FILE__, __LINE__,
"RandomAccessIterator test disabled");
560 rw_note (0, __FILE__, __LINE__,
"std::remove_copy test disabled");
568 rw_note (0, __FILE__, __LINE__,
"std::remove_copy_if test disabled");
590int main (
int argc,
char *argv[])
592 return rw_test (argc, argv, __FILE__,
598 "|-no-remove_copy_if# "
599 "|-no-InputIterator# "
600 "|-no-OutputIterator# "
601 "|-no-ForwardIterator# "
602 "|-no-BidirectionalIterator# "
603 "|-no-RandomAccessIterator#",
const MyBuffer< char > nsrc[]
void run_test(const ForwardIterator &dummy, T *, Predicate *pred)
const char *const fnames[]
int rw_opt_no_remove_copy_if
void test_remove(int line, const char *src, const char val, std::size_t nrem, Iterator, NoIterator, const T *, const Predicate *, RemoveTag tag)
const char *const fnames_if[]
int rw_opt_no_remove_copy
#define TEST(src, val, nremoved)
int rw_opt_no_output_iter
void test_remove_copy(const InputIterator &iter, const T *, const Predicate *pred, Tag tag)
#define _RWSTD_UNUSED(arg)
#define _RWSTD_NAMESPACE(name)
ConvertibleToBool(bool res)
T * make_iter(T *cur, const T *, const T *, T *)
_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 *,...)
ConvertibleToBool operator()(const T &x, const U &y)
EqualityPredicate(const T &val, int)
static std::size_t funcalls_
static std::size_t funcalls_