#include <fstream>
#include <testsuite_hooks.h>
#include <testsuite_io.h>
const char name_01[] = "seekpos-1io.tst";
void test05()
{
using namespace std;
using namespace __gnu_test;
typedef filebuf::int_type int_type;
typedef filebuf::pos_type pos_type;
typedef filebuf::off_type off_type;
bool test __attribute__((unused)) = true;
int_type c1;
int_type c2;
int_type c3;
pos_type pt_1(off_type(-1));
pos_type pt_2(off_type(0));
pos_type pt_3;
off_type off_1 = 0;
off_type off_2 = 0;
{
constraint_filebuf fb;
fb.open(name_01, ios_base::out | ios_base::in);
VERIFY( !fb.write_position() );
VERIFY( !fb.read_position() );
pt_1 = fb.pubseekoff(78, ios_base::beg);
off_1 = off_type(pt_1);
VERIFY( off_1 > 0 );
c1 = fb.snextc(); VERIFY( c1 == 't' );
pt_3 = fb.pubseekoff(0, ios_base::cur);
fb.pubseekpos(pt_3);
c2 = fb.sputc('\n'); pt_3 = fb.pubseekoff(0, ios_base::cur);
fb.pubseekpos(pt_3);
c3 = fb.sgetc();
fb.pubsync(); pt_2 = fb.pubseekpos(pt_1);
off_2 = off_type(pt_2);
VERIFY( off_1 == off_2 );
c3 = fb.snextc(); VERIFY( c2 == c3 );
pt_1 = fb.pubseekoff(0, ios_base::end);
off_1 = off_type(pt_1);
VERIFY( off_1 > off_2 );
fb.sputn("\nof the wonderful things he does!!\nok", 37);
fb.pubsync();
VERIFY( fb.write_position() );
VERIFY( !fb.read_position() );
fb.close();
VERIFY( !fb.is_open() );
}
}
int main()
{
test05();
return 0;
}