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