oledb32: Add tests for DBTYPE_I4 to DBTYPE_WSTR/DBTYPE_STR conversion.

This commit is contained in:
Alex Villacís Lasso 2010-04-05 11:39:49 -05:00 committed by Alexandre Julliard
parent 5f236f1a5c
commit cad15d3a7c
1 changed files with 115 additions and 0 deletions

View File

@ -1002,6 +1002,64 @@ static void test_converttowstr(void)
ok(dst[3] == 0, "got %02x\n", dst[3]);
ok(dst[4] == 0xcccc, "got %02x\n", dst[4]);
*(int *)src = 4321;
hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_WSTR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
ok(hr == S_OK, "got %08x\n", hr);
ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
ok(dst_len == 8, "got %d\n", dst_len);
ok(!lstrcmpW(dst, fourthreetwoone), "got %s\n", wine_dbgstr_w(dst));
*(int *)src = 4321;
memset(dst, 0xcc, sizeof(dst));
hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_WSTR, 0, &dst_len, src, dst, 0, 0, &dst_status, 0, 0, 0);
ok(hr == DB_E_ERRORSOCCURRED, "got %08x\n", hr);
ok(dst_status == DBSTATUS_E_DATAOVERFLOW, "got %08x\n", dst_status);
ok(dst_len == 8, "got %d\n", dst_len);
ok(dst[0] == 0xcccc, "got %02x\n", dst[0]);
*(int *)src = 4321;
memset(dst, 0xcc, sizeof(dst));
hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_WSTR, 0, &dst_len, src, NULL, 0, 0, &dst_status, 0, 0, 0);
ok(hr == S_OK, "got %08x\n", hr);
ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
ok(dst_len == 8, "got %d\n", dst_len);
ok(dst[0] == 0xcccc, "got %02x\n", dst[0]);
*(int *)src = 4321;
memset(dst, 0xcc, sizeof(dst));
hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_WSTR, 0, &dst_len, src, dst, 4, 0, &dst_status, 0, 0, 0);
ok(hr == S_OK, "got %08x\n", hr);
ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
ok(dst_len == 8, "got %d\n", dst_len);
ok(dst[0] == '4', "got %02x\n", dst[0]);
ok(dst[1] == 0, "got %02x\n", dst[1]);
ok(dst[2] == 0xcccc, "got %02x\n", dst[2]);
*(int *)src = 4321;
memset(dst, 0xcc, sizeof(dst));
hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_WSTR, 0, &dst_len, src, dst, 2, 0, &dst_status, 0, 0, 0);
ok(hr == S_OK, "got %08x\n", hr);
ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
ok(dst_len == 8, "got %d\n", dst_len);
ok(dst[0] == 0, "got %02x\n", dst[0]);
ok(dst[1] == 0xcccc, "got %02x\n", dst[1]);
*(int *)src = 4321;
memset(dst, 0xcc, sizeof(dst));
hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_WSTR, 0, &dst_len, src, dst, 8, 0, &dst_status, 0, 0, 0);
ok(hr == S_OK, "got %08x\n", hr);
ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
ok(dst_len == 8, "got %d\n", dst_len);
ok(dst[0] == '4', "got %02x\n", dst[0]);
ok(dst[1] == '3', "got %02x\n", dst[1]);
ok(dst[2] == '2', "got %02x\n", dst[2]);
ok(dst[3] == 0, "got %02x\n", dst[3]);
ok(dst[4] == 0xcccc, "got %02x\n", dst[4]);
b = SysAllocString(ten);
*(BSTR *)src = b;
hr = IDataConvert_DataConvert(convert, DBTYPE_BSTR, DBTYPE_WSTR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
@ -1126,6 +1184,63 @@ static void test_converttostr(void)
ok(dst[3] == 0, "got %02x\n", dst[3]);
ok(dst[4] == (char)0xcc, "got %02x\n", dst[4]);
*(int *)src = 4321;
hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_STR, 0, &dst_len, src, dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
ok(hr == S_OK, "got %08x\n", hr);
ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
ok(dst_len == 4, "got %d\n", dst_len);
ok(!lstrcmpA(dst, fourthreetwoone), "got %s\n", dst);
*(int *)src = 4321;
memset(dst, 0xcc, sizeof(dst));
hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_STR, 0, &dst_len, src, dst, 0, 0, &dst_status, 0, 0, 0);
ok(hr == DB_E_ERRORSOCCURRED, "got %08x\n", hr);
ok(dst_status == DBSTATUS_E_DATAOVERFLOW, "got %08x\n", dst_status);
ok(dst_len == 4, "got %d\n", dst_len);
ok(dst[0] == (char)0xcc, "got %02x\n", dst[0]);
*(int *)src = 4321;
memset(dst, 0xcc, sizeof(dst));
hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_STR, 0, &dst_len, src, NULL, 0, 0, &dst_status, 0, 0, 0);
ok(hr == S_OK, "got %08x\n", hr);
ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
ok(dst_len == 4, "got %d\n", dst_len);
ok(dst[0] == (char)0xcc, "got %02x\n", dst[0]);
*(int *)src = 4321;
memset(dst, 0xcc, sizeof(dst));
hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_STR, 0, &dst_len, src, dst, 2, 0, &dst_status, 0, 0, 0);
ok(hr == S_OK, "got %08x\n", hr);
ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
ok(dst_len == 4, "got %d\n", dst_len);
ok(dst[0] == '4', "got %02x\n", dst[0]);
ok(dst[1] == 0, "got %02x\n", dst[1]);
ok(dst[2] == (char)0xcc, "got %02x\n", dst[2]);
*(int *)src = 4321;
memset(dst, 0xcc, sizeof(dst));
hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_STR, 0, &dst_len, src, dst, 1, 0, &dst_status, 0, 0, 0);
ok(hr == S_OK, "got %08x\n", hr);
ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
ok(dst_len == 4, "got %d\n", dst_len);
ok(dst[0] == 0, "got %02x\n", dst[0]);
ok(dst[1] == (char)0xcc, "got %02x\n", dst[1]);
*(int *)src = 4321;
memset(dst, 0xcc, sizeof(dst));
hr = IDataConvert_DataConvert(convert, DBTYPE_I4, DBTYPE_STR, 0, &dst_len, src, dst, 4, 0, &dst_status, 0, 0, 0);
ok(hr == S_OK, "got %08x\n", hr);
ok(dst_status == DBSTATUS_S_TRUNCATED, "got %08x\n", dst_status);
ok(dst_len == 4, "got %d\n", dst_len);
ok(dst[0] == '4', "got %02x\n", dst[0]);
ok(dst[1] == '3', "got %02x\n", dst[1]);
ok(dst[2] == '2', "got %02x\n", dst[2]);
ok(dst[3] == 0, "got %02x\n", dst[3]);
ok(dst[4] == (char)0xcc, "got %02x\n", dst[4]);
b = SysAllocString(ten);
*(BSTR *)src = b;
memset(dst, 0xcc, sizeof(dst));