From 0e92f07f41c280bb62ef8dc658bd23134536697b Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Sat, 14 Nov 2015 00:38:39 +0300 Subject: [PATCH] gdi32/tests: Some empty string tests for GetTextExtentPoint. Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/gdi32/tests/font.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c index 6eefc3bc277..53945da1bbd 100644 --- a/dlls/gdi32/tests/font.c +++ b/dlls/gdi32/tests/font.c @@ -1410,6 +1410,7 @@ static void test_GetCharABCWidths(void) static void test_text_extents(void) { static const WCHAR wt[] = {'O','n','e','\n','t','w','o',' ','3',0}; + static const WCHAR emptyW[] = {0}; LPINT extents; INT i, len, fit1, fit2, extents2[3]; LOGFONTA lf; @@ -1428,9 +1429,20 @@ static void test_text_extents(void) hdc = GetDC(0); hfont = SelectObject(hdc, hfont); GetTextMetricsA(hdc, &tm); - GetTextExtentPointA(hdc, "o", 1, &sz); + ret = GetTextExtentPointA(hdc, "o", 1, &sz); + ok(ret, "got %d\n", ret); ok(sz.cy == tm.tmHeight, "cy %d tmHeight %d\n", sz.cy, tm.tmHeight); + memset(&sz, 0xcc, sizeof(sz)); + ret = GetTextExtentPointA(hdc, "o", 0, &sz); + ok(ret, "got %d\n", ret); + ok(sz.cx == 0 && sz.cy == 0, "cx %d, cy %d\n", sz.cx, sz.cy); + + memset(&sz, 0xcc, sizeof(sz)); + ret = GetTextExtentPointA(hdc, "", 0, &sz); + ok(ret, "got %d\n", ret); + ok(sz.cx == 0 && sz.cy == 0, "cx %d, cy %d\n", sz.cx, sz.cy); + SetLastError(0xdeadbeef); GetTextExtentExPointW(hdc, wt, 1, 1, &fit1, &fit2, &sz1); if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) @@ -1442,6 +1454,16 @@ static void test_text_extents(void) return; } + memset(&sz, 0xcc, sizeof(sz)); + ret = GetTextExtentPointW(hdc, wt, 0, &sz); + ok(ret, "got %d\n", ret); + ok(sz.cx == 0 && sz.cy == 0, "cx %d, cy %d\n", sz.cx, sz.cy); + + memset(&sz, 0xcc, sizeof(sz)); + ret = GetTextExtentPointW(hdc, emptyW, 0, &sz); + ok(ret, "got %d\n", ret); + ok(sz.cx == 0 && sz.cy == 0, "cx %d, cy %d\n", sz.cx, sz.cy); + len = lstrlenW(wt); extents = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len * sizeof extents[0]); extents[0] = 1; /* So that the increasing sequence test will fail