msvcirt: Implement strstream constructors.

Signed-off-by: Iván Matellanes <matellanesivan@gmail.com>
Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Iván Matellanes 2016-10-21 19:34:02 +02:00 committed by Alexandre Julliard
parent 4df13fff82
commit 95018e6887
2 changed files with 409 additions and 6 deletions

View File

@ -4225,13 +4225,44 @@ iostream* __thiscall iostream_scalar_dtor(ios *base, unsigned int flags)
return this;
}
static iostream* iostream_internal_copy_ctor(iostream *this, const iostream *copy, const vtable_ptr *vtbl, BOOL virt_init)
{
ios *base, *base_copy = istream_get_ios(&copy->base1);
if (virt_init) {
this->base1.vbtable = iostream_vbtable_istream;
this->base2.vbtable = iostream_vbtable_ostream;
base = istream_get_ios(&this->base1);
ios_copy_ctor(base, base_copy);
} else
base = istream_get_ios(&this->base1);
ios_init(base, base_copy->sb);
istream_ctor(&this->base1, FALSE);
ostream_ctor(&this->base2, FALSE);
base->vtable = vtbl;
return this;
}
static iostream* iostream_internal_sb_ctor(iostream *this, streambuf *sb, const vtable_ptr *vtbl, BOOL virt_init)
{
ios *base;
iostream_ctor(this, virt_init);
base = istream_get_ios(&this->base1);
if (sb)
ios_init(base, sb);
base->vtable = vtbl;
base->delbuf = 1;
return this;
}
/* ??0strstream@@QAE@ABV0@@Z */
/* ??0strstream@@QEAA@AEBV0@@Z */
DEFINE_THISCALL_WRAPPER(strstream_copy_ctor, 12)
iostream* __thiscall strstream_copy_ctor(iostream *this, const iostream *copy, BOOL virt_init)
{
FIXME("(%p %p %d) stub\n", this, copy, virt_init);
return this;
TRACE("(%p %p %d)\n", this, copy, virt_init);
return iostream_internal_copy_ctor(this, copy, &MSVCP_strstream_vtable, virt_init);
}
/* ??0strstream@@QAE@PADHH@Z */
@ -4239,8 +4270,17 @@ iostream* __thiscall strstream_copy_ctor(iostream *this, const iostream *copy, B
DEFINE_THISCALL_WRAPPER(strstream_buffer_ctor, 20)
iostream* __thiscall strstream_buffer_ctor(iostream *this, char *buffer, int length, int mode, BOOL virt_init)
{
FIXME("(%p %p %d %d %d) stub\n", this, buffer, length, mode, virt_init);
return this;
strstreambuf *ssb = MSVCRT_operator_new(sizeof(strstreambuf));
TRACE("(%p %p %d %d %d)\n", this, buffer, length, mode, virt_init);
if (ssb) {
strstreambuf_buffer_ctor(ssb, buffer, length, buffer);
if ((mode & OPENMODE_out) && (mode & (OPENMODE_app|OPENMODE_ate)))
ssb->base.pptr = buffer + strlen(buffer);
return iostream_internal_sb_ctor(this, &ssb->base, &MSVCP_strstream_vtable, virt_init);
}
return iostream_internal_sb_ctor(this, NULL, &MSVCP_strstream_vtable, virt_init);
}
/* ??0strstream@@QAE@XZ */
@ -4248,8 +4288,15 @@ iostream* __thiscall strstream_buffer_ctor(iostream *this, char *buffer, int len
DEFINE_THISCALL_WRAPPER(strstream_ctor, 8)
iostream* __thiscall strstream_ctor(iostream *this, BOOL virt_init)
{
FIXME("(%p %d) stub\n", this, virt_init);
return this;
strstreambuf *ssb = MSVCRT_operator_new(sizeof(strstreambuf));
TRACE("(%p %d)\n", this, virt_init);
if (ssb) {
strstreambuf_ctor(ssb);
return iostream_internal_sb_ctor(this, &ssb->base, &MSVCP_strstream_vtable, virt_init);
}
return iostream_internal_sb_ctor(this, NULL, &MSVCP_strstream_vtable, virt_init);
}
/* ?pcount@strstream@@QBEHXZ */

View File

@ -404,6 +404,14 @@ static void (*__thiscall p_iostream_vbase_dtor)(iostream*);
static iostream* (*__thiscall p_iostream_assign_sb)(iostream*, streambuf*);
static iostream* (*__thiscall p_iostream_assign)(iostream*, const iostream*);
/* strstream */
static iostream* (*__thiscall p_strstream_copy_ctor)(iostream*, const iostream*, BOOL);
static iostream* (*__thiscall p_strstream_buffer_ctor)(iostream*, char*, int, int, BOOL);
static iostream* (*__thiscall p_strstream_ctor)(iostream*, BOOL);
static void (*__thiscall p_strstream_dtor)(ios*);
static void (*__thiscall p_strstream_vbase_dtor)(iostream*);
static iostream* (*__thiscall p_strstream_assign)(iostream*, const iostream*);
/* Iostream_init */
static void* (*__thiscall p_Iostream_init_ios_ctor)(void*, ios*, int);
@ -681,6 +689,13 @@ static BOOL init(void)
SET(p_iostream_assign_sb, "??4iostream@@IEAAAEAV0@PEAVstreambuf@@@Z");
SET(p_iostream_assign, "??4iostream@@IEAAAEAV0@AEAV0@@Z");
SET(p_strstream_copy_ctor, "??0strstream@@QEAA@AEBV0@@Z");
SET(p_strstream_buffer_ctor, "??0strstream@@QEAA@PEADHH@Z");
SET(p_strstream_ctor, "??0strstream@@QEAA@XZ");
SET(p_strstream_dtor, "??1strstream@@UEAA@XZ");
SET(p_strstream_vbase_dtor, "??_Dstrstream@@QEAAXXZ");
SET(p_strstream_assign, "??4strstream@@QEAAAEAV0@AEAV0@@Z");
SET(p_Iostream_init_ios_ctor, "??0Iostream_init@@QEAA@AEAVios@@H@Z");
} else {
p_operator_new = (void*)GetProcAddress(msvcrt, "??2@YAPAXI@Z");
@ -875,6 +890,13 @@ static BOOL init(void)
SET(p_iostream_assign_sb, "??4iostream@@IAEAAV0@PAVstreambuf@@@Z");
SET(p_iostream_assign, "??4iostream@@IAEAAV0@AAV0@@Z");
SET(p_strstream_copy_ctor, "??0strstream@@QAE@ABV0@@Z");
SET(p_strstream_buffer_ctor, "??0strstream@@QAE@PADHH@Z");
SET(p_strstream_ctor, "??0strstream@@QAE@XZ");
SET(p_strstream_dtor, "??1strstream@@UAE@XZ");
SET(p_strstream_vbase_dtor, "??_Dstrstream@@QAEXXZ");
SET(p_strstream_assign, "??4strstream@@QAEAAV0@AAV0@@Z");
SET(p_Iostream_init_ios_ctor, "??0Iostream_init@@QAE@AAVios@@H@Z");
}
SET(p_ios_static_lock, "?x_lockc@ios@@0U_CRT_CRITICAL_SECTION@@A");
@ -6658,6 +6680,339 @@ static void test_iostream(void)
ok(ios2.base_ios.do_lock == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, ios2.base_ios.do_lock);
}
static void test_strstream(void)
{
iostream ios1, ios2, *pios;
ostream *pos;
strstreambuf *pssb;
char buffer[32];
memset(&ios1, 0xab, sizeof(iostream));
memset(&ios2, 0xab, sizeof(iostream));
/* constructors/destructors */
pios = call_func2(p_strstream_ctor, &ios1, TRUE);
pssb = (strstreambuf*) ios1.base_ios.sb;
ok(pios == &ios1, "wrong return, expected %p got %p\n", &ios1, pios);
ok(ios1.base1.extract_delim == 0, "expected 0 got %d\n", ios1.base1.extract_delim);
ok(ios1.base1.count == 0, "expected 0 got %d\n", ios1.base1.count);
ok(ios1.base2.unknown == 0, "expected 0 got %d\n", ios1.base2.unknown);
ok(ios1.base_ios.sb != NULL, "expected not %p got %p\n", NULL, ios1.base_ios.sb);
ok(ios1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ios1.base_ios.state);
ok(ios1.base_ios.delbuf == 1, "expected 1 got %d\n", ios1.base_ios.delbuf);
ok(ios1.base_ios.tie == NULL, "expected %p got %p\n", NULL, ios1.base_ios.tie);
ok(ios1.base_ios.flags == FLAGS_skipws, "expected %x got %x\n", FLAGS_skipws, ios1.base_ios.flags);
ok(ios1.base_ios.precision == 6, "expected 6 got %d\n", ios1.base_ios.precision);
ok(ios1.base_ios.fill == ' ', "expected 32 got %d\n", ios1.base_ios.fill);
ok(ios1.base_ios.width == 0, "expected 0 got %d\n", ios1.base_ios.width);
ok(ios1.base_ios.do_lock == -1, "expected -1 got %d\n", ios1.base_ios.do_lock);
ok(pssb->dynamic == 1, "expected 1, got %d\n", pssb->dynamic);
ok(pssb->increase == 1, "expected 1, got %d\n", pssb->increase);
ok(pssb->constant == 0, "expected 0, got %d\n", pssb->constant);
ok(pssb->f_alloc == NULL, "expected %p, got %p\n", NULL, pssb->f_alloc);
ok(pssb->f_free == NULL, "expected %p, got %p\n", NULL, pssb->f_free);
ok(pssb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pssb->base.allocated);
ok(pssb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pssb->base.unbuffered);
ok(pssb->base.base == NULL, "wrong buffer, expected %p got %p\n", NULL, pssb->base.base);
ok(pssb->base.ebuf == NULL, "wrong buffer end, expected %p got %p\n", NULL, pssb->base.ebuf);
ok(pssb->base.do_lock == -1, "expected -1 got %d\n", pssb->base.do_lock);
call_func1(p_strstream_vbase_dtor, &ios1);
ok(ios1.base_ios.sb == NULL, "expected %p got %p\n", NULL, ios1.base_ios.sb);
ok(ios1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, ios1.base_ios.state);
ios1.base1.extract_delim = ios1.base1.count = 0xabababab;
ios1.base2.unknown = 0xabababab;
memset(&ios1.base_ios, 0xab, sizeof(ios));
ios1.base_ios.delbuf = 0;
pios = call_func2(p_strstream_ctor, &ios1, FALSE);
pssb = (strstreambuf*) ios1.base_ios.sb;
ok(pios == &ios1, "wrong return, expected %p got %p\n", &ios1, pios);
ok(ios1.base1.extract_delim == 0, "expected 0 got %d\n", ios1.base1.extract_delim);
ok(ios1.base1.count == 0, "expected 0 got %d\n", ios1.base1.count);
ok(ios1.base2.unknown == 0, "expected 0 got %d\n", ios1.base2.unknown);
ok(ios1.base_ios.sb != NULL, "expected not %p got %p\n", NULL, ios1.base_ios.sb);
ok(ios1.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.state);
ok(ios1.base_ios.delbuf == 1, "expected 1 got %d\n", ios1.base_ios.delbuf);
ok(ios1.base_ios.tie == ios2.base_ios.tie, "expected %p got %p\n", ios2.base_ios.tie, ios1.base_ios.tie);
ok(ios1.base_ios.flags == 0xabababab, "expected %x got %x\n", 0xabababab, ios1.base_ios.flags);
ok(ios1.base_ios.precision == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.precision);
ok(ios1.base_ios.fill == (char) 0xab, "expected -85 got %d\n", ios1.base_ios.fill);
ok(ios1.base_ios.width == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.width);
ok(ios1.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.do_lock);
ok(pssb->dynamic == 1, "expected 1, got %d\n", pssb->dynamic);
ok(pssb->increase == 1, "expected 1, got %d\n", pssb->increase);
ok(pssb->constant == 0, "expected 0, got %d\n", pssb->constant);
ok(pssb->f_alloc == NULL, "expected %p, got %p\n", NULL, pssb->f_alloc);
ok(pssb->f_free == NULL, "expected %p, got %p\n", NULL, pssb->f_free);
ok(pssb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pssb->base.allocated);
ok(pssb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pssb->base.unbuffered);
ok(pssb->base.base == NULL, "wrong buffer, expected %p got %p\n", NULL, pssb->base.base);
ok(pssb->base.ebuf == NULL, "wrong buffer end, expected %p got %p\n", NULL, pssb->base.ebuf);
ok(pssb->base.do_lock == -1, "expected -1 got %d\n", pssb->base.do_lock);
call_func1(p_strstream_dtor, &ios1.base_ios);
ok(ios1.base_ios.sb == &pssb->base, "expected %p got %p\n", &pssb->base, ios1.base_ios.sb);
ok(ios1.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.state);
call_func1(p_strstreambuf_dtor, pssb);
p_operator_delete(pssb);
memset(&ios1, 0xab, sizeof(iostream));
pios = call_func5(p_strstream_buffer_ctor, &ios1, buffer, 32, 0, TRUE);
pssb = (strstreambuf*) ios1.base_ios.sb;
ok(pios == &ios1, "wrong return, expected %p got %p\n", &ios1, pios);
ok(ios1.base1.extract_delim == 0, "expected 0 got %d\n", ios1.base1.extract_delim);
ok(ios1.base1.count == 0, "expected 0 got %d\n", ios1.base1.count);
ok(ios1.base2.unknown == 0, "expected 0 got %d\n", ios1.base2.unknown);
ok(ios1.base_ios.sb != NULL, "expected not %p got %p\n", NULL, ios1.base_ios.sb);
ok(ios1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ios1.base_ios.state);
ok(ios1.base_ios.delbuf == 1, "expected 1 got %d\n", ios1.base_ios.delbuf);
ok(ios1.base_ios.tie == NULL, "expected %p got %p\n", NULL, ios1.base_ios.tie);
ok(ios1.base_ios.flags == FLAGS_skipws, "expected %x got %x\n", FLAGS_skipws, ios1.base_ios.flags);
ok(ios1.base_ios.precision == 6, "expected 6 got %d\n", ios1.base_ios.precision);
ok(ios1.base_ios.fill == ' ', "expected 32 got %d\n", ios1.base_ios.fill);
ok(ios1.base_ios.width == 0, "expected 0 got %d\n", ios1.base_ios.width);
ok(ios1.base_ios.do_lock == -1, "expected -1 got %d\n", ios1.base_ios.do_lock);
ok(pssb->dynamic == 0, "expected 0, got %d\n", pssb->dynamic);
ok(pssb->constant == 1, "expected 1, got %d\n", pssb->constant);
ok(pssb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pssb->base.allocated);
ok(pssb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pssb->base.unbuffered);
ok(pssb->base.base == buffer, "wrong buffer, expected %p got %p\n", buffer, pssb->base.base);
ok(pssb->base.ebuf == buffer + 32, "wrong buffer end, expected %p got %p\n", buffer + 32, pssb->base.ebuf);
ok(pssb->base.eback == buffer, "wrong get base, expected %p got %p\n", buffer, pssb->base.eback);
ok(pssb->base.gptr == buffer, "wrong get pointer, expected %p got %p\n", buffer, pssb->base.gptr);
ok(pssb->base.egptr == buffer, "wrong get end, expected %p got %p\n", buffer, pssb->base.egptr);
ok(pssb->base.pbase == buffer, "wrong put base, expected %p got %p\n", buffer, pssb->base.pbase);
ok(pssb->base.pptr == buffer, "wrong put pointer, expected %p got %p\n", buffer, pssb->base.pptr);
ok(pssb->base.epptr == buffer + 32, "wrong put end, expected %p got %p\n", buffer + 32, pssb->base.epptr);
ok(pssb->base.do_lock == -1, "expected -1 got %d\n", pssb->base.do_lock);
call_func1(p_strstream_vbase_dtor, &ios1);
ok(ios1.base_ios.sb == NULL, "expected %p got %p\n", NULL, ios1.base_ios.sb);
ok(ios1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, ios1.base_ios.state);
memset(&ios1, 0xab, sizeof(iostream));
pios = call_func5(p_strstream_buffer_ctor, &ios1, buffer, 16, OPENMODE_in, TRUE);
pssb = (strstreambuf*) ios1.base_ios.sb;
ok(pios == &ios1, "wrong return, expected %p got %p\n", &ios1, pios);
ok(ios1.base1.extract_delim == 0, "expected 0 got %d\n", ios1.base1.extract_delim);
ok(ios1.base1.count == 0, "expected 0 got %d\n", ios1.base1.count);
ok(ios1.base2.unknown == 0, "expected 0 got %d\n", ios1.base2.unknown);
ok(ios1.base_ios.sb != NULL, "expected not %p got %p\n", NULL, ios1.base_ios.sb);
ok(ios1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ios1.base_ios.state);
ok(ios1.base_ios.delbuf == 1, "expected 1 got %d\n", ios1.base_ios.delbuf);
ok(ios1.base_ios.tie == NULL, "expected %p got %p\n", NULL, ios1.base_ios.tie);
ok(ios1.base_ios.flags == FLAGS_skipws, "expected %x got %x\n", FLAGS_skipws, ios1.base_ios.flags);
ok(ios1.base_ios.precision == 6, "expected 6 got %d\n", ios1.base_ios.precision);
ok(ios1.base_ios.fill == ' ', "expected 32 got %d\n", ios1.base_ios.fill);
ok(ios1.base_ios.width == 0, "expected 0 got %d\n", ios1.base_ios.width);
ok(ios1.base_ios.do_lock == -1, "expected -1 got %d\n", ios1.base_ios.do_lock);
ok(pssb->dynamic == 0, "expected 0, got %d\n", pssb->dynamic);
ok(pssb->constant == 1, "expected 1, got %d\n", pssb->constant);
ok(pssb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pssb->base.allocated);
ok(pssb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pssb->base.unbuffered);
ok(pssb->base.base == buffer, "wrong buffer, expected %p got %p\n", buffer, pssb->base.base);
ok(pssb->base.ebuf == buffer + 16, "wrong buffer end, expected %p got %p\n", buffer + 16, pssb->base.ebuf);
ok(pssb->base.eback == buffer, "wrong get base, expected %p got %p\n", buffer, pssb->base.eback);
ok(pssb->base.gptr == buffer, "wrong get pointer, expected %p got %p\n", buffer, pssb->base.gptr);
ok(pssb->base.egptr == buffer, "wrong get end, expected %p got %p\n", buffer, pssb->base.egptr);
ok(pssb->base.pbase == buffer, "wrong put base, expected %p got %p\n", buffer, pssb->base.pbase);
ok(pssb->base.pptr == buffer, "wrong put pointer, expected %p got %p\n", buffer, pssb->base.pptr);
ok(pssb->base.epptr == buffer + 16, "wrong put end, expected %p got %p\n", buffer + 16, pssb->base.epptr);
ok(pssb->base.do_lock == -1, "expected -1 got %d\n", pssb->base.do_lock);
call_func1(p_strstream_vbase_dtor, &ios1);
ok(ios1.base_ios.sb == NULL, "expected %p got %p\n", NULL, ios1.base_ios.sb);
ok(ios1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, ios1.base_ios.state);
memset(&ios1, 0xab, sizeof(iostream));
pios = call_func5(p_strstream_buffer_ctor, &ios1, buffer, -1, OPENMODE_in|OPENMODE_out, TRUE);
pssb = (strstreambuf*) ios1.base_ios.sb;
ok(pios == &ios1, "wrong return, expected %p got %p\n", &ios1, pios);
ok(ios1.base1.extract_delim == 0, "expected 0 got %d\n", ios1.base1.extract_delim);
ok(ios1.base1.count == 0, "expected 0 got %d\n", ios1.base1.count);
ok(ios1.base2.unknown == 0, "expected 0 got %d\n", ios1.base2.unknown);
ok(ios1.base_ios.sb != NULL, "expected not %p got %p\n", NULL, ios1.base_ios.sb);
ok(ios1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ios1.base_ios.state);
ok(ios1.base_ios.delbuf == 1, "expected 1 got %d\n", ios1.base_ios.delbuf);
ok(ios1.base_ios.tie == NULL, "expected %p got %p\n", NULL, ios1.base_ios.tie);
ok(ios1.base_ios.flags == FLAGS_skipws, "expected %x got %x\n", FLAGS_skipws, ios1.base_ios.flags);
ok(ios1.base_ios.precision == 6, "expected 6 got %d\n", ios1.base_ios.precision);
ok(ios1.base_ios.fill == ' ', "expected 32 got %d\n", ios1.base_ios.fill);
ok(ios1.base_ios.width == 0, "expected 0 got %d\n", ios1.base_ios.width);
ok(ios1.base_ios.do_lock == -1, "expected -1 got %d\n", ios1.base_ios.do_lock);
ok(pssb->dynamic == 0, "expected 0, got %d\n", pssb->dynamic);
ok(pssb->constant == 1, "expected 1, got %d\n", pssb->constant);
ok(pssb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pssb->base.allocated);
ok(pssb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pssb->base.unbuffered);
ok(pssb->base.base == buffer, "wrong buffer, expected %p got %p\n", buffer, pssb->base.base);
ok(pssb->base.ebuf == buffer + 0x7fffffff || pssb->base.ebuf == (char*) -1,
"wrong buffer end, expected %p + 0x7fffffff or -1, got %p\n", buffer, pssb->base.ebuf);
ok(pssb->base.eback == buffer, "wrong get base, expected %p got %p\n", buffer, pssb->base.eback);
ok(pssb->base.gptr == buffer, "wrong get pointer, expected %p got %p\n", buffer, pssb->base.gptr);
ok(pssb->base.egptr == buffer, "wrong get end, expected %p got %p\n", buffer, pssb->base.egptr);
ok(pssb->base.pbase == buffer, "wrong put base, expected %p got %p\n", buffer, pssb->base.pbase);
ok(pssb->base.pptr == buffer, "wrong put pointer, expected %p got %p\n", buffer, pssb->base.pptr);
ok(pssb->base.epptr == buffer + 0x7fffffff || pssb->base.epptr == (char*) -1,
"wrong buffer end, expected %p + 0x7fffffff or -1, got %p\n", buffer, pssb->base.epptr);
ok(pssb->base.do_lock == -1, "expected -1 got %d\n", pssb->base.do_lock);
call_func1(p_strstream_vbase_dtor, &ios1);
ok(ios1.base_ios.sb == NULL, "expected %p got %p\n", NULL, ios1.base_ios.sb);
ok(ios1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, ios1.base_ios.state);
ios1.base1.extract_delim = ios1.base1.count = 0xabababab;
ios1.base2.unknown = 0xabababab;
memset(&ios1.base_ios, 0xab, sizeof(ios));
ios1.base_ios.delbuf = 0;
strcpy(buffer, "Test");
pios = call_func5(p_strstream_buffer_ctor, &ios1, buffer, 0, OPENMODE_in|OPENMODE_app, FALSE);
pssb = (strstreambuf*) ios1.base_ios.sb;
ok(pios == &ios1, "wrong return, expected %p got %p\n", &ios1, pios);
ok(ios1.base1.extract_delim == 0, "expected 0 got %d\n", ios1.base1.extract_delim);
ok(ios1.base1.count == 0, "expected 0 got %d\n", ios1.base1.count);
ok(ios1.base2.unknown == 0, "expected 0 got %d\n", ios1.base2.unknown);
ok(ios1.base_ios.sb != NULL, "expected not %p got %p\n", NULL, ios1.base_ios.sb);
ok(ios1.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.state);
ok(ios1.base_ios.delbuf == 1, "expected 1 got %d\n", ios1.base_ios.delbuf);
ok(ios1.base_ios.tie == ios2.base_ios.tie, "expected %p got %p\n", ios2.base_ios.tie, ios1.base_ios.tie);
ok(ios1.base_ios.flags == 0xabababab, "expected %x got %x\n", 0xabababab, ios1.base_ios.flags);
ok(ios1.base_ios.precision == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.precision);
ok(ios1.base_ios.fill == (char) 0xab, "expected -85 got %d\n", ios1.base_ios.fill);
ok(ios1.base_ios.width == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.width);
ok(ios1.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.do_lock);
ok(pssb->dynamic == 0, "expected 0, got %d\n", pssb->dynamic);
ok(pssb->constant == 1, "expected 1, got %d\n", pssb->constant);
ok(pssb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pssb->base.allocated);
ok(pssb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pssb->base.unbuffered);
ok(pssb->base.base == buffer, "wrong buffer, expected %p got %p\n", buffer, pssb->base.base);
ok(pssb->base.ebuf == buffer + 4, "wrong buffer end, expected %p got %p\n", buffer + 4, pssb->base.ebuf);
ok(pssb->base.eback == buffer, "wrong get base, expected %p got %p\n", buffer, pssb->base.eback);
ok(pssb->base.gptr == buffer, "wrong get pointer, expected %p got %p\n", buffer, pssb->base.gptr);
ok(pssb->base.egptr == buffer, "wrong get end, expected %p got %p\n", buffer, pssb->base.egptr);
ok(pssb->base.pbase == buffer, "wrong put base, expected %p got %p\n", buffer, pssb->base.pbase);
ok(pssb->base.pptr == buffer, "wrong put pointer, expected %p got %p\n", buffer, pssb->base.pptr);
ok(pssb->base.epptr == buffer + 4, "wrong put end, expected %p got %p\n", buffer + 4, pssb->base.epptr);
ok(pssb->base.do_lock == -1, "expected -1 got %d\n", pssb->base.do_lock);
call_func1(p_strstream_dtor, &ios1.base_ios);
ok(ios1.base_ios.sb == &pssb->base, "expected %p got %p\n", &pssb->base, ios1.base_ios.sb);
ok(ios1.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, ios1.base_ios.state);
call_func1(p_strstreambuf_dtor, pssb);
p_operator_delete(pssb);
memset(&ios1, 0xab, sizeof(iostream));
pios = call_func5(p_strstream_buffer_ctor, &ios1, buffer, 16, OPENMODE_ate, TRUE);
pssb = (strstreambuf*) ios1.base_ios.sb;
ok(pios == &ios1, "wrong return, expected %p got %p\n", &ios1, pios);
ok(ios1.base1.extract_delim == 0, "expected 0 got %d\n", ios1.base1.extract_delim);
ok(ios1.base1.count == 0, "expected 0 got %d\n", ios1.base1.count);
ok(ios1.base2.unknown == 0, "expected 0 got %d\n", ios1.base2.unknown);
ok(ios1.base_ios.sb != NULL, "expected not %p got %p\n", NULL, ios1.base_ios.sb);
ok(ios1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ios1.base_ios.state);
ok(ios1.base_ios.delbuf == 1, "expected 1 got %d\n", ios1.base_ios.delbuf);
ok(ios1.base_ios.tie == NULL, "expected %p got %p\n", NULL, ios1.base_ios.tie);
ok(ios1.base_ios.flags == FLAGS_skipws, "expected %x got %x\n", FLAGS_skipws, ios1.base_ios.flags);
ok(ios1.base_ios.precision == 6, "expected 6 got %d\n", ios1.base_ios.precision);
ok(ios1.base_ios.fill == ' ', "expected 32 got %d\n", ios1.base_ios.fill);
ok(ios1.base_ios.width == 0, "expected 0 got %d\n", ios1.base_ios.width);
ok(ios1.base_ios.do_lock == -1, "expected -1 got %d\n", ios1.base_ios.do_lock);
ok(pssb->dynamic == 0, "expected 0, got %d\n", pssb->dynamic);
ok(pssb->constant == 1, "expected 1, got %d\n", pssb->constant);
ok(pssb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pssb->base.allocated);
ok(pssb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pssb->base.unbuffered);
ok(pssb->base.base == buffer, "wrong buffer, expected %p got %p\n", buffer, pssb->base.base);
ok(pssb->base.ebuf == buffer + 16, "wrong buffer end, expected %p got %p\n", buffer + 16, pssb->base.ebuf);
ok(pssb->base.eback == buffer, "wrong get base, expected %p got %p\n", buffer, pssb->base.eback);
ok(pssb->base.gptr == buffer, "wrong get pointer, expected %p got %p\n", buffer, pssb->base.gptr);
ok(pssb->base.egptr == buffer, "wrong get end, expected %p got %p\n", buffer, pssb->base.egptr);
ok(pssb->base.pbase == buffer, "wrong put base, expected %p got %p\n", buffer, pssb->base.pbase);
ok(pssb->base.pptr == buffer, "wrong put pointer, expected %p got %p\n", buffer, pssb->base.pptr);
ok(pssb->base.epptr == buffer + 16, "wrong put end, expected %p got %p\n", buffer + 16, pssb->base.epptr);
ok(pssb->base.do_lock == -1, "expected -1 got %d\n", pssb->base.do_lock);
call_func1(p_strstream_vbase_dtor, &ios1);
ok(ios1.base_ios.sb == NULL, "expected %p got %p\n", NULL, ios1.base_ios.sb);
ok(ios1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, ios1.base_ios.state);
pios = call_func5(p_strstream_buffer_ctor, &ios1, buffer, 16, OPENMODE_out|OPENMODE_ate, TRUE);
pssb = (strstreambuf*) ios1.base_ios.sb;
ok(pios == &ios1, "wrong return, expected %p got %p\n", &ios1, pios);
ok(ios1.base1.extract_delim == 0, "expected 0 got %d\n", ios1.base1.extract_delim);
ok(ios1.base1.count == 0, "expected 0 got %d\n", ios1.base1.count);
ok(ios1.base2.unknown == 0, "expected 0 got %d\n", ios1.base2.unknown);
ok(ios1.base_ios.sb != NULL, "expected not %p got %p\n", NULL, ios1.base_ios.sb);
ok(ios1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ios1.base_ios.state);
ok(ios1.base_ios.delbuf == 1, "expected 1 got %d\n", ios1.base_ios.delbuf);
ok(ios1.base_ios.tie == NULL, "expected %p got %p\n", NULL, ios1.base_ios.tie);
ok(ios1.base_ios.flags == FLAGS_skipws, "expected %x got %x\n", FLAGS_skipws, ios1.base_ios.flags);
ok(ios1.base_ios.precision == 6, "expected 6 got %d\n", ios1.base_ios.precision);
ok(ios1.base_ios.fill == ' ', "expected 32 got %d\n", ios1.base_ios.fill);
ok(ios1.base_ios.width == 0, "expected 0 got %d\n", ios1.base_ios.width);
ok(ios1.base_ios.do_lock == -1, "expected -1 got %d\n", ios1.base_ios.do_lock);
ok(pssb->dynamic == 0, "expected 0, got %d\n", pssb->dynamic);
ok(pssb->constant == 1, "expected 1, got %d\n", pssb->constant);
ok(pssb->base.allocated == 0, "wrong allocate value, expected 0 got %d\n", pssb->base.allocated);
ok(pssb->base.unbuffered == 0, "wrong unbuffered value, expected 0 got %d\n", pssb->base.unbuffered);
ok(pssb->base.base == buffer, "wrong buffer, expected %p got %p\n", buffer, pssb->base.base);
ok(pssb->base.ebuf == buffer + 16, "wrong buffer end, expected %p got %p\n", buffer + 16, pssb->base.ebuf);
ok(pssb->base.eback == buffer, "wrong get base, expected %p got %p\n", buffer, pssb->base.eback);
ok(pssb->base.gptr == buffer, "wrong get pointer, expected %p got %p\n", buffer, pssb->base.gptr);
ok(pssb->base.egptr == buffer, "wrong get end, expected %p got %p\n", buffer, pssb->base.egptr);
ok(pssb->base.pbase == buffer, "wrong put base, expected %p got %p\n", buffer, pssb->base.pbase);
ok(pssb->base.pptr == buffer + 4, "wrong put pointer, expected %p got %p\n", buffer + 4, pssb->base.pptr);
ok(pssb->base.epptr == buffer + 16, "wrong put end, expected %p got %p\n", buffer + 16, pssb->base.epptr);
ok(pssb->base.do_lock == -1, "expected -1 got %d\n", pssb->base.do_lock);
call_func1(p_strstream_vbase_dtor, &ios1);
ok(ios1.base_ios.sb == NULL, "expected %p got %p\n", NULL, ios1.base_ios.sb);
ok(ios1.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, ios1.base_ios.state);
ios1.base1.extract_delim = ios1.base1.count = 0xcdcdcdcd;
ios1.base2.unknown = 0xcdcdcdcd;
memset(&ios1.base_ios, 0xcd, sizeof(ios));
pios = call_func3(p_strstream_copy_ctor, &ios2, &ios1, TRUE);
ok(pios == &ios2, "wrong return, expected %p got %p\n", &ios2, pios);
ok(ios2.base1.extract_delim == 0, "expected 0 got %d\n", ios2.base1.extract_delim);
ok(ios2.base1.count == 0, "expected 0 got %d\n", ios2.base1.count);
ok(ios2.base2.unknown == 0, "expected 0 got %d\n", ios2.base2.unknown);
ok(ios2.base_ios.sb == ios1.base_ios.sb, "expected %p got %p\n", ios1.base_ios.sb, ios2.base_ios.sb);
ok(ios2.base_ios.state == 0xcdcdcdc9, "expected %d got %d\n", 0xcdcdcdc9, ios2.base_ios.state);
ok(ios2.base_ios.delbuf == 0, "expected 0 got %d\n", ios2.base_ios.delbuf);
ok(ios2.base_ios.tie == ios1.base_ios.tie, "expected %p got %p\n", ios1.base_ios.tie, ios2.base_ios.tie);
ok(ios2.base_ios.flags == 0xcdcdcdcd, "expected %x got %x\n", 0xcdcdcdcd, ios2.base_ios.flags);
ok(ios2.base_ios.precision == (char) 0xcd, "expected -51 got %d\n", ios2.base_ios.precision);
ok(ios2.base_ios.fill == (char) 0xcd, "expected -51 got %d\n", ios2.base_ios.fill);
ok(ios2.base_ios.width == (char) 0xcd, "expected -51 got %d\n", ios2.base_ios.width);
ok(ios2.base_ios.do_lock == -1, "expected -1 got %d\n", ios2.base_ios.do_lock);
call_func1(p_strstream_vbase_dtor, &ios2);
ios2.base1.extract_delim = ios2.base1.count = 0xabababab;
ios2.base2.unknown = 0xabababab;
memset(&ios2.base_ios, 0xab, sizeof(ios));
ios2.base_ios.delbuf = 0;
pos = ios2.base_ios.tie;
pios = call_func3(p_strstream_copy_ctor, &ios2, &ios1, FALSE);
ok(pios == &ios2, "wrong return, expected %p got %p\n", &ios2, pios);
ok(ios2.base1.extract_delim == 0, "expected 0 got %d\n", ios2.base1.extract_delim);
ok(ios2.base1.count == 0, "expected 0 got %d\n", ios2.base1.count);
ok(ios2.base2.unknown == 0, "expected 0 got %d\n", ios2.base2.unknown);
ok(ios2.base_ios.sb == ios1.base_ios.sb, "expected %p got %p\n", ios1.base_ios.sb, ios2.base_ios.sb);
ok(ios2.base_ios.state == 0xabababab, "expected %d got %d\n", 0xabababab, ios2.base_ios.state);
ok(ios2.base_ios.delbuf == 0, "expected 0 got %d\n", ios2.base_ios.delbuf);
ok(ios2.base_ios.tie == pos, "expected %p got %p\n", pos, ios2.base_ios.tie);
ok(ios2.base_ios.flags == 0xabababab, "expected %x got %x\n", 0xabababab, ios2.base_ios.flags);
ok(ios2.base_ios.precision == 0xabababab, "expected %d got %d\n", 0xabababab, ios2.base_ios.precision);
ok(ios2.base_ios.fill == (char) 0xab, "expected -85 got %d\n", ios2.base_ios.fill);
ok(ios2.base_ios.width == 0xabababab, "expected %d got %d\n", 0xabababab, ios2.base_ios.width);
ok(ios2.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, ios2.base_ios.do_lock);
call_func1(p_strstream_dtor, &ios2.base_ios);
/* assignment */
ios2.base1.extract_delim = ios2.base1.count = 0xabababab;
ios2.base2.unknown = 0xabababab;
memset(&ios2.base_ios, 0xab, sizeof(ios));
ios2.base_ios.delbuf = 0;
pios = call_func2(p_strstream_assign, &ios2, &ios1);
ok(ios2.base1.extract_delim == 0xabababab, "expected %d got %d\n", 0xabababab, ios2.base1.extract_delim);
ok(ios2.base1.count == 0, "expected 0 got %d\n", ios2.base1.count);
ok(ios2.base2.unknown == 0xabababab, "expected %d got %d\n", 0xabababab, ios2.base2.unknown);
ok(ios2.base_ios.sb == ios1.base_ios.sb, "expected %p got %p\n", ios1.base_ios.sb, ios2.base_ios.sb);
ok(ios2.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ios2.base_ios.state);
ok(ios2.base_ios.delbuf == 0, "expected 0 got %d\n", ios2.base_ios.delbuf);
ok(ios2.base_ios.tie == NULL, "expected %p got %p\n", NULL, ios2.base_ios.tie);
ok(ios2.base_ios.flags == 0, "expected 0 got %x\n", ios2.base_ios.flags);
ok(ios2.base_ios.precision == 6, "expected 6 got %d\n", ios2.base_ios.precision);
ok(ios2.base_ios.fill == ' ', "expected 32 got %d\n", ios2.base_ios.fill);
ok(ios2.base_ios.width == 0, "expected 0 got %d\n", ios2.base_ios.width);
ok(ios2.base_ios.do_lock == 0xabababab, "expected %d got %d\n", 0xabababab, ios2.base_ios.do_lock);
}
static void test_Iostream_init(void)
{
ios ios_obj;
@ -6954,6 +7309,7 @@ START_TEST(msvcirt)
test_istream_withassign();
test_istrstream();
test_iostream();
test_strstream();
test_Iostream_init();
test_std_streams();