From 38a21bf119a17758747ee830845e2cca078d27da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Villac=C3=ADs=20Lasso?= Date: Mon, 5 Apr 2010 11:43:24 -0500 Subject: [PATCH] oledb32: Add tests for DBTYPE_I1/DBTYPE_UI1/DBTYPE_UI2/DBTYPE_UI4/DBTYPE_I8/DBTYPE_UI8 to DBTYPE_WSTR/DBTYPE_STR conversion. --- dlls/oledb32/tests/convert.c | 100 +++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/dlls/oledb32/tests/convert.c b/dlls/oledb32/tests/convert.c index 9d2d473f666..69eb08378b7 100644 --- a/dlls/oledb32/tests/convert.c +++ b/dlls/oledb32/tests/convert.c @@ -1183,6 +1183,56 @@ static void test_converttowstr(void) + memset(src, 0, sizeof(src)); + *(signed char *)src = 10; + hr = IDataConvert_DataConvert(convert, DBTYPE_I1, 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 == 4, "got %d\n", dst_len); + ok(!lstrcmpW(dst, ten), "got %s\n", wine_dbgstr_w(dst)); + + memset(src, 0, sizeof(src)); + *(unsigned char *)src = 10; + hr = IDataConvert_DataConvert(convert, DBTYPE_UI1, 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 == 4, "got %d\n", dst_len); + ok(!lstrcmpW(dst, ten), "got %s\n", wine_dbgstr_w(dst)); + + memset(src, 0, sizeof(src)); + *(unsigned short *)src = 4321; + hr = IDataConvert_DataConvert(convert, DBTYPE_UI2, 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)); + + memset(src, 0, sizeof(src)); + *(unsigned int *)src = 4321; + hr = IDataConvert_DataConvert(convert, DBTYPE_UI4, 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)); + + memset(src, 0, sizeof(src)); + ((LARGE_INTEGER*)src)->QuadPart = 4321; + hr = IDataConvert_DataConvert(convert, DBTYPE_I8, 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)); + + memset(src, 0, sizeof(src)); + ((ULARGE_INTEGER*)src)->QuadPart = 4321; + hr = IDataConvert_DataConvert(convert, DBTYPE_UI8, 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)); + + + 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); @@ -1485,6 +1535,56 @@ static void test_converttostr(void) + memset(src, 0, sizeof(src)); + *(signed char *)src = 10; + hr = IDataConvert_DataConvert(convert, DBTYPE_I1, 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 == 2, "got %d\n", dst_len); + ok(!lstrcmpA(dst, ten_a), "got %s\n", dst); + + memset(src, 0, sizeof(src)); + *(unsigned char *)src = 10; + hr = IDataConvert_DataConvert(convert, DBTYPE_UI1, 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 == 2, "got %d\n", dst_len); + ok(!lstrcmpA(dst, ten_a), "got %s\n", dst); + + memset(src, 0, sizeof(src)); + *(unsigned short *)src = 4321; + hr = IDataConvert_DataConvert(convert, DBTYPE_UI2, 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); + + memset(src, 0, sizeof(src)); + *(unsigned int *)src = 4321; + hr = IDataConvert_DataConvert(convert, DBTYPE_UI4, 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); + + memset(src, 0, sizeof(src)); + ((LARGE_INTEGER*)src)->QuadPart = 4321; + hr = IDataConvert_DataConvert(convert, DBTYPE_I8, 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); + + memset(src, 0, sizeof(src)); + ((ULARGE_INTEGER*)src)->QuadPart = 4321; + hr = IDataConvert_DataConvert(convert, DBTYPE_UI8, 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); + + + b = SysAllocString(ten); *(BSTR *)src = b; memset(dst, 0xcc, sizeof(dst));