#include <string>
#include <stdexcept>
#include <testsuite_hooks.h>
int test01(void)
{
bool test __attribute__((unused)) = true;
typedef std::string::size_type csize_type;
typedef std::string::iterator citerator;
csize_type csz01, csz02;
const std::string str01("rodeo beach, marin");
const std::string str02("baker beach, san francisco");
std::string str03;
str03 = str01;
csz01 = str03.size();
csz02 = str02.size();
try {
str03.insert(csz01 + 1, str02, 0, 5);
VERIFY( false );
}
catch(std::out_of_range& fail) {
VERIFY( true );
}
catch(...) {
VERIFY( false );
}
str03 = str01;
csz01 = str03.size();
csz02 = str02.size();
try {
str03.insert(0, str02, csz02 + 1, 5);
VERIFY( false );
}
catch(std::out_of_range& fail) {
VERIFY( true );
}
catch(...) {
VERIFY( false );
}
csz01 = str01.max_size();
try {
std::string str04(csz01, 'b');
str03 = str04;
csz02 = str02.size();
try {
str03.insert(0, str02, 0, 5);
VERIFY( false );
}
catch(std::length_error& fail) {
VERIFY( true );
}
catch(...) {
VERIFY( false );
}
}
catch(std::bad_alloc& failure){
VERIFY( true );
}
catch(std::exception& failure){
VERIFY( false );
}
str03 = str01;
csz01 = str03.size();
csz02 = str02.size();
str03.insert(13, str02, 0, 12);
VERIFY( str03 == "rodeo beach, baker beach,marin" );
str03 = str01;
csz01 = str03.size();
csz02 = str02.size();
str03.insert(0, str02, 0, 12);
VERIFY( str03 == "baker beach,rodeo beach, marin" );
str03 = str01;
csz01 = str03.size();
csz02 = str02.size();
str03.insert(csz01, str02, 0, csz02);
VERIFY( str03 == "rodeo beach, marinbaker beach, san francisco" );
str03 = str01;
csz01 = str03.size();
csz02 = str02.size();
str03.insert(csz01, str02);
VERIFY( str03 == "rodeo beach, marinbaker beach, san francisco" );
str03 = str01;
csz01 = str03.size();
csz02 = str02.size();
str03.insert(0, str02);
VERIFY( str03 == "baker beach, san franciscorodeo beach, marin" );
str03 = str02;
csz01 = str03.size();
str03.insert(0, "-break at the bridge", 20);
VERIFY( str03 == "-break at the bridgebaker beach, san francisco" );
str03 = str02;
str03.insert(0, "-break at the bridge");
VERIFY( str03 == "-break at the bridgebaker beach, san francisco" );
str03 = str02;
csz01 = str03.size();
str03.insert(csz01, 5, 'z');
VERIFY( str03 == "baker beach, san franciscozzzzz" );
str03 = str02;
citerator cit01 = str03.begin();
str03.insert(cit01, 'u');
VERIFY( str03 == "ubaker beach, san francisco" );
str03 = str02;
cit01 = str03.begin();
str03.insert(cit01, 5, 'u');
VERIFY( str03 == "uuuuubaker beach, san francisco" );
str03 = str02;
csz01 = str03.size();
str03.insert(str03.begin(), str01.begin(), str01.end());
VERIFY( str03 == "rodeo beach, marinbaker beach, san francisco" );
str03 = str02;
csz01 = str03.size();
str03.insert(str03.end(), str01.begin(), str01.end());
VERIFY( str03 == "baker beach, san franciscorodeo beach, marin" );
return test;
}
int main()
{
__gnu_test::set_memory_limits();
test01();
return 0;
}