38#ifdef _RWSTD_NO_EXCEPTIONS
45# define try if (0 == (id = setjmp (env)))
48# define catch(ignore) else if (0 != id)
59typedef std::basic_string<Char, CharTraits, CharAllocator>
String;
66String::size_type String::max_size ()
const
74#ifndef _RWSTD_NO_REPLACEABLE_NEW_DELETE
79# define rwt_check_leaks(psize, ignore) \
80 ((psize) ? *(std::size_t*)(psize) = 0 : 0)
87 _RW::__rw_free_what_buf (what);
89#ifndef _RWSTD_NO_EXCEPTIONS
105 rw_info (0, __FILE__, __LINE__,
"exception handling test setup");
110#ifdef _RWSTD_NO_EXCEPTIONS
127#ifndef _RWSTD_NO_EXCEPTIONS
129 catch (std::out_of_range&) {
145 rw_assert (1 == thrown, __FILE__, __LINE__,
146 "_RWSTD_REQUIRES (_RWSTD_ERROR_OUT_OF_RANGE) failed to "
147 "throw std::out_of_range");
155 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
156 'a',
'b',
'c',
'd',
'e',
'f',
'\0'
168 rw_info (0, __FILE__, __LINE__,
"21.3.1, p4 (size)");
179#ifndef _RWSTD_NO_EXCEPTIONS
181 catch (std::out_of_range&) {
201 rw_assert (1 == thrown, __FILE__, __LINE__,
202 (
"string::string (const string&, size_type, size_type, "
203 "const allocator_type&) failed to throw std::out_of_range"));
206 "original const string modified");
208 rw_assert (0 == nbytes, __FILE__, __LINE__,
209 "string::string (const string&, size_type, size_type, "
210 "const allocator_type&) leaked %u bytes", nbytes);
216 rw_info (0, __FILE__, __LINE__,
"21.3.1, p4 (npos)");
238 rw_assert (1 == thrown, __FILE__, __LINE__,
239 "string::string (const string&, size_type, size_type, "
240 "const allocator_type&) failed to use __rw::__rw_throw()");
242 rw_assert (0 == nbytes, __FILE__, __LINE__,
243 "string::string (const string&, size_type, size_type, "
244 "const allocator_type&) leaked %u bytes", nbytes);
247 "original const string modified");
251test_max_size_ctor1 ()
253 rw_info (0, __FILE__, __LINE__,
"21.3.1, p7");
274 rw_assert (1 == thrown, __FILE__, __LINE__,
275 "string::string (const char_type*, size_type) "
276 "failed to use __rw::__rw_throw()");
278 rw_assert (0 == nbytes, __FILE__, __LINE__,
279 "string::string (const char_type*, size_type)"
280 "leaked %u bytes", nbytes);
283 "original const string modified");
287test_max_size_ctor2 ()
289 rw_info (0, __FILE__, __LINE__,
"21.3.1, p13");
303 rw_assert (1 == thrown, __FILE__, __LINE__,
304 "string::string (size_type, char_type) "
305 "failed to use __rw::__rw_throw()");
311 rw_info (0, __FILE__, __LINE__,
"21.3.1, p15");
324 rw_assert (1 == thrown, __FILE__, __LINE__,
325 "string::string (InputIterator, InputIterator)"
326 "failed to use __rw::__rw_throw()");
336 rw_info (0, __FILE__, __LINE__,
"21.3.3, p6");
341 const String::const_pointer s1_data =
s1.data ();
342 const String::size_type s1_size =
s1.size ();
343 const String::size_type s1_cap =
s1.capacity ();
346 "std::string::string (const string&)");
352 s1.resize (
s1.max_size () + 1U );
359 rw_assert (1 == thrown, __FILE__, __LINE__,
360 "string::resize (size_type, char_type)"
361 "failed to use __rw::__rw_throw()");
365 && s1_cap ==
s1.capacity (), __FILE__, __LINE__,
366 "string::resize (size_type, char_type) modified *this");
372 rw_info (0, __FILE__, __LINE__,
"21.3.3, p12");
378 const String::const_pointer s1_data =
s1.data ();
379 const String::size_type s1_size =
s1.size ();
380 const String::size_type s1_cap =
s1.capacity ();
384 s1.reserve (
s1.max_size () + 1U);
391 rw_assert (1 == thrown, __FILE__, __LINE__,
392 "string::reserve (size_type)"
393 "failed to use __rw::__rw_throw()");
397 && s1_cap ==
s1.capacity (), __FILE__, __LINE__,
398 "string::reserve (size_type) modified *this");
404 rw_info (0, __FILE__, __LINE__,
"21.3.4, p3");
410 const String::const_pointer s1_data =
s1.data ();
411 const String::size_type s1_size =
s1.size ();
412 const String::size_type s1_cap =
s1.capacity ();
423 rw_assert (1 == thrown, __FILE__, __LINE__,
424 "string::at (size_type) failed to use __rw::__rw_throw()");
428 && s1_cap ==
s1.capacity (), __FILE__, __LINE__,
429 "string::at (size_type) modified *this");
435 rw_info (0, __FILE__, __LINE__,
"21.3.5.2, p3");
441 const String::const_pointer s1_data =
s1.data ();
442 const String::size_type s1_size =
s1.size ();
443 const String::size_type s1_cap =
s1.capacity ();
447 s1.append (
s1,
s1.size () + 1, 0);
454 rw_assert (1 == thrown, __FILE__, __LINE__,
455 "string::append (const string&, size_type, size_type) "
456 "failed to use __rw::__rw_throw()");
460 && s1_cap ==
s1.capacity (), __FILE__, __LINE__,
461 "string::append (const string&, size_type, size_type) "
468 rw_info (0, __FILE__, __LINE__,
"21.3.5.3, p3");
474 const String::const_pointer s1_data =
s1.data ();
475 const String::size_type s1_size =
s1.size ();
476 const String::size_type s1_cap =
s1.capacity ();
480 s1.assign (
s1,
s1.size () + 1, 0);
487 rw_assert (1 == thrown, __FILE__, __LINE__,
488 "string::assign (const string&, size_type, size_type) "
489 "failed to use __rw::__rw_throw()");
493 && s1_cap ==
s1.capacity (), __FILE__, __LINE__,
494 "string::assign (const string&, size_type, size_type) "
501 rw_info (0, __FILE__, __LINE__,
"21.3.5.4, p3 (pos1 > size ())");
507 const String::const_pointer s1_data =
s1.data ();
508 const String::size_type s1_size =
s1.size ();
509 const String::size_type s1_cap =
s1.capacity ();
515 s1.insert (
s1.size () + 1,
s1, 0, 0);
522 rw_assert (1 == thrown, __FILE__, __LINE__,
523 "string::insert (size_type, const string&, size_type, "
524 "size_type) failed to use __rw::__rw_throw()");
528 && s1_cap ==
s1.capacity (), __FILE__, __LINE__,
529 "string::insert (size_type, const string&, size_type, "
536 rw_info (0, __FILE__, __LINE__,
"21.3.5.4, p3 (pos2 > str.size ())");
542 const String::const_pointer s1_data =
s1.data ();
543 const String::size_type s1_size =
s1.size ();
544 const String::size_type s1_cap =
s1.capacity ();
550 s1.insert (
s1.size (),
s1,
s1.size () + 1, 0);
557 rw_assert (1 == thrown, __FILE__, __LINE__,
558 "string::insert (size_type, const string&, size_type, "
559 "size_type) failed to use __rw::__rw_throw()");
563 && s1_cap ==
s1.capacity (), __FILE__, __LINE__,
564 "string::insert (size_type, const string&, size_type, "
571 rw_info (0, __FILE__, __LINE__,
"21.3.5.5, p2");
577 const String::const_pointer s1_data =
s1.data ();
578 const String::size_type s1_size =
s1.size ();
579 const String::size_type s1_cap =
s1.capacity ();
583 s1.erase (
s1.size () + 1 );
590 rw_assert (1 == thrown, __FILE__, __LINE__,
591 "string::erase (size_type, size_type) "
592 "failed to use __rw::__rw_throw()");
596 && s1_cap ==
s1.capacity (), __FILE__, __LINE__,
597 "string::erase (size_type, size_type) modified *this");
603 rw_info (0, __FILE__, __LINE__,
"21.3.5.6, p3 (pos1 > size ())");
609 const String::const_pointer s1_data =
s1.data ();
610 const String::size_type s1_size =
s1.size ();
611 const String::size_type s1_cap =
s1.capacity ();
617 s1.replace (
s1.size () + 1, 0,
s0,
s0.size (), 0);
624 rw_assert (1 == thrown, __FILE__, __LINE__,
625 "string::replace (size_type, size_type, const string&, "
626 "size_type, size_type) failed to use __rw::__rw_throw()");
630 && s1_cap ==
s1.capacity (), __FILE__, __LINE__,
631 "string::replace (size_type, size_type, const string&, "
632 "size_type, size_type) modified *this");
638 rw_info (0, __FILE__, __LINE__,
"21.3.5.6, p3 (pos2 > str.size ())");
644 const String::const_pointer s1_data =
s1.data ();
645 const String::size_type s1_size =
s1.size ();
646 const String::size_type s1_cap =
s1.capacity ();
652 s1.replace (
s1.size (), 0,
s1,
s1.size () + 1, 0);
659 rw_assert (1 == thrown, __FILE__, __LINE__,
660 "string::replace (size_type, size_type, const string&, "
661 "size_type, size_type) failed to use __rw::__rw_throw()");
665 && s1_cap ==
s1.capacity (), __FILE__, __LINE__,
666 "string::replace (size_type, size_type, const string&, "
667 "size_type, size_type) modified *this");
673 rw_info (0, __FILE__, __LINE__,
"21.3.5.6, p5");
679 const String::const_pointer s1_data =
s1.data ();
680 const String::size_type s1_size =
s1.size ();
681 const String::size_type s1_cap =
s1.capacity ();
702 s1.replace (0, 1,
s2, 0,
s2.size ());
713 rw_assert (1 == thrown, __FILE__, __LINE__,
714 "string::replace (size_type, size_type, const string&, "
715 "size_type, size_type) failed to use __rw::__rw_throw()");
719 && s1_cap ==
s1.capacity (), __FILE__, __LINE__,
720 "string::replace (size_type, size_type, const string&, "
721 "size_type, size_type) modified *this");
724 rw_assert (1 == thrown, __FILE__, __LINE__,
725 "string::replace (size_type, size_type, const string&, "
726 "size_type, size_type) leaked %u bytes", nbytes);
732 rw_info (0, __FILE__, __LINE__,
"21.3.5.7, p2");
742 s1.copy (&
c, 1,
s1.size () + 1);
749 rw_assert (1 == thrown, __FILE__, __LINE__,
750 "string::copy (pointer, size_type, size_type) "
751 "failed to use __rw::__rw_throw()");
755 "string::copy (pointer, size_type, size_type) "
762 rw_info (0, __FILE__, __LINE__,
"21.3.6.7, p2");
770 s1.substr (
s1.size () + 1 );
777 rw_assert (1 == thrown, __FILE__, __LINE__,
778 "string::substr (size_type, size_type) "
779 "failed to use __rw::__rw_throw()");
787 test_simple_throw ();
793 test_max_size_ctor1 ();
794 test_max_size_ctor2 ();
823 return rw_test (argc, argv, __FILE__,
void test_append(charT *, Traits *, Allocator *, const RangeBase< std::basic_string< charT, Traits, Allocator > > &rng, const StringTestCaseData< charT > &tdata)
std::allocator< Char > CharAllocator
std::char_traits< Char > CharTraits
void user_throw(int ex_id, char *what)
std::basic_string< Char, CharTraits, CharAllocator > String
void test_assign(int line, int exceptions, const Iterator &dummy, int nelems, const char *seq, std::size_t seqlen, const char *asn, std::size_t asnlen, const char *res, std::size_t reslen)
void test_erase(int line, const char *seq, std::size_t seqlen, std::size_t begoff, std::size_t len, const char *res, std::size_t reslen)
void test_copy(std::size_t N, const InputIterator &input_iter, const OutputIterator &output_iter, const T *)
void run_test(const ForwardIterator &dummy, T *, Predicate *pred)
void test_size_ctor(const T *, const char *tname, bool copy)
#define _RWSTD_SPECIALIZED_CLASS
#define _RWSTD_REQUIRES(pred, args)
#define _RWSTD_UNUSED(arg)
#define _RWSTD_NAMESPACE(name)
#define _RWSTD_FUNC(ignore)
#define _RWSTD_NEW_CAPACITY(ignore, what, from)
#define _RWSTD_ERROR_LENGTH_ERROR
#define _RWSTD_ERROR_OUT_OF_RANGE
_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_assert(int, const char *, int, const char *,...)
_TEST_EXPORT _RWSTD_SIZE_T rwt_check_leaks(_RWSTD_SIZE_T *, const rwt_free_store *)