40#ifndef _RWSTD_NO_EXPLICIT_INSTANTIATION
73 operator bool()
const {
return result_; }
93template <
class InputIterator>
101 static const char*
const pname = test_pred ?
"Predicate" :
"operator==";
103 const std::size_t
nsrc = std::strlen (src);
121 const UserClass &to_find = tsrc [findoff];
131 std::find_if (first,
last, pred) : std::find (first,
last, to_find);
139 "line %d: find%{?}_if%{;} (%s = \"%s\", ..., '%c')"
140 " == (it + %zu), got (it + %td)",
141 __LINE__, test_pred, itname, src, to_find.
data_.
val_,
142 findoff,
res.cur_ - first.cur_)) {
153 const std::size_t npreds =
157 "line %d: find%{?}_if%{;} (%s = \"%s\", ..., '%c') "
158 "invoked %s %zu times, expected no more than %zu",
159 __LINE__, test_pred, itname, src, to_find.
data_.
val_,
160 pname, npreds, findoff + 1);
167template <
class InputIterator>
172 rw_info (0, 0, 0,
"std::find%{?}_if%{;} (%s, %2$s, "
173 "%{?}Predicate%{:}const UserClass&%{;})",
174 test_pred, itname, test_pred);
176#define TEST(src, off_find) \
177 test_find (__LINE__, src, std::size_t (off_find), \
178 dummy_iter, test_pred)
198 TEST (
"abcdefgh", 7);
199 TEST (
"abcdefghi", 8);
200 TEST (
"abcdefghij", 9);
201 TEST (
"abcdefghijk", 10);
202 TEST (
"abcdefghijk", -1);
217 "template <class %s, class %s> "
218 "%1$s std::find%{?}_if%{;} (%1$s, %1$s, "
219 "%{?}%2$s%{:}const %2$s&%{;})",
220 "InputIterator", test_pred ?
"Predicate" :
"T",
224 rw_note (0, __FILE__, __LINE__,
"InputIterator test disabled");
231 rw_note (0, __FILE__, __LINE__,
"ForwardIterator test disabled");
239 rw_note (0, __FILE__, __LINE__,
"BidirectionalIterator test disabled");
247 rw_note (0, __FILE__, __LINE__,
"RandomAccessIterator test disabled");
258run_test (
int,
char*[])
263 rw_note (0, __FILE__, __LINE__,
"Predicate test disabled");
274int main (
int argc,
char *argv[])
276 return rw_test (argc, argv, __FILE__,
279 "|-no-InputIterator#"
280 "|-no-ForwardIterator#"
281 "|-no-BidirectionalIterator#"
282 "|-no-RandomAccessIterator#"
const MyBuffer< char > nsrc[]
#define TEST(src, off_find)
void test_find(int line, const char *src, std::size_t findoff, InputIterator dummy_iter, bool test_pred)
#define _RWSTD_UNUSED(arg)
#define _RWSTD_NAMESPACE(name)
ConvertibleToBool(bool res)
_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 *,...)
static std::size_t funcalls_
Predicate(const T &val, int)
static _RWSTD_SIZE_T n_total_op_eq_
static UserClass from_char(char c)