Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
23.vector.modifiers.cpp
Go to the documentation of this file.
1
29#include <memory> // for placement operator new()
30#include <vector> // for vector
31
32#include <cstddef> // for size_t
33
34#include <rw_printf.h>
35#include <rw_alg_test.h>
36#include <rw_value.h> // for UserClass
37#include <rw_driver.h>
38
39#ifndef _RWSTD_NO_REPLACEABLE_NEW_DELETE
40 // disabled for compilers such as IBM VAC++ or MSVC
41 // that can't reliably replace the operators
42# include <rw_new.h>
43#endif // _RWSTD_NO_REPLACEABLE_NEW_DELETE
44
45
47static unsigned rw_opt_nloops;
48static int rw_opt_no_input_iter;
49static int rw_opt_no_forward_iter;
50static int rw_opt_no_bidir_iter;
51static int rw_opt_no_random_iter;
52static int rw_opt_no_insert;
53static int rw_opt_no_insert_range;
54static int rw_opt_no_insert_at_end;
55static int rw_opt_no_complexity;
56static int rw_opt_no_push_back;
57
58
60typedef std::vector<UserClass, std::allocator<UserClass> > Vector;
61
62Vector::size_type new_capacity;
63
64namespace __rw {
65
67inline Vector::size_type
68__rw_new_capacity<Vector>(Vector::size_type n, const Vector*)
69{
70 if (n)
71 return n * 2;
72
73 return new_capacity;
74}
75
76}
77
78
80// used to determine whether insert() can or cannot use
81// an algorithm optimized for ForwardIterators
82bool is_forward_category (std::input_iterator_tag) { return false; }
83bool is_forward_category (std::forward_iterator_tag) { return true; }
84
85template <class Iterator>
86bool is_forward (const Iterator &it)
87{
88 _RWSTD_UNUSED (it);
89
91
92}
93
94// exercises the exception safety of each tested function by successively
95// forcing operator new to thow a bad_alloc exception at each iteration
96// of the loop until the call succeeds (i.e., until no exception is
97// thrown)
98template <class Iterator>
99void exception_loop (int line, const char *fcall, bool capchg,
100 Vector &vec, const Vector::iterator &it,
101 int n, const UserClass *x,
102 const Iterator &first, const Iterator &last,
103 std::size_t *n_copy, std::size_t *n_asgn)
104{
105 std::size_t throw_after = 0;
106
107 const std::size_t size = vec.size ();
108 const std::size_t capacity = vec.capacity ();
109 const Vector::const_iterator begin = vec.begin ();
110
111#ifndef _RWSTD_NO_REPLACEABLE_NEW_DELETE
112
113 rwt_free_store* const pst = rwt_get_free_store (0);
114
115#endif // _RWSTD_NO_REPLACEABLE_NEW_DELETE
116
117 // iterate for`n=throw_after' starting at the next call to operator
118 // new, forcing each call to throw an exception, until the insertion
119 // finally succeeds (i.e, no exception is thrown)
120 for ( ; ; ) {
121
124
125#ifndef _RWSTD_NO_EXCEPTIONS
126
127 // detect objects constructed but not destroyed after an exception
128 const std::size_t count = UserClass::count_;
129
130# ifndef _RWSTD_NO_REPLACEABLE_NEW_DELETE
131
132 // disable out of memory exceptions before copying iterators
133 // (InputIter ctors may dynamically allocate memory)
134 *pst->throw_at_calls_ [0] = std::size_t (-1);
135# endif // _RWSTD_NO_REPLACEABLE_NEW_DELETE
136#endif // _RWSTD_NO_EXCEPTIONS
137
138 // create "deep" copies of the iterators to thwart
139 // InpuIter's multi-pass detection
140 const Iterator beg = copy_iter (first, (UserClass*)0);
141 const Iterator end = copy_iter (last, (UserClass*)0);
142
143#ifndef _RWSTD_NO_EXCEPTIONS
144# ifndef _RWSTD_NO_REPLACEABLE_NEW_DELETE
145
146 *pst->throw_at_calls_ [0] = pst->new_calls_ [0] + throw_after + 1;
147
148# endif // _RWSTD_NO_REPLACEABLE_NEW_DELETE
149#endif // _RWSTD_NO_EXCEPTIONS
150
151 _TRY {
152 if (-2 == n) {
153 vec.insert (it, *x);
154 }
155 else if (-1 == n) {
156
157#ifndef _RWSTD_NO_EXT_VECTOR_INSERT_IN_PLACE
158# ifndef _RWSTD_NO_REPLACEABLE_NEW_DELETE
159 // disable exceptions if Iterator is not at least
160 // a ForwardIterator since the extension doesn't
161 // provide the strong exception safety guarantee
162 // required in 23.2.4.3, p1
163 if (!is_forward (beg)) {
164 *pst->throw_at_calls_ [0] = std::size_t (-1);
165 }
166# endif //_RWSTD_NO_REPLACEABLE_NEW_DELETE
167#endif // _RWSTD_NO_EXT_VECTOR_INSERT_IN_PLACE
168
169 vec.insert (it, beg, end);
170 }
171 else {
172 vec.insert (it, n, *x);
173 }
174 break;
175 }
176 _CATCH (...) {
177
178#ifndef _RWSTD_NO_EXCEPTIONS
179
180 // verify that an exception thrown during allocation
181 // doesn't cause a change in the state of the vector
182
183 rw_assert (vec.size () == size, 0, line,
184 "line %d: %s: size unexpectedly changed "
185 "from %zu to %zu after an exception",
186 __LINE__, fcall, size, vec.size ());
187
188 rw_assert (vec.capacity () == capacity, 0, line,
189 "line %d: %s: capacity unexpectedly "
190 "changed from %zu to %zu after an exception",
191 __LINE__, fcall, capacity, vec.capacity ());
192
193
194 rw_assert (vec.begin () == begin, 0, line,
195 "line %d: %s: begin() unexpectedly "
196 "changed from after an exception by %d",
197 __LINE__, fcall, vec.begin () - begin);
198
199
201 "line %d: %s: leaked %d objects "
202 "after an exception",
203 __LINE__, fcall, UserClass::count_ - count);
204
205 // increment to allow this call to operator new to succeed
206 // and force the next one to fail, and try to insert again
207 ++throw_after;
208
209#endif // _RWSTD_NO_EXCEPTIONS
210
211 } // catch
212 } // for
213
214#ifndef _RWSTD_NO_EXCEPTIONS
215# ifndef _RWSTD_NO_REPLACEABLE_NEW_DELETE
216
217 // verify that if exceptions are enabled and when capacity changes
218 // at least one exception is thrown
219 rw_assert ( *pst->throw_at_calls_ [0] == std::size_t (-1)
220 || !capchg
221 || throw_after,
222 0, line,
223 "line %d: %s: failed to throw an expected exception",
224 __LINE__, fcall);
225
226 // commented out: just because capacity doesn't change doesn't mean
227 // that no exception is thrown (e.g., if the function dynamically
228 // allocates temporary storage)
229 //
230 // rw_assert (capchg || !throw_after,
231 // 0, line,
232 // "line %d: %s: unexpectedly threw an exception",
233 // __LINE__, fcall);
234
235# endif // _RWSTD_NO_REPLACEABLE_NEW_DELETE
236#else // if defined (_RWSTD_NO_EXCEPTIONS)
237
240 _RWSTD_UNUSED (fcall);
241 _RWSTD_UNUSED (capchg);
243 _RWSTD_UNUSED (capacity);
244 _RWSTD_UNUSED (throw_after);
245
246#endif // _RWSTD_NO_EXCEPTIONS
247
248#ifndef _RWSTD_NO_REPLACEABLE_NEW_DELETE
249
250 *pst->throw_at_calls_ [0] = std::size_t (-1);
251
252#endif // _RWSTD_NO_REPLACEABLE_NEW_DELETE
253
254 // compute the number of calls to UserClass copy ctor
255 // and assignment operator
256 *n_copy = UserClass::n_total_copy_ctor_ - *n_copy;
257 *n_asgn = UserClass::n_total_op_assign_ - *n_asgn;
258}
259
260
262template <class Iterator>
263void test_insert (int line, // line number of call site
264 const Iterator &dummy, // unused dummy iterator
265 int n, // number of elements to insert
266 // or the special values -1 and -2
267 const char *seq, // initial container contents
268 std::size_t seqlen, // initial container size
269 std::size_t seqcap, // initial container capacity
270 int off, // offset at which to insert
271 const char *ins, // inserted sequence
272 std::size_t inslen, // length of inserted sequence
273 const char *res, // resulting sequence
274 std::size_t reslen /* length of resulting sequence */)
275{
276 // create arrays of `seqlen' and `inslen' elements of type UserClass
277 // initialized from the sequences `seq' and `ins', respectively
278 const UserClass* const xseq = UserClass::from_char (seq, seqlen);
279 UserClass* const xins = UserClass::from_char (ins, inslen);
280
281 // construct a std::vector from the sequence of elements
282 Vector vec = seqlen ? Vector (xseq, xseq + seqlen) : Vector ();
283
284 // set the capacity of the container (if specified)
285 if (std::size_t (-1) == seqcap)
286 seqcap = vec.capacity ();
287 else
288 vec.reserve (seqcap);
289
290 // create an iterator pointing `off' past the beginning of the vector
291 const Vector::iterator it = vec.begin () + off;
292
293 char* fcall = 0;
294 std::size_t len = 0;
295
296 static const int cwidth = sizeof (*xseq);
297
298 // format a string describing the function call being tested
299 // (used in diagnostic messages, if any, below)
300 rw_asnprintf (&fcall, &len, "vector(\"%{X=*.*}\").insert("
301 "%{?}begin()%{:}%{?}end()%{:}begin() + %zu%{;}%{;}, "
302 "%{?}%d%{:}%{?}\"%{X=*.*}\"%{:}%d, %d%{;}%{;})",
303 cwidth, int (seqlen), -1, xseq,
304 0 == off, int (seqlen) == off, off,
305 n == -2, *ins, n == -1,
306 cwidth, int (inslen), -1, xins, n, *ins);
307
308 // 23.2.4.3, p1
309 // Notes: Causes reallocation if the new size is greater than
310 // the old capacity. If no reallocation happens, all the iterators
311 // and references before the insertion point remain valid.
312 // If an exception is thrown other than by the copy constructor
313 // an assignment operator of T there are no effects.
314
315 // determine whether the insertion must or must not change capacity
316 const bool capchg = seqlen + (n < 0 ? inslen : n) > seqcap;
317
318 std::size_t n_copy = UserClass::n_total_copy_ctor_;
319 std::size_t n_asgn = UserClass::n_total_op_assign_;
320
321 if (-2 == n) {
322
323 exception_loop (line, fcall, capchg,
324 vec, it, n, xins, dummy, dummy,
325 &n_copy, &n_asgn);
326 }
327 else if (-1 == n) {
328
329 const Iterator first =
330 make_iter (xins, xins, xins + inslen, dummy);
331
332 const Iterator last =
333 make_iter (xins + inslen, xins, xins + inslen, dummy);
334
335 exception_loop (line, fcall, capchg,
336 vec, it, n, 0, first, last,
337 &n_copy, &n_asgn);
338 }
339 else /* if (n != -2 && n != -1) */ {
340 // n must be in the range [-2, INT_MAX]
341 _RWSTD_ASSERT (n >= 0);
342
343 exception_loop (line, fcall, capchg,
344 vec, it, n, xins, dummy, dummy,
345 &n_copy, &n_asgn);
346 }
347
348 // verify the expected size of the vector after insertion
349 rw_assert (vec.size () == reslen, 0, line,
350 "line %d: %s: size == %zu, got %zu",
351 __LINE__, fcall, reslen, vec.size ());
352
353 // verify the expected change in capacity of the vactor
354 rw_assert (capchg == (vec.capacity () != seqcap),
355 0, line, "line %d: %s: capacity %c = %zu, got %zu",
356 __LINE__, fcall, capchg ? '!' : '=', seqcap, vec.capacity ());
357
358 // verify the expected contents of the vector after insertion
359 const Vector::const_pointer resbeg = vec.size () ? &*vec.begin () : 0;
360 const Vector::const_pointer resend = resbeg + vec.size ();
361
362 for (Vector::const_pointer ptr = resbeg; ptr != resend; ++ptr) {
363
364 typedef unsigned char UChar;
365
366 if (ptr->data_.val_ != UChar (res [ptr - resbeg])) {
367
368 char* const got = new char [vec.size () + 1];
369
370 for (Vector::const_pointer p = resbeg; p != resend; ++p) {
371 got [p - resbeg] = char (p->data_.val_);
372 }
373
374 got [vec.size ()] = '\0';
375
376 rw_assert (0, 0, line,
377 "line %d: %s: expected %{#s}, got %{#s}",
378 __LINE__, fcall, res, got);
379
380 delete [] got;
381 break;
382 }
383 }
384
385 // 23.2.4.3, p2
386 // Complexity:
387 // -- If first and last are forward iterators, bidirectional iterators,
388 // or random access iterators, the complexity is linear in the number
389 // of elements in the range [first, last) plus the distance to
390 // the end of the vector.
391 // -- If they are input iterators, the complexity is proportional
392 // to the number of elements in the range [first, last) times
393 // the distance to the end of the vector.
394
395 // verify the complexity of the operation in terms of the number
396 // of calls to the copy ctor and assignment operator on value_type
397 // note that the complexity requirement imposes an upper bound on
398 // the number of operations and implementations are allowed to do
399 // better (see 17.3.1.3, p5)
400
401 std::size_t expect_copy; // expected number of copy ctor calls
402 std::size_t expect_asgn; // expected number of assignments
403
404 if (is_forward (dummy)) {
405 // ForwardIterator or better
406
407 if (capchg) {
408 // when the insertion causes a change in capacity
409 // (i.e., reallocation), the number of copy ctor
410 // invocations is equal to the size of the resulting
411 // sequence; no assignment operators are invoked
412 expect_copy = reslen;
413 expect_asgn = 0;
414 }
415 else {
416 // when no change in capacity occurs the number of copy
417 // ctor invocations is equal to the number of elements
418 // between the end of the inserted range and the end of
419 // the original sequence
420 // the number of assignments is equal to the distance
421 // from the point of insertion to the end of the original
422 // sequence
423 expect_copy = n < 0 ? inslen : n;
424 expect_asgn = n && inslen ? reslen - off : 0;
425 }
426 }
427 else {
428 // InputIterator
429 expect_copy = n_copy;
430 expect_asgn = n_asgn;
431
432 // don't bother testing the complexity of the functions with
433 // InputIterators, the standard's messed up (see issue 247
434 // and the indirectly related issue 406)
435 }
436
437 rw_assert (expect_copy >= n_copy,
438 0, line,
439 "line %d: %s: expected at most %zu "
440 "invocation(s) of UserClass::UserClass(const UserClass&), "
441 "got %zu", __LINE__, fcall, expect_copy, n_copy);
442
443 rw_assert (expect_asgn >= n_asgn,
444 0, line,
445 "line %d: %s: expected at most %zu invocation(s) "
446 "of UserClass::operator=(const UserClass&), got %zu",
447 __LINE__, fcall, expect_asgn, n_asgn);
448
449 delete [] xins;
450 delete [] _RWSTD_CONST_CAST (UserClass*, xseq);
451}
452
453
456{
458 // exercise vector::insert(iterator, const_reference)
459
460 rw_info (0, 0, 0,
461 "std::vector<UserClass>::insert(iterator, const_reference)");
462
463#undef TEST
464#define TEST(seq, seqcap, off, ins, res) do { \
465 const char insseq [] = { ins, '\0' }; \
466 test_insert (__LINE__, (UserClass*)0, -2, \
467 seq, sizeof seq - 1, \
468 std::size_t (seqcap), off, \
469 insseq, 1, \
470 res, sizeof res - 1); \
471 } while (0)
472
473 // +----------------------- initial container contents
474 // | +--------------- initial container capacity
475 // | | +----------- offset at which to insert
476 // | | | +------ element to insert
477 // | | | | +-- resulting sequence
478 // | | | | |
479 // V V V V V
480 TEST ("", -1, +0, 'a', "a");
481 TEST ("b", -1, +0, 'a', "ab");
482 TEST ("bc", -1, +0, 'a', "abc");
483 TEST ("bcd", -1, +0, 'a', "abcd");
484 TEST ("bcde", -1, +0, 'a', "abcde");
485
486 TEST ("a", -1, +1, 'b', "ab");
487 TEST ("ac", -1, +1, 'b', "abc");
488 TEST ("acd", -1, +1, 'b', "abcd");
489 TEST ("acde", -1, +1, 'b', "abcde");
490
491 TEST ("ab", -1, +2, 'c', "abc");
492 TEST ("abd", -1, +2, 'c', "abcd");
493 TEST ("abde", -1, +2, 'c', "abcde");
494
495 TEST ("abc", -1, +3, 'd', "abcd");
496 TEST ("abce", -1, +3, 'd', "abcde");
497
498 TEST ("abcd", -1, +4, 'e', "abcde");
499
501 // exercise vector::insert(iterator, size_type, const_reference)
502
503 rw_info (0, 0, 0,
504 "std::vector<UserClass>::insert(iterator, "
505 "size_type, const_reference)");
506
507#undef TEST
508#define TEST(seq, seqcap, off, n, ins, res) do { \
509 const char insseq [] = { ins, '\0' }; \
510 test_insert (__LINE__, (UserClass*)0, n, \
511 seq, sizeof seq - 1, \
512 std::size_t (seqcap), off, \
513 insseq, 1, \
514 res, sizeof res - 1); \
515 } while (0)
516
517 // +-------------------------- initial container contents
518 // | +------------------ initial container capacity
519 // | | +-------------- offset at which to insert
520 // | | | +---------- number of elements to insert
521 // | | | | +------ element value to insert
522 // | | | | | +-- resulting sequence
523 // | | | | | |
524 // V V V V V V
525 TEST ("", -1, +0, 0, 'a', "");
526 TEST ("", -1, +0, 1, 'a', "a");
527 TEST ("", -1, +0, 2, 'b', "bb");
528 TEST ("", -1, +0, 3, 'c', "ccc");
529
530 TEST ("a", -1, +0, 0, 'a', "a");
531 TEST ("b", -1, +0, 1, 'a', "ab");
532 TEST ("b", -1, +0, 2, 'a', "aab");
533 TEST ("b", -1, +0, 3, 'a', "aaab");
534
535 TEST ("ab", -1, +1, 0, 'b', "ab");
536 TEST ("ac", -1, +1, 1, 'b', "abc");
537 TEST ("ac", -1, +1, 2, 'b', "abbc");
538 TEST ("ac", -1, +1, 3, 'b', "abbbc");
539
540 TEST ("abcd", -1, +2, 0, 'c', "abcd");
541 TEST ("abde", -1, +2, 1, 'c', "abcde");
542 TEST ("abde", -1, +2, 2, 'c', "abccde");
543 TEST ("abde", -1, +2, 3, 'c', "abcccde");
544}
545
546
548template <class Iterator>
549void test_insert_range (const Iterator &dummy)
550{
551 static const char* const itname = type_name (dummy, (UserClass*)0);
552
553 rw_info (0, 0, 0,
554 "std::vector<UserClass>::insert(iterator, %s, %s)",
555 itname, itname);
556
557#undef TEST
558#define TEST(seq, seqcap, off, ins, res) \
559 test_insert (__LINE__, dummy, -1, \
560 seq, sizeof seq - 1, \
561 std::size_t (seqcap), off, \
562 ins, sizeof ins - 1, \
563 res, sizeof res - 1)
564
565 // +-------------------------------------------- seq(uence)
566 // | +------------------------------------- seqcap(acity)
567 // | | +--------------------------------- off(set of insertion)
568 // | | | +----------------------------- ins(erted sequence)
569 // | | | | +---------------------- res(ulting sequence)
570 // | | | | |
571 // v v v v v
572 TEST ("", -1, +0, "", "");
573 TEST ("", -1, +0, "a", "a");
574 TEST ("", -1, +0, "ab", "ab");
575 TEST ("", -1, +0, "abc", "abc");
576
577 TEST ("A", -1, +0, "", "A");
578 TEST ("B", -1, +0, "a", "aB");
579 TEST ("C", -1, +0, "ab", "abC");
580 TEST ("D", -1, +0, "abc", "abcD");
581
582 TEST ("AB", -1, +0, "", "AB");
583 TEST ("AB", -1, +0, "c", "cAB");
584 TEST ("AB", -1, +0, "cd", "cdAB");
585 TEST ("AB", -1, +0, "cde", "cdeAB");
586
587 TEST ("A", -1, +1, "", "A");
588 TEST ("A", -1, +1, "b", "Ab");
589 TEST ("A", -1, +1, "bc", "Abc");
590 TEST ("A", -1, +1, "bcd", "Abcd");
591
592 TEST ("AB", -1, +1, "", "AB");
593 TEST ("AC", -1, +1, "b", "AbC");
594 TEST ("AD", -1, +1, "bc", "AbcD");
595 TEST ("AE", -1, +1, "bcd", "AbcdE");
596
597 TEST ("AB", -1, +2, "", "AB");
598 TEST ("AB", -1, +2, "c", "ABc");
599 TEST ("AB", -1, +2, "cd", "ABcd");
600 TEST ("AB", -1, +2, "cde", "ABcde");
601
602 TEST ("ABC", -1, +2, "", "ABC");
603 TEST ("ABD", -1, +2, "c", "ABcD");
604 TEST ("ABE", -1, +2, "cd", "ABcdE");
605 TEST ("ABF", -1, +2, "cde", "ABcdeF");
606
607 TEST ("ABC", -1, +3, "", "ABC");
608 TEST ("ABC", -1, +3, "d", "ABCd");
609 TEST ("ABC", -1, +3, "de", "ABCde");
610 TEST ("ABC", -1, +3, "def", "ABCdef");
611
612
613#define UPPER "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
614#define LOWER "abcdefghijklmnopqrstuvwxyz"
615
616 TEST ("", -1, +0, LOWER, LOWER);
617
618 TEST ("A", -1, +0, LOWER, LOWER "A");
619 TEST ("A", -1, +1, LOWER, "A" LOWER);
620
621 TEST ("AB", -1, +0, LOWER, LOWER "AB");
622 TEST ("AB", -1, +1, LOWER, "A" LOWER "B");
623 TEST ("AB", -1, +2, LOWER, "AB" LOWER);
624
625 TEST ("ABC", -1, +0, LOWER, LOWER "ABC");
626 TEST ("ABC", -1, +1, LOWER, "A" LOWER "BC");
627 TEST ("ABC", -1, +2, LOWER, "AB" LOWER "C");
628 TEST ("ABC", -1, +3, LOWER, "ABC" LOWER);
629
630 TEST (UPPER, -1, +0, "!", "!ABCDEFGHIJKLMNOPQRSTUVWXYZ");
631 TEST (UPPER, -1, +1, "!", "A!BCDEFGHIJKLMNOPQRSTUVWXYZ");
632 TEST (UPPER, -1, +2, "!", "AB!CDEFGHIJKLMNOPQRSTUVWXYZ");
633 TEST (UPPER, -1, +3, "!", "ABC!DEFGHIJKLMNOPQRSTUVWXYZ");
634 TEST (UPPER, -1, +9, "!", "ABCDEFGHI!JKLMNOPQRSTUVWXYZ");
635 TEST (UPPER, -1, +25, "!", "ABCDEFGHIJKLMNOPQRSTUVWXY!Z");
636 TEST (UPPER, -1, +26, "!", "ABCDEFGHIJKLMNOPQRSTUVWXYZ!");
637
638 TEST (UPPER, -1, +0, "12", "12ABCDEFGHIJKLMNOPQRSTUVWXYZ");
639 TEST (UPPER, -1, +1, "12", "A12BCDEFGHIJKLMNOPQRSTUVWXYZ");
640 TEST (UPPER, -1, +2, "12", "AB12CDEFGHIJKLMNOPQRSTUVWXYZ");
641 TEST (UPPER, -1, +3, "12", "ABC12DEFGHIJKLMNOPQRSTUVWXYZ");
642 TEST (UPPER, -1, +9, "12", "ABCDEFGHI12JKLMNOPQRSTUVWXYZ");
643 TEST (UPPER, -1, +25, "12", "ABCDEFGHIJKLMNOPQRSTUVWXY12Z");
644 TEST (UPPER, -1, +26, "12", "ABCDEFGHIJKLMNOPQRSTUVWXYZ12");
645
646 TEST (UPPER, -1, +0, "123", "123ABCDEFGHIJKLMNOPQRSTUVWXYZ");
647 TEST (UPPER, -1, +1, "123", "A123BCDEFGHIJKLMNOPQRSTUVWXYZ");
648 TEST (UPPER, -1, +2, "123", "AB123CDEFGHIJKLMNOPQRSTUVWXYZ");
649 TEST (UPPER, -1, +3, "123", "ABC123DEFGHIJKLMNOPQRSTUVWXYZ");
650 TEST (UPPER, -1, +9, "123", "ABCDEFGHI123JKLMNOPQRSTUVWXYZ");
651 TEST (UPPER, -1, +25, "123", "ABCDEFGHIJKLMNOPQRSTUVWXY123Z");
652 TEST (UPPER, -1, +26, "123", "ABCDEFGHIJKLMNOPQRSTUVWXYZ123");
653
654 TEST (UPPER, -1, +0, LOWER, "" LOWER "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
655 TEST (UPPER, -1, +1, LOWER, "A" LOWER "BCDEFGHIJKLMNOPQRSTUVWXYZ");
656 TEST (UPPER, -1, +2, LOWER, "AB" LOWER "CDEFGHIJKLMNOPQRSTUVWXYZ");
657 TEST (UPPER, -1, +3, LOWER, "ABC" LOWER "DEFGHIJKLMNOPQRSTUVWXYZ");
658 TEST (UPPER, -1, +4, LOWER, "ABCD" LOWER "EFGHIJKLMNOPQRSTUVWXYZ");
659 TEST (UPPER, -1, +5, LOWER, "ABCDE" LOWER "FGHIJKLMNOPQRSTUVWXYZ");
660 TEST (UPPER, -1, +6, LOWER, "ABCDEF" LOWER "GHIJKLMNOPQRSTUVWXYZ");
661 TEST (UPPER, -1, +7, LOWER, "ABCDEFG" LOWER "HIJKLMNOPQRSTUVWXYZ");
662 TEST (UPPER, -1, +8, LOWER, "ABCDEFGH" LOWER "IJKLMNOPQRSTUVWXYZ");
663 TEST (UPPER, -1, +9, LOWER, "ABCDEFGHI" LOWER "JKLMNOPQRSTUVWXYZ");
664 TEST (UPPER, -1, +10, LOWER, "ABCDEFGHIJ" LOWER "KLMNOPQRSTUVWXYZ");
665 TEST (UPPER, -1, +11, LOWER, "ABCDEFGHIJK" LOWER "LMNOPQRSTUVWXYZ");
666 TEST (UPPER, -1, +12, LOWER, "ABCDEFGHIJKL" LOWER "MNOPQRSTUVWXYZ");
667 TEST (UPPER, -1, +13, LOWER, "ABCDEFGHIJKLM" LOWER "NOPQRSTUVWXYZ");
668 TEST (UPPER, -1, +14, LOWER, "ABCDEFGHIJKLMN" LOWER "OPQRSTUVWXYZ");
669 TEST (UPPER, -1, +15, LOWER, "ABCDEFGHIJKLMNO" LOWER "PQRSTUVWXYZ");
670 TEST (UPPER, -1, +16, LOWER, "ABCDEFGHIJKLMNOP" LOWER "QRSTUVWXYZ");
671 TEST (UPPER, -1, +17, LOWER, "ABCDEFGHIJKLMNOPQ" LOWER "RSTUVWXYZ");
672 TEST (UPPER, -1, +18, LOWER, "ABCDEFGHIJKLMNOPQR" LOWER "STUVWXYZ");
673 TEST (UPPER, -1, +19, LOWER, "ABCDEFGHIJKLMNOPQRS" LOWER "TUVWXYZ");
674 TEST (UPPER, -1, +20, LOWER, "ABCDEFGHIJKLMNOPQRST" LOWER "UVWXYZ");
675 TEST (UPPER, -1, +21, LOWER, "ABCDEFGHIJKLMNOPQRSTU" LOWER "VWXYZ");
676 TEST (UPPER, -1, +22, LOWER, "ABCDEFGHIJKLMNOPQRSTUV" LOWER "WXYZ");
677 TEST (UPPER, -1, +23, LOWER, "ABCDEFGHIJKLMNOPQRSTUVW" LOWER "XYZ");
678 TEST (UPPER, -1, +24, LOWER, "ABCDEFGHIJKLMNOPQRSTUVWX" LOWER "YZ");
679 TEST (UPPER, -1, +25, LOWER, "ABCDEFGHIJKLMNOPQRSTUVWXY" LOWER "Z");
680 TEST (UPPER, -1, +26, LOWER, "ABCDEFGHIJKLMNOPQRSTUVWXYZ" LOWER "");
681}
682
683
686{
688 // exercise vector::insert() at the end of the container and
689 // verify that the functions perform in amortized constant time
690 // (see also PR #30615)
691
692 rw_info (0, 0, 0,
693 "std::vector<UserClass>::insert (end(), const_reference)");
694
695 typedef Vector::size_type size_type;
696
697 Vector v;
698
699 size_type nextcap = 0;
700
701 // iterate to grow vector excactly 8 times
702 for (int i = 0; i != 8; ++i) {
703
704 // count the number of copy ctor and assignment operator invocations
705 std::size_t n_copy;
706 std::size_t n_asgn;
707
708 // compute the next (non-zero) capacity of the container
709 nextcap = _RW::__rw_new_capacity (nextcap + 1, (Vector*)0);
710
711 // insert elements at the end of the container until its size
712 // reaches its capacity, verifying that each of the insertions
713 // performed in (amortized) constant time
714 while (v.size () < nextcap) {
715
718
719 v.insert (v.end (), Vector::value_type ());
720
721 rw_assert (nextcap >= v.capacity (), 0, __LINE__,
722 "vector<UserClass>::insert (end(), value_type()); "
723 "capacity == %zu, got %zu after %zu insertions",
724 nextcap, v.capacity (), v.size ());
725
726 if (nextcap < v.capacity ()) break;
727
728 // compute the number of copy ctor and assignment operator calls
729 n_copy = UserClass::n_total_copy_ctor_ - n_copy;
730 n_asgn = UserClass::n_total_op_assign_ - n_asgn;
731
732 // verify that the copy ctor was invoked exactly once
733 rw_assert (1U == n_copy, 0, __LINE__,
734 "vector<UserClass>::insert (end(), value_type()); "
735 "expected 1 invocation of the copy ctor, got %zu",
736 n_copy);
737
738 // verify that the assignment operator was not invoked
739 rw_assert (n_asgn == 0, 0, __LINE__,
740 "vector<UserClass>::insert (end(), value_type()); "
741 "expected 0 invocations of the assignment "
742 "operator, got %zu", n_asgn);
743 }
744
745 // inserting the next element must reallocate
746 v.insert (v.end (), Vector::value_type ());
747
748 rw_assert (v.capacity () > nextcap, 0, __LINE__,
749 "vector<UserClass>::insert (end(), value_type()); "
750 "capacity > %zu, got %zu after %zu insertions",
751 nextcap, v.capacity (), v.size ());
752 }
753}
754
755
757// exercise vector<>::insert() and vector::erase()
758// focus on the complexity of the function
759
761{
762 rw_info (0, 0, 0, "std::vector<UserClass>::insert(iterator, "
763 "const_reference)");
764 rw_info (0, 0, 0, "std::ector<UserClass>::insert(iterator, size_type, "
765 "const_reference)");
766 rw_info (0, 0, 0, "template <class InputIterator> "
767 "std::vector<UserClass>::insert"
768 "(iterator, InputIterator, InputIterator)");
769 rw_info (0, 0, 0, "std::vector<UserClass>::erase(iterator)");
770 rw_info (0, 0, 0, "std::vector<UserClass>::erase(iterator, iterator)");
771
772 typedef std::vector<UserClass, std::allocator<UserClass> > Vector;
773 typedef Vector::iterator VectorIter;
774 typedef Vector::size_type VectorSize;
775
776 bool success = true;
777
778 Vector v0;
779 Vector v1;
780 Vector v2;
781
782 VectorIter it = v0.begin ();
783 VectorIter it1 = v1.begin ();
784 VectorIter it2 = v2.begin ();
785
786 VectorSize i;
787
788 for (i = 0; i < rw_opt_nloops; i++) {
789 // initialize the current size, capacity and begin iterator variables
790 VectorSize v0_size = v0.size ();
791 VectorSize v0_cap = v0.capacity ();
792 VectorIter v0_beg = v0.begin ();
793
795
796 // reset the UserClass totals
798
799 // inseert val into the vector
800 it = v0.insert (it, val);
801
802 // 23.2.4.3, p1: causes reallocation if the new size
803 // is greater than the old capacity
804 rw_assert (v0_cap <= v0.size () || v0_beg == v0.begin (),
805 0, __LINE__,
806 "vector<UserClass>::insert(iterator, const_reference) "
807 "invalidated iterators w/o reallocation");
808
809 // make sure that the vector is now one element larger
810 rw_assert (v0.size () == v0_size + 1,
811 0, __LINE__,
812 "vector<UserClass>::insert(iterator, const_reference); "
813 "new size = %zu, expected %zu", v0.size (), v0_size + 1);
814
815 // make sure that the returned iterator points to the new value
816 rw_assert (*it == val,
817 0, __LINE__,
818 "vector<UserClass>::insert(iterator, const_reference); "
819 "returned iterator doesn't point at inserted value");
820
821 // 23.2.4.3, p2: the complexity is linear in the number of elements
822 // in the range [first, last) plus the distance to the
823 // end of the vector.
824 if(v0.begin () != v0_beg) {
825 rw_assert ((VectorSize)UserClass::n_total_copy_ctor_ == v0.size (),
826 0, __LINE__,
827 "vector<UserClass>::insert() - fails complexity "
828 "copy_ctor called %zu; size = %zu",
830 }
831 else {
834 == std::size_t (v0.end() - it),
835 0, __LINE__,
836 "vector<UserClass>::insert(iterator, const_reference) - "
837 "fails complexity copy_ctor and assign called "
838 "%zu correct = %zu", UserClass::n_total_copy_ctor_ +
839 UserClass::n_total_op_assign_, (v0.end() - it));
840 }
841
842 // every 5 loops erase 'it'
843 if (i % 5) {
844 it1 = it;
845 Vector::value_type next_val;
846
847 // if we are not at the end of the vector then increment it1 and
848 // if we are still not at the end then set next_val = *it1
849 // because when we erase it, that will be the value it should
850 // point to
851 if (it != v0.end () && ++it1 != v0.end())
852 next_val = *it1;
853
854 VectorSize num_left = v0.end () - it - 1;
855 VectorSize X_count = UserClass::count_;
856
857 v0_size = v0.size ();
858
859 // reset the totals for the complexity test
861 it = v0.erase (it);
862
863 // make sure only one element was erased
864 rw_assert (v0.size () != v0_size - 1, 0, __LINE__,
865 "vector<UserClass>::erase(iterator); new size = %zu, "
866 "expected %zu", v0.size (), v0_size - 1);
867
868 // if we were not at the end of the vector then *it should be
869 // next_val
870 rw_assert (it == v0.end () || *it == next_val, 0, __LINE__,
871 "vector<UserClass>::erase(iterator); "
872 "returned iterator doesn't point at next value ");
873
874 // 23.2.4.2, p4: The assignment operator of UserClass should be
875 // called the number of times equal to the number of
876 // elements in the vector after the erased elements.
877 rw_assert ((VectorSize)UserClass::n_total_op_assign_ != num_left,
878 0, __LINE__,
879 "vector<UserClass>::erase(iterator) - fails "
880 "complexity assign called %zu correct = %zu",
882
883
884 // 23.2.4.2, p4: The destructor of UserClass should be called
885 // the number of times equal to the number of
886 // elements erased
887 rw_assert ((VectorSize)X_count - UserClass::count_ == 1,
888 0, __LINE__,
889 "vector<UserClass>::erase(iterator) - "
890 "fails complexity destructor called %zu "
891 "correct = %zu", X_count - UserClass::count_ , 1);
892 }
893
894 // Don't always insert at the beginning
895 if (i % 2 && it != v0.end ())
896 it++;
897 }
898
899 // now lets test nultiple insert and erase functions
900 for (i = 0; i < rw_opt_nloops; i++) {
901 VectorSize v1_size = v1.size ();
902 VectorSize v1_cap = v1.capacity ();
903 VectorIter v1_beg = v1.begin ();
904
907
908 // insert `i' copies of `val' in the middle
909 VectorSize offset = (v1.size () ? (i / 2) % v1.size () : 0);
910 it1 = v1.begin () + offset;
911 v1.insert (it1, i, val);
912
913 // since insert doesn't return the next position after the
914 //inserted elements we will calculate this ourself
915 it1 = v1.begin () + offset + i;
916
917 // 23.2.4.3, p1: causes reallocation if the new size
918 // is greater than the old capacity
919 rw_assert (v1_cap <= v1.size () || v1_beg == v1.begin (),
920 0, __LINE__,
921 "vector<UserClass>::insert(iterator, const_reference) "
922 "invalidated iterators w/o reallocation");
923
924 // make sure that the vector increased in size by the correct number
925 rw_assert (v1.size () == v1_size + i,
926 0, __LINE__,
927 "vector<UserClass>::insert(iterator, const_reference); "
928 "new size = %zu, expected %zu", v1.size (), v1_size + i);
929
930 // 23.2.4.3, p2: the complexity is linear in the number of elements
931 // in the range [first, last) plus the distance to the
932 // end of the vector.
933 if (v1.begin () != v1_beg) {
934 rw_assert ((VectorSize)UserClass::n_total_copy_ctor_ == v1.size (),
935 0, __LINE__,
936 "vector<UserClass>::insert(iterator, const_reference) - "
937 "fails complexity copy_ctor called %zu size =%zu",
939 }
940 else {
941 rw_assert ( i + (v1.end() - it1)
942 == (VectorSize)(UserClass::n_total_copy_ctor_ +
944 0, __LINE__,
945 "vector<UserClass>::insert(iterator, const_reference) - "
946 "fails complexity copy_ctor and assign "
947 "called %zu correct = %zu",
950 (v1.end() - it1));
951 }
952
953 VectorSize old_size = v1.size();
954
955 UserClass new_val;
956
957 Vector::value_type expected_val =
958 v1.size () ? *(v1.begin () + (v1.size () / 2)) : new_val;
959
961 // set up some variable that will keep track of how many we are going
962 // to erase, how many are left after the last element we are erasing
963 // and what the current number of Xs are in existance.
964 VectorSize num_destroy = v1.size () / 2;
965
966 VectorSize num_left =
967 v1.end () - (v1.begin () + (v1.size () / 2));
968
969 VectorSize X_count = UserClass::count_;
970
971 it1 = v1.erase(v1.begin (), v1.begin () + (v1.size () / 2));
972
973 // make sure the correct number of elements were erased
974 rw_assert (v1.size () == old_size - (old_size / 2),
975 0, __LINE__,
976 "vector<UserClass>::erase(iterator, iterator); "
977 "new size = %zu, expected %zu", v1.size (),
978 old_size - (old_size / 2));
979
980 // if there is at least one element left then make sure that it1 now
981 // points to the expected next element in the vector.
982 rw_assert (v1.size () == 0 || *it1 == expected_val,
983 0, __LINE__,
984 "vector<UserClass>::erase(iterator, iterator); "
985 "returned iterator doesn't point at next value ");
986
987 // 23.2.4.2, p4: The assignment operator of UserClass should be called
988 // the number of times equal to the number of elements
989 // in the vector after the erased elements.
990 rw_assert ((VectorSize)UserClass::n_total_op_assign_ == num_left,
991 0, __LINE__,
992 "vector<UserClass>::erase(iterator, iterator) - fails "
993 "complexity assign called %zu correct = %zu",
995
996 // 23.2.4.2, p4: The destructor of UserClass should be called the number
997 // of times equal to the number of elements erased
998 rw_assert (X_count - UserClass::count_ == num_destroy,
999 0, __LINE__,
1000 "vector<UserClass>::erase(iterator, iterator) - fails "
1001 "complexity destructor called %zu correct = %zu",
1002 X_count - UserClass::count_ , num_destroy);
1003
1004
1005 }
1006
1007#if !defined (_MSC_VER) || _MSC_VER >= 1300
1008
1009 v0.clear ();
1010 for (i = 0; i < rw_opt_nloops; i++) {
1011 VectorSize v2_size = v2.size ();
1012 VectorSize v2_cap = v2.capacity ();
1013 VectorIter v2_beg = v2.begin ();
1014
1015 UserClass val;
1016 v0.insert (v0.begin(), val);
1017
1018 // 23.2.4.3, p1: causes reallocation if the new size
1019 // is greater than the old capacity
1020 rw_assert (v2_cap <= v2.size () || v2_beg == v2.begin (),
1021 0, __LINE__,
1022 "vector<UserClass>::insert(iterator, const_reference) "
1023 "invalidated iterators w/o reallocation");
1024
1026 v2.insert(v2.begin(), v0.begin(), v0.end());
1027
1028 if (v2.begin () != v2_beg)
1029 rw_assert ((VectorSize)UserClass::n_total_copy_ctor_ == v2.size (),
1030 0, __LINE__,
1031 "vector<UserClass>::insert(iterator, const_reference) - "
1032 "fails complexity copy_ctor called %zu size =%zu",
1034 else {
1037 == v0.size () + (v2.end() - (v2.begin() + v0.size())),
1038 0, __LINE__,
1039 "vector<UserClass>::insert(iterator, const_reference) - "
1040 "fails complexity copy_ctor and assign called "
1041 "%zu correct = %zu",
1044 v0.size() + (v2.end() - (v2.begin() + v0.size())));
1045 }
1046
1047
1048 rw_assert (v2.size () == v2_size + v0.size (),
1049 0, __LINE__,
1050 "vector<UserClass>::insert(iterator, const_reference); "
1051 "new size = %zu, expected %zu", v2.size (),
1052 v2_size + v0.size ());
1053
1054 VectorSize old_size = v2.size();
1055
1056 VectorIter expected_it = v2.begin () + (v2.size () / 2) ;
1057
1058 Vector::value_type expected_val = *expected_it;
1059
1061
1062 VectorSize num_destroy = v2.size () / 2;
1063
1064 VectorSize num_left =
1065 v2.end () - (v2.begin () + (v2.size () / 2));
1066
1067 VectorSize X_count = UserClass::count_;
1068
1069 it2 = v2.erase(v2.begin (), v2.begin () + (v2.size () / 2));
1070
1071
1072 rw_assert (v2.size () == v2_size + v0.size() - (old_size / 2),
1073 0, __LINE__,
1074 "vector<UserClass>::erase(iterator, iterator); "
1075 "new size = %zu, expected %zu",
1076 v2.size (), v2_size + i - (old_size / 2));
1077
1078 rw_assert (v2.size () == 0 || *it2 == expected_val,
1079 0, __LINE__,
1080 "vector<UserClass>::erase(iterator, iterator); "
1081 "returned iterator doesn't point at next value ");
1082
1083 rw_assert ((VectorSize)UserClass::n_total_op_assign_ == num_left,
1084 0, __LINE__,
1085 "vector<UserClass>::erase(iterator, iterator) - "
1086 "fails complexity assign called %zu correct = %zu",
1088
1089 rw_assert (X_count - UserClass::count_ == num_destroy,
1090 0, __LINE__,
1091 "vector<UserClass>::erase(iterator, iterator) - "
1092 "fails complexity destructor called %zu correct = %zu",
1093 X_count - UserClass::count_ , num_destroy);
1094
1095 }
1096#endif // !defined (_MSC_VER) || _MSC_VER >= 1300
1097
1098 rw_assert (success, 0, __LINE__, "vector<UserClass>::insert()");
1099 rw_assert (success, 0, __LINE__, "vector<UserClass>::erase()");
1100}
1101
1102
1104template <class T, class Allocator>
1105void test_push_back (const std::vector<T, Allocator>*)
1106{
1107 rw_info (0, 0, 0, "std::vector<UserClass>::push_back(const_reference)");
1108
1109 typedef std::vector<T, Allocator> MyVector;
1110 typedef typename MyVector::value_type ValueType;
1111 typedef typename MyVector::size_type SizeType;
1112 typedef typename MyVector::pointer Pointer;
1113 typedef typename MyVector::const_pointer ConstPointer;
1114 typedef typename MyVector::iterator Iterator;
1115
1116 MyVector v1;
1117 MyVector v2;
1118
1119 const ValueType val = ValueType ();
1120
1121 for (SizeType i = 0; i != SizeType (4096); ++i) {
1122
1123 // perform the two operations from Table 68
1124 v1.push_back (val);
1125
1126 v2.insert (v2.end (), val);
1127
1128 // verify that effects on both sequences
1129 // are identical as required by Table 68
1130 rw_assert (v1.size () == v2.size (),
1131 0, __LINE__,
1132 "Expected std::vector::size to "
1133 "compare equal; got %zu and %zu",
1134 v1.size (), v2.size ());
1135
1136 rw_assert (v1.capacity () == v2.capacity (),
1137 0, __LINE__,
1138 "Expected std::vector::capacity to "
1139 "compare equal; got %zu and %zu",
1140 v1.capacity (), v2.capacity ());
1141
1142 rw_assert (v1.end () - v1.begin () == v2.end () - v2.begin (),
1143 0, __LINE__,
1144 "Expected std::vector::end() - std::vector::begin() "
1145 "to compare equal; got %zu and %zu",
1146 v1.end () - v1.begin (), v2.end () - v2.begin ());
1147 }
1148}
1149
1150
1152static int
1153run_test (int /* argc */, char** /* argv */)
1154{
1155 if (rw_opt_no_complexity) {
1156 rw_note (0, 0, __LINE__, "complexity test disabled");
1157 }
1158 else {
1159 test_complexity ();
1160 }
1161
1162 if (rw_opt_no_push_back) {
1163 rw_note (0, 0, __LINE__, "push_back test disabled");
1164 }
1165 else {
1166 test_push_back ((std::vector<UserClass, std::allocator<UserClass> >*)0);
1167 }
1168
1169 if (rw_opt_no_insert) {
1170 rw_note (0, 0, __LINE__, "insert test disabled");
1171 }
1172 else {
1173 test_insert ();
1174 }
1175
1176 if (rw_opt_no_insert_range) {
1177 rw_note (0, 0, __LINE__, "insert range test disabled");
1178 }
1179 else {
1180 if (rw_opt_no_input_iter) {
1181 rw_note (0, 0, __LINE__,
1182 "InputIterator test disabled");
1183 }
1184 else {
1186 }
1187
1188 if (rw_opt_no_forward_iter) {
1189 rw_note (0, 0, __LINE__,
1190 "ForwardIterator test disabled");
1191 }
1192 else {
1194 }
1195
1196 if (rw_opt_no_bidir_iter) {
1197 rw_note (0, 0, __LINE__,
1198 "BidirectionalIterator test disabled");
1199 }
1200 else {
1202 }
1203
1204 if (rw_opt_no_random_iter) {
1205 rw_note (0, 0, __LINE__,
1206 "RandomAccessIterator test disabled");
1207 }
1208 else {
1210 }
1211
1212 }
1213
1214 if (rw_opt_no_insert_at_end) {
1215 rw_note (0, 0, __LINE__, "insert at end test disabled");
1216 }
1217 else {
1219 }
1220
1221 return 0;
1222}
1223
1224
1226int main (int argc, char** argv)
1227{
1228 return rw_test (argc, argv, __FILE__,
1229 "lib.vector.modifiers",
1230 0 /* no comment */,
1231 run_test,
1232 "|-nloops#1 "
1233 "|-no-insert# "
1234 "|-no-insert_range# "
1235 "|-no-insert_at_end# "
1236 "|-no-complexity# "
1237 "|-no-input_iter# "
1238 "|-no-forward_iter# "
1239 "|-no-bidir_iter# "
1240 "|-no-random_iter# "
1241 "|-no-push_back#",
1244 &rw_opt_no_insert_range,
1245 &rw_opt_no_insert_at_end,
1248 &rw_opt_no_forward_iter,
1250 &rw_opt_no_random_iter,
1252 0 /* sentinel*/);
1253}
InputIter< UserClass > Iterator
void count(T, T, const U &,...)
#define i
Definition 17.names.cpp:126
#define t
Definition 17.names.cpp:136
#define v
Definition 17.names.cpp:138
#define line
Definition 17.names.cpp:490
#define res
Definition 17.names.cpp:531
#define ptr
Definition 17.names.cpp:525
#define last
Definition 17.names.cpp:487
#define v2
Definition 17.names.cpp:271
#define x
Definition 17.names.cpp:140
#define off
Definition 17.names.cpp:507
#define offset
Definition 17.names.cpp:508
#define len
Definition 17.names.cpp:488
#define n
Definition 17.names.cpp:130
#define val
Definition 17.names.cpp:570
#define p
Definition 17.names.cpp:132
#define Pointer
Definition 17.names.cpp:517
#define v1
Definition 17.names.cpp:245
int rw_opt_no_push_back
std::size_t new_capacity
int rw_opt_no_insert
std::vector< UserClass, std::allocator< UserClass > > Vector
void test_push_back(const std::vector< T, Allocator > *)
void test_insert_at_end()
bool is_forward(const Iterator &it)
void test_insert()
void exception_loop(int line, const char *fcall, bool capchg, Vector &vec, const Vector::iterator &it, int n, const UserClass *x, const Iterator &first, const Iterator &last, std::size_t *n_copy, std::size_t *n_asgn)
void test_insert_range(const Iterator &dummy)
#define LOWER
#define UPPER
void test_complexity()
#define TEST(seq, seqcap, off, ins, res)
Vector::size_type new_capacity
bool is_forward_category(std::input_iterator_tag)
std::vector< UserClass, std::allocator< UserClass > > Vector
int rw_opt_no_bidir_iter
int rw_opt_no_input_iter
Definition 25.copy.cpp:236
int rw_opt_nloops
Definition 25.copy.cpp:235
void run_test(const ForwardIterator &dummy, T *, Predicate *pred)
int rw_opt_no_complexity
const char * type_name()
const int end
#define main
#define _RWSTD_UNUSED(arg)
Definition _defs.h:972
#define _TRY
Definition _defs.h:850
#define _RWSTD_ASSERT(ignore)
Definition _defs.h:1108
#define _CATCH(ex)
Definition _defs.h:851
#define _RWSTD_CONST_CAST(T, x)
Definition _defs.h:536
#define _RWSTD_SPECIALIZED_FUNCTION
Definition _defs.h:556
#define _RWSTD_ITERATOR_CATEGORY(iterT, ignore)
Definition _defs.h:1055
_RWSTD_SPECIALIZED_FUNCTION Vector::size_type __rw_new_capacity< Vector >(Vector::size_type n, const Vector *)
T * make_iter(T *cur, const T *, const T *, T *)
T * copy_iter(T *ptr, const 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 *,...)
Definition driver.cpp:1681
_TEST_EXPORT int rw_note(int, const char *, int, const char *,...)
Definition driver.cpp:1664
_TEST_EXPORT int rw_assert(int, const char *, int, const char *,...)
Definition driver.cpp:1630
_TEST_EXPORT rwt_free_store * rwt_get_free_store(rwt_free_store *)
Definition new.cpp:597
_TEST_EXPORT int rw_asnprintf(char **pbuf, _RWSTD_SIZE_T *pbufsize, const char *fmt,...)
unsigned char UChar
Definition collate.cpp:122
static _RWSTD_SIZE_T n_total_op_assign_
Definition rw_value.h:127
static UserClass from_char(char c)
Definition rw_value.h:221
static _RWSTD_SIZE_T count_
Definition rw_value.h:120
static void reset_totals()
Definition value.cpp:452
static _RWSTD_SIZE_T n_total_copy_ctor_
Definition rw_value.h:125
_RWSTD_SIZE_T * throw_at_calls_[2]
Definition rw_new.h:83
_RWSTD_SIZE_T new_calls_[2]
Definition rw_new.h:47