Commit 57f3a88c authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcp90/tests: Added basic_string<{char,wchar_t}>.size tests.

parent ec8cdcc2
......@@ -59,6 +59,7 @@ static basic_string_char* (WINAPI *p_basic_string_char_erase)(size_t, size_t);
static basic_string_char* (WINAPI *p_basic_string_char_assign_cstr_len)(const char*, size_t);
static const char* (WINAPI *p_basic_string_char_cstr)(void);
static const char* (WINAPI *p_basic_string_char_data)(void);
static size_t (WINAPI *p_basic_string_char_size)(void);
static basic_string_wchar* (WINAPI *p_basic_string_wchar_ctor)(void);
static basic_string_wchar* (WINAPI *p_basic_string_wchar_copy_ctor)(basic_string_wchar*);
......@@ -68,6 +69,7 @@ static basic_string_wchar* (WINAPI *p_basic_string_wchar_erase)(size_t, size_t);
static basic_string_wchar* (WINAPI *p_basic_string_wchar_assign_cstr_len)(const wchar_t*, size_t);
static const wchar_t* (WINAPI *p_basic_string_wchar_cstr)(void);
static const wchar_t* (WINAPI *p_basic_string_wchar_data)(void);
static size_t (WINAPI *p_basic_string_wchar_size)(void);
#else
static basic_string_char* (__cdecl *p_basic_string_char_ctor)(basic_string_char*);
static basic_string_char* (__cdecl *p_basic_string_char_copy_ctor)(basic_string_char*, basic_string_char*);
......@@ -77,6 +79,7 @@ static basic_string_char* (__cdecl *p_basic_string_char_erase)(basic_string_char
static basic_string_char* (__cdecl *p_basic_string_char_assign_cstr_len)(basic_string_char*, const char*, size_t);
static const char* (__cdecl *p_basic_string_char_cstr)(basic_string_char*);
static const char* (__cdecl *p_basic_string_char_data)(basic_string_char*);
static size_t (__cdecl *p_basic_string_char_size)(basic_string_char*);
static basic_string_wchar* (__cdecl *p_basic_string_wchar_ctor)(basic_string_wchar*);
static basic_string_wchar* (__cdecl *p_basic_string_wchar_copy_ctor)(basic_string_wchar*, basic_string_wchar*);
......@@ -86,6 +89,7 @@ static basic_string_wchar* (__cdecl *p_basic_string_wchar_erase)(basic_string_wc
static basic_string_wchar* (__cdecl *p_basic_string_wchar_assign_cstr_len)(basic_string_wchar*, const wchar_t*, size_t);
static const wchar_t* (__cdecl *p_basic_string_wchar_cstr)(basic_string_wchar*);
static const wchar_t* (__cdecl *p_basic_string_wchar_data)(basic_string_wchar*);
static size_t (__cdecl *p_basic_string_wchar_size)(basic_string_wchar*);
#endif
static int invalid_parameter = 0;
......@@ -234,6 +238,8 @@ static BOOL init(void)
"?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEBAPEBDXZ");
p_basic_string_char_data = (void*)GetProcAddress(msvcp,
"?data@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEBAPEBDXZ");
p_basic_string_char_size = (void*)GetProcAddress(msvcp,
"?size@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEBA_KXZ");
p_basic_string_wchar_ctor = (void*)GetProcAddress(msvcp,
"??0?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@XZ");
......@@ -251,6 +257,8 @@ static BOOL init(void)
"?c_str@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEBAPEB_WXZ");
p_basic_string_wchar_data = (void*)GetProcAddress(msvcp,
"?data@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEBAPEB_WXZ");
p_basic_string_wchar_size = (void*)GetProcAddress(msvcp,
"?size@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEBA_KXZ");
} else {
p_basic_string_char_ctor = (void*)GetProcAddress(msvcp,
......@@ -269,6 +277,8 @@ static BOOL init(void)
"?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ");
p_basic_string_char_data = (void*)GetProcAddress(msvcp,
"?data@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ");
p_basic_string_char_size = (void*)GetProcAddress(msvcp,
"?size@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIXZ");
p_basic_string_wchar_ctor = (void*)GetProcAddress(msvcp,
"??0?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@XZ");
......@@ -286,6 +296,8 @@ static BOOL init(void)
"?c_str@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QBEPB_WXZ");
p_basic_string_wchar_data = (void*)GetProcAddress(msvcp,
"?data@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QBEPB_WXZ");
p_basic_string_wchar_size = (void*)GetProcAddress(msvcp,
"?size@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QBEIXZ");
}
return TRUE;
......@@ -294,11 +306,13 @@ static BOOL init(void)
static void test_basic_string_char(void) {
basic_string_char str1, str2, *pstr;
const char *str;
size_t size;
if(!p_basic_string_char_ctor || !p_basic_string_char_copy_ctor
|| !p_basic_string_char_ctor_cstr || !p_basic_string_char_dtor
|| !p_basic_string_char_erase || !p_basic_string_char_assign_cstr_len
|| !p_basic_string_char_cstr || !p_basic_string_char_data) {
|| !p_basic_string_char_cstr || !p_basic_string_char_data
|| !p_basic_string_char_size) {
win_skip("basic_string<char> unavailable\n");
return;
}
......@@ -319,6 +333,8 @@ static void test_basic_string_char(void) {
ok(!memcmp(str, "test", 5), "str = %s\n", str);
str = call_func1(p_basic_string_char_data, &str1);
ok(!memcmp(str, "test", 5), "str = %s\n", str);
size = (size_t)call_func1(p_basic_string_char_size, &str1);
ok(size == 4, "size = %lu\n", (unsigned long)size);
pstr = call_func2(p_basic_string_char_copy_ctor, &str2, &str1);
ok(pstr == &str2, "pstr != &str2\n");
......@@ -332,12 +348,16 @@ static void test_basic_string_char(void) {
ok(!memcmp(str, "tt", 3), "str = %s\n", str);
str = call_func1(p_basic_string_char_data, &str2);
ok(!memcmp(str, "tt", 3), "str = %s\n", str);
size = (size_t)call_func1(p_basic_string_char_size, &str1);
ok(size == 4, "size = %lu\n", (unsigned long)size);
call_func3(p_basic_string_char_erase, &str2, 1, 100);
str = call_func1(p_basic_string_char_cstr, &str2);
ok(!memcmp(str, "t", 2), "str = %s\n", str);
str = call_func1(p_basic_string_char_data, &str2);
ok(!memcmp(str, "t", 2), "str = %s\n", str);
size = (size_t)call_func1(p_basic_string_char_size, &str1);
ok(size == 4, "size = %lu\n", (unsigned long)size);
call_func3(p_basic_string_char_assign_cstr_len, &str2, "test", 4);
str = call_func1(p_basic_string_char_cstr, &str2);
......@@ -360,11 +380,13 @@ static void test_basic_string_wchar(void) {
basic_string_wchar str1, str2, *pstr;
const wchar_t *str;
size_t size;
if(!p_basic_string_wchar_ctor || !p_basic_string_wchar_copy_ctor
|| !p_basic_string_wchar_ctor_cstr || !p_basic_string_wchar_dtor
|| !p_basic_string_wchar_erase || !p_basic_string_wchar_assign_cstr_len
|| !p_basic_string_wchar_cstr || !p_basic_string_wchar_data) {
|| !p_basic_string_wchar_cstr || !p_basic_string_wchar_data
|| !p_basic_string_wchar_size) {
win_skip("basic_string<wchar_t> unavailable\n");
return;
}
......@@ -385,6 +407,8 @@ static void test_basic_string_wchar(void) {
ok(!memcmp(str, test, 5*sizeof(wchar_t)), "str = %s\n", wine_dbgstr_w(str));
str = call_func1(p_basic_string_wchar_data, &str1);
ok(!memcmp(str, test, 5*sizeof(wchar_t)), "str = %s\n", wine_dbgstr_w(str));
size = (size_t)call_func1(p_basic_string_char_size, &str1);
ok(size == 4, "size = %lu\n", (unsigned long)size);
memset(&str2, 0, sizeof(basic_string_wchar));
pstr = call_func2(p_basic_string_wchar_copy_ctor, &str2, &str1);
......@@ -399,12 +423,16 @@ static void test_basic_string_wchar(void) {
ok(str[0]=='t' && str[1]=='t' && str[2]=='\0', "str = %s\n", wine_dbgstr_w(str));
str = call_func1(p_basic_string_wchar_data, &str2);
ok(str[0]=='t' && str[1]=='t' && str[2]=='\0', "str = %s\n", wine_dbgstr_w(str));
size = (size_t)call_func1(p_basic_string_char_size, &str1);
ok(size == 4, "size = %lu\n", (unsigned long)size);
call_func3(p_basic_string_wchar_erase, &str2, 1, 100);
str = call_func1(p_basic_string_wchar_cstr, &str2);
ok(str[0]=='t' && str[1]=='\0', "str = %s\n", wine_dbgstr_w(str));
str = call_func1(p_basic_string_wchar_data, &str2);
ok(str[0]=='t' && str[1]=='\0', "str = %s\n", wine_dbgstr_w(str));
size = (size_t)call_func1(p_basic_string_char_size, &str1);
ok(size == 4, "size = %lu\n", (unsigned long)size);
call_func3(p_basic_string_wchar_assign_cstr_len, &str2, test, 4);
str = call_func1(p_basic_string_wchar_cstr, &str2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment