Commit d6900fc5 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

ntdll/tests: Add 0-length read tests for a disk file.

parent 6e143e6c
......@@ -1985,6 +1985,22 @@ static void test_read_write(void)
bytes = 0xdeadbeef;
SetLastError(0xdeadbeef);
ret = ReadFile(INVALID_HANDLE_VALUE, buf, 0, &bytes, NULL);
todo_wine
ok(!ret, "ReadFile should fail\n");
todo_wine
ok(GetLastError() == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
ok(bytes == 0, "bytes %u\n", bytes);
bytes = 0xdeadbeef;
SetLastError(0xdeadbeef);
ret = ReadFile(hfile, buf, 0, &bytes, NULL);
ok(ret, "ReadFile error %d\n", GetLastError());
ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
ok(bytes == 0, "bytes %u\n", bytes);
bytes = 0xdeadbeef;
SetLastError(0xdeadbeef);
ret = ReadFile(hfile, buf, sizeof(buf), &bytes, NULL);
ok(ret, "ReadFile error %d\n", GetLastError());
ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
......@@ -2184,6 +2200,31 @@ todo_wine
bytes = 0xdeadbeef;
SetLastError(0xdeadbeef);
ret = ReadFile(INVALID_HANDLE_VALUE, buf, 0, &bytes, NULL);
todo_wine
ok(!ret, "ReadFile should fail\n");
todo_wine
ok(GetLastError() == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
ok(bytes == 0, "bytes %u\n", bytes);
S(U(ovl)).Offset = 0;
S(U(ovl)).OffsetHigh = 0;
ovl.Internal = -1;
ovl.InternalHigh = -1;
ovl.hEvent = 0;
bytes = 0xdeadbeef;
SetLastError(0xdeadbeef);
ret = ReadFile(hfile, buf, 0, &bytes, &ovl);
/* ReadFile return value depends on Windows version and testing it is not practical */
if (!ret) ok(GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %d\n", GetLastError());
ok(bytes == 0, "bytes %u\n", bytes);
todo_wine
ok((NTSTATUS)ovl.Internal == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#lx\n", ovl.Internal);
todo_wine
ok(ovl.InternalHigh == 0, "expected 0, got %lu\n", ovl.InternalHigh);
bytes = 0xdeadbeef;
SetLastError(0xdeadbeef);
ret = WriteFile(hfile, contents, sizeof(contents), &bytes, NULL);
ok(!ret, "WriteFile should fail\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
......
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