#include <new>
#include <string>
#include <stdexcept>
#include <testsuite_hooks.h>
void test01(void)
{
bool test __attribute__((unused)) = true;
typedef std::string::size_type csize_type;
typedef std::string::iterator citerator;
csize_type npos = std::string::npos;
csize_type csz01;
const char str_lit01[] = "rodeo beach, marin";
const std::string str01(str_lit01);
const std::string str02("baker beach, san francisco");
csz01 = str01.size();
try {
std::string str03(str01, csz01 + 1);
VERIFY( false );
}
catch(std::out_of_range& fail) {
VERIFY( true );
}
catch(...) {
VERIFY( false );
}
try {
std::string str03(str01, csz01);
VERIFY( str03.size() == 0 );
VERIFY( str03.size() <= str03.capacity() );
}
catch(...) {
VERIFY( false );
}
csz01 = str01.max_size();
try {
std::string str03(str_lit01, csz01 + 1);
VERIFY( true );
}
catch(std::length_error& fail) {
VERIFY( true );
}
catch(...) {
VERIFY( false );
}
try {
std::string str04(str_lit01, npos);
VERIFY( true );
}
catch(std::length_error& fail) {
VERIFY( true );
}
catch(...) {
VERIFY( false );
}
try {
std::string str03(csz01 - 1, 'A');
VERIFY( str03.size() == csz01 - 1 );
VERIFY( str03.size() <= str03.capacity() );
}
catch(std::bad_alloc& fail) {
VERIFY( true );
}
catch(...) {
VERIFY( false );
}
std::string str04(str_lit01);
VERIFY( str01 == str04 );
csz01 = str01.max_size();
try {
std::string str03(csz01 + 1, 'z');
VERIFY( false );
}
catch(std::length_error& fail) {
VERIFY( true );
}
catch(...) {
VERIFY( false );
}
try {
std::string str04(npos, 'b'); VERIFY( false );
}
catch(std::length_error& fail) {
VERIFY( true );
}
catch(...) {
VERIFY( false );
}
try {
std::string str03(csz01 - 1, 'z');
VERIFY( str03.size() != 0 );
VERIFY( str03.size() <= str03.capacity() );
}
catch(std::bad_alloc& fail) {
VERIFY( true );
}
catch(...) {
VERIFY( false );
}
std::string str06(str01.begin(), str01.end());
VERIFY( str06 == str01 );
}
int main()
{
__gnu_test::set_memory_limits();
test01();
return 0;
}