[RPCRT4_WINETEST] Sync with Wine Staging 4.0. CORE-15682
[reactos.git] / modules / rostests / winetests / rpcrt4 / rpc_async.c
1 /*
2 * Unit test suite for rpc functions
3 *
4 * Copyright 2008 Robert Shearman (for CodeWeavers)
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21 #include <stdarg.h>
22
23 #include "wine/test.h"
24
25 #include <rpc.h>
26 #include <rpcasync.h>
27
28 static void test_RpcAsyncInitializeHandle(void)
29 {
30 char buffer[256];
31 RPC_ASYNC_STATE async;
32 RPC_STATUS status;
33 int i;
34 void *unset_ptr;
35
36 status = RpcAsyncInitializeHandle((PRPC_ASYNC_STATE)buffer, sizeof(buffer));
37 ok(status == ERROR_INVALID_PARAMETER, "RpcAsyncInitializeHandle with large Size should have returned ERROR_INVALID_PARAMETER instead of %d\n", status);
38
39 status = RpcAsyncInitializeHandle(&async, sizeof(async) - 1);
40 ok(status == ERROR_INVALID_PARAMETER, "RpcAsyncInitializeHandle with small Size should have returned ERROR_INVALID_PARAMETER instead of %d\n", status);
41
42 memset(&async, 0xcc, sizeof(async));
43 memset(&unset_ptr, 0xcc, sizeof(unset_ptr));
44 status = RpcAsyncInitializeHandle(&async, sizeof(async));
45 ok(status == RPC_S_OK, "RpcAsyncInitializeHandle failed with error %d\n", status);
46
47 ok(async.Size == sizeof(async), "async.Size wrong: %d\n", async.Size);
48 ok(async.Signature == 0x43595341, "async.Signature should be 0x43595341, but is 0x%x instead\n", async.Signature);
49 ok(async.Lock == 0, "async.Lock should be 0, but is %d instead\n", async.Lock);
50 ok(async.Flags == 0, "async.Flags should be 0, but is %d instead\n", async.Flags);
51 ok(async.StubInfo == NULL, "async.StubInfo should be NULL, not %p\n", async.StubInfo);
52 ok(async.UserInfo == unset_ptr, "async.UserInfo should be unset, not %p\n", async.UserInfo);
53 ok(async.RuntimeInfo == NULL, "async.RuntimeInfo should be NULL, not %p\n", async.RuntimeInfo);
54 ok(async.Event == 0xcccccccc, "async.Event should be unset, not %d\n", async.Event);
55 ok(async.NotificationType == 0xcccccccc, "async.NotificationType should be unset, not %d\n", async.NotificationType);
56 for (i = 0; i < 4; i++)
57 ok(async.Reserved[i] == 0x0, "async.Reserved[%d] should be 0x0, not 0x%lx\n", i, async.Reserved[i]);
58 }
59
60 static void test_RpcAsyncGetCallStatus(void)
61 {
62 RPC_ASYNC_STATE async;
63 RPC_STATUS status;
64
65 status = RpcAsyncInitializeHandle(&async, sizeof(async));
66 ok(status == RPC_S_OK, "RpcAsyncInitializeHandle failed with error %d\n", status);
67
68 status = RpcAsyncGetCallStatus(&async);
69 todo_wine
70 ok(status == RPC_S_INVALID_BINDING, "RpcAsyncGetCallStatus should have returned RPC_S_INVALID_BINDING instead of %d\n", status);
71
72 memset(&async, 0, sizeof(async));
73 status = RpcAsyncGetCallStatus(&async);
74 todo_wine
75 ok(status == RPC_S_INVALID_BINDING, "RpcAsyncGetCallStatus should have returned RPC_S_INVALID_BINDING instead of %d\n", status);
76 }
77
78 START_TEST( rpc_async )
79 {
80 test_RpcAsyncInitializeHandle();
81 test_RpcAsyncGetCallStatus();
82 }