#include <sstream>
#include <testsuite_hooks.h>
std::wstring str_01(L"mykonos. . . or what?");
std::wstringbuf strb_01(str_01);
void test04()
{
bool test __attribute__((unused)) = true;
std::wstring str_tmp;
std::streamsize strmsz_1, strmsz_2;
typedef std::wstringbuf::int_type int_type;
typedef std::wstringbuf::traits_type traits_type;
typedef std::wstringbuf::pos_type pos_type;
typedef std::wstringbuf::off_type off_type;
int_type c1 = strb_01.sbumpc();
int_type c2, c3;
pos_type pt_1(off_type(-1));
pos_type pt_2(off_type(0));
off_type off_1 = 0;
off_type off_2 = 0;
strb_01.str(str_01);
pt_1 = strb_01.pubseekoff(2, std::ios_base::beg);
off_1 = off_type(pt_1);
VERIFY( off_1 >= 0 );
c1 = strb_01.snextc(); VERIFY( c1 == L'o' );
c2 = strb_01.sputc(L'x'); str_tmp = std::wstring(L"myxonos. . . or what?");
VERIFY( strb_01.str() == str_tmp );
pt_1 = strb_01.pubseekoff(2, std::ios_base::cur);
off_1 = off_type(pt_1);
VERIFY( off_1 == -1 ); pt_1 = strb_01.pubseekoff(2, std::ios_base::cur, std::ios_base::in);
off_1 = off_type(pt_1);
pt_2 = strb_01.pubseekoff(2, std::ios_base::cur, std::ios_base::in);
off_2 = off_type(pt_2);
VERIFY( off_2 == off_1 + 2 );
c1 = strb_01.snextc(); VERIFY( c1 == L' ' );
c2 = strb_01.sputc(L'x'); str_tmp = std::wstring(L"myxxnos. . . or what?");
VERIFY( strb_01.str() == str_tmp );
pt_2 = strb_01.pubseekoff(2, std::ios_base::end);
off_1 = off_type(pt_2);
VERIFY( off_1 == -1 ); VERIFY( strb_01.str() == str_tmp );
strb_01.pubseekoff(0, std::ios_base::end);
strmsz_1 = strb_01.in_avail(); c1 = strb_01.sgetc();
c2 = strb_01.sungetc();
strmsz_2 = strb_01.in_avail(); c3 = strb_01.sgetc();
VERIFY( c1 != c2 );
VERIFY( strmsz_2 != strmsz_1 );
VERIFY( strmsz_2 == 1 );
strmsz_1 = strb_01.str().size();
strmsz_2 = strb_01.sputn(L" ravi shankar meets carlos santana in LoHa", 90);
strb_01.pubseekoff(0, std::ios_base::end);
strb_01.sputc(L'<');
str_tmp = strb_01.str();
VERIFY(static_cast<std::streamsize>(str_tmp.size()) == strmsz_1 + strmsz_2 + 1);
}
int main()
{
test04();
return 0;
}