42#ifndef _RWSTD_NO_EXPLICIT_INSTANTIATION
86 void operator= (
Less&);
103 const Less*)
const = 0;
106template <
class InputIterator1,
class InputIterator2,
class OutputIterator>
121 const Less *ppred)
const {
123 const InputIterator1 first1 (xsrc1, xsrc1, xsrc1_end);
124 const InputIterator1 last1 (xsrc1_end, xsrc1, xsrc1_end);
125 const InputIterator2 first2 (xsrc2, xsrc2, xsrc2_end);
126 const InputIterator2 last2 (xsrc2_end, xsrc2, xsrc2_end);
131 std::set_symmetric_difference (first1, last1, first2, last2,
133 : std::set_symmetric_difference (first1, last1, first2, last2,
154 const std::size_t nf,
158 const char*
const it1name = alg.
iter_names [0];
159 const char*
const it2name = alg.
iter_names [1];
160 const char*
const outname = alg.
iter_names [2];
161 const char*
const algname =
"set_symmetric_difference";
162 const char*
const funname =
predicate ?
"Less" : 0;
174 const int max1_id = nsrc1 > 0 ? xsrc1 [nsrc1 - 1].
id_ : -1;
176 UserClass*
const xsrc1_end = xsrc1 + nsrc1;
177 UserClass*
const xsrc2_end = xsrc2 + nsrc2;
182 const Less pred (0, 0);
187 xdst, xdst_end, ppred);
190 bool success = xdst_res == xdst_end;
192 "line %d: %s<%s, %s, %s%{?}, %s%{;}> (\"%s\", \"%s\", ...) "
193 "got res + %td, expected res + %zu",
194 __LINE__, algname, it1name, it2name, outname,
predicate,
195 funname, src1, src2, xdst_res - xdst, ndst);
205 std::size_t n_ops_lt = ppred ?
212 for ( ;
i < ndst;
i++) {
220 i =
i < ndst ?
i : ndst - 1;
222 static const int cwidth =
sizeof (*xdst);
225 "line %d: %s<%s, %s, %s%{?}, %s%{;}> (\"%s\", \"%s\", ...) "
226 " ==> \"%{X=*.*}\", expected \"%s\"",
227 __LINE__, algname, it1name, it2name, outname,
predicate,
228 funname, src1, src2, cwidth,
int (ndst),
i, xdst,
res);
233 "line %d: %s<%s, %s, %s%{?}, %s%{;}> (\"%s\", \"%s\", ...) "
234 " ==> \"%{X=*.*}\" got %zu elements from first sequence and "
235 "%zu from second, expected %zu from first and %zu from second",
236 __LINE__, algname, it1name, it2name, outname,
predicate,
238 cwidth,
int (ndst), -1, xdst,
n1,
n2, nf, ndst - nf);
242 for (
i = 1;
i < ndst;
i++) {
243 if (xdst [
i - 1].data_.val_ == xdst [
i].
data_.
val_) {
252 i =
i < ndst ?
i : ndst - 1;
255 "line %d: %s<%s, %s, %s%{?}, %s%{;}> (\"%s\", \"%s\", ...)"
256 " ==> \"%{X=*.*}\" not stable : elements %#c==%#c have "
258 __LINE__, algname, it1name, it2name, outname,
predicate,
259 funname, src1, src2, cwidth,
int (ndst),
i, xdst,
265 std::size_t n_exp_ops = nsrc1 + nsrc2 > 0 ? 2 * (nsrc1 + nsrc2) - 1 : 0;
267 "line %d: %s<%s, %s, %s%{?}, %s%{;}> (\"%s\", \"%s\", ...) "
268 "complexity: got %zu, expected no more than %zu",
269 __LINE__, algname, it1name, it2name, outname,
predicate,
270 funname, src1, src2, n_ops_lt, n_exp_ops);
282 const char*
const it1name = alg.
iter_names [0];
283 const char*
const it2name = alg.
iter_names [1];
284 const char*
const outname = alg.
iter_names [2];
285 const char*
const algname =
"set_symmetric_difference";
286 const char*
const funname =
predicate ?
"Less" : 0;
289 "%s std::%s(%s, %3$s, %s, %4$s, %1$s%{?}, %s%{;})",
290 outname, algname, it1name, it2name,
predicate, funname);
292#define TEST(src1, src2, res, nf) \
293 test_set_sym_difference (__LINE__, src1, sizeof src1 -1, \
294 src2, sizeof src2 - 1, \
295 res, sizeof res - 1, \
304 TEST (
"a",
"",
"a", 1);
305 TEST (
"abcde",
"",
"abcde", 5);
306 TEST (
"",
"a",
"a", 0);
307 TEST (
"",
"abcde",
"abcde", 0);
308 TEST (
"a",
"b",
"ab", 1);
309 TEST (
"b",
"a",
"ab", 1);
310 TEST (
"aa",
"aa",
"", 0);
311 TEST (
"ab",
"ab",
"", 0);
312 TEST (
"aa",
"ab",
"ab", 1);
313 TEST (
"aa",
"bb",
"aabb", 2);
314 TEST (
"ab",
"bb",
"ab", 1);
315 TEST (
"ac",
"bb",
"abbc", 2);
316 TEST (
"ace",
"bdf",
"abcdef", 3);
317 TEST (
"acf",
"bdf",
"abcd", 2);
318 TEST (
"ade",
"bdf",
"abef", 2);
319 TEST (
"bce",
"bdf",
"cdef", 2);
320 TEST (
"aacee",
"aacee",
"", 0);
321 TEST (
"aacee",
"aaace",
"ae", 1);
322 TEST (
"aacee",
"aaaae",
"aace", 2);
323 TEST (
"aacee",
"aaaaa",
"aaacee", 3);
324 TEST (
"aacee",
"aaabd",
"abcdee", 3);
325 TEST (
"aacee",
"aabee",
"bc", 1);
326 TEST (
"aaaaa",
"aaaaa",
"", 0);
327 TEST (
"aaaaa",
"aaaa",
"a", 1);
328 TEST (
"aaaaa",
"aaa",
"aa", 2);
329 TEST (
"aaaaa",
"aa",
"aaa", 3);
330 TEST (
"aaaaa",
"a",
"aaaa", 4);
344template <
class InputIterator1,
class InputIterator2,
class OutputIterator>
346 const InputIterator2&,
358template <
class InputIterator1,
class InputIterator2>
360 const InputIterator2 &it2,
377template <
class InputIterator1>
400 "template <class %s, class %s, class %s%{?}, class %s%{;}> %3$s "
401 "set_symmetric_difference (%1$s, %1$s, %2$s, %2$s, "
403 "InputIterator1",
"InputIterator2",
"OutputIterator",
407 rw_note (0, 0, 0,
"OutputIterator test disabled");
410 rw_note (0, 0, 0,
"InputIterator test disabled");
415 rw_note (0, 0, 0,
"ForwardIterator test disabled");
421 rw_note (0, 0, 0,
"BidirectionalIterator test disabled");
427 rw_note (0, 0, 0,
"RandomAccessIterator test disabled");
438 rw_note (0, 0, 0,
"predicate test disabled");
443 for (
int i = 0;
i != niters; ++
i) {
452int main (
int argc,
char *argv[])
454 return rw_test (argc, argv, __FILE__,
455 "lib.set.symmetric.difference",
458 "|-no-InputIterator# "
459 "|-no-OutputIterator# "
460 "|-no-ForwardIterator# "
461 "|-no-BidirectionalIterator# "
462 "|-no-RandomAccessIterator#",
void run_test(const ForwardIterator &dummy, T *, Predicate *pred)
#define TEST(src1, src2, res, nf)
void test_set_sym_difference(int line, const char *src1, std::size_t nsrc1, const char *src2, std::size_t nsrc2, const char *res, std::size_t ndst, const std::size_t nf, bool predicate, const SetSymDifferenceBase &alg)
void gen_set_sym_difference_test(const InputIterator1 &, const InputIterator2 &, const OutputIterator &, bool predicate)
int rw_opt_no_output_iter
#define _RWSTD_UNUSED(arg)
#define _RWSTD_NAMESPACE(name)
_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_bool operator()(const T &x, const T &y)
static std::size_t funcalls_
virtual ~SetSymDifferenceBase()
virtual UserClass * set_sym_difference(const UserClass *, const UserClass *, const UserClass *, const UserClass *, UserClass *, UserClass *, const Less *) const =0
const char * iter_names[3]
virtual UserClass * set_sym_difference(const UserClass *xsrc1, const UserClass *xsrc1_end, const UserClass *xsrc2, const UserClass *xsrc2_end, UserClass *xdst, UserClass *xdst_end, const Less *ppred) const
virtual ~SetSymDifference()
static UserClass from_char(char c)
static _RWSTD_SIZE_T n_total_op_lt_
static conv_to_bool make(bool val)