Rob Shearman : rpcrt4: Add tests for RpcStringBindingParseA.

Alexandre Julliard julliard at winehq.org
Thu Feb 28 06:21:43 CST 2008


Module: wine
Branch: master
Commit: f7628b69b07c0b11312985613325709beb87ed04
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=f7628b69b07c0b11312985613325709beb87ed04

Author: Rob Shearman <rob at codeweavers.com>
Date:   Wed Feb 27 19:03:04 2008 +0000

rpcrt4: Add tests for RpcStringBindingParseA.

---

 dlls/rpcrt4/tests/rpc.c |   78 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 78 insertions(+), 0 deletions(-)

diff --git a/dlls/rpcrt4/tests/rpc.c b/dlls/rpcrt4/tests/rpc.c
index 57973e5..ace8aff 100644
--- a/dlls/rpcrt4/tests/rpc.c
+++ b/dlls/rpcrt4/tests/rpc.c
@@ -533,6 +533,83 @@ static void test_I_RpcMapWin32Status(void)
     }
 }
 
+static void test_RpcStringBindingParseA(void)
+{
+    static unsigned char valid_binding[] = "00000000-0000-0000-c000-000000000046 at ncacn_np:.[endpoint=\\pipe\\test]";
+    static unsigned char valid_binding2[] = "00000000-0000-0000-c000-000000000046 at ncacn_np:.[\\pipe\\test]";
+    static unsigned char invalid_uuid_binding[] = "{00000000-0000-0000-c000-000000000046}@ncacn_np:.[endpoint=\\pipe\\test]";
+    static unsigned char invalid_ep_binding[] = "00000000-0000-0000-c000-000000000046 at ncacn_np:.[endpoint=test]";
+    static unsigned char invalid_binding[] = "00000000-0000-0000-c000-000000000046 at ncacn_np";
+    RPC_STATUS status;
+    unsigned char *uuid;
+    unsigned char *protseq;
+    unsigned char *network_addr;
+    unsigned char *endpoint;
+    unsigned char *options;
+
+    /* test all parameters */
+    status = RpcStringBindingParseA(valid_binding, &uuid, &protseq, &network_addr, &endpoint, &options);
+    ok(status == RPC_S_OK, "RpcStringBindingParseA failed with error %ld\n", status);
+    ok(!strcmp((char *)uuid, "00000000-0000-0000-c000-000000000046"), "uuid should have been 00000000-0000-0000-C000-000000000046 instead of %s\n", uuid);
+    ok(!strcmp((char *)protseq, "ncacn_np"), "protseq should have been ncacn_np instead of %s\n", protseq);
+    ok(!strcmp((char *)network_addr, "."), "network_addr should have been . instead of %s\n", network_addr);
+    todo_wine
+    ok(!strcmp((char *)endpoint, "pipetest"), "endpoint should have been pipetest instead of %s\n", endpoint);
+    todo_wine
+    ok(options && !strcmp((char *)options, ""), "options should have been \"\" of \"%s\"\n", options);
+    RpcStringFreeA(&uuid);
+    RpcStringFreeA(&protseq);
+    RpcStringFreeA(&network_addr);
+    RpcStringFreeA(&endpoint);
+    RpcStringFreeA(&options);
+
+    /* test all parameters with different type of string binding */
+    status = RpcStringBindingParseA(valid_binding2, &uuid, &protseq, &network_addr, &endpoint, &options);
+    ok(status == RPC_S_OK, "RpcStringBindingParseA failed with error %ld\n", status);
+    ok(!strcmp((char *)uuid, "00000000-0000-0000-c000-000000000046"), "uuid should have been 00000000-0000-0000-C000-000000000046 instead of %s\n", uuid);
+    ok(!strcmp((char *)protseq, "ncacn_np"), "protseq should have been ncacn_np instead of %s\n", protseq);
+    ok(!strcmp((char *)network_addr, "."), "network_addr should have been . instead of %s\n", network_addr);
+    todo_wine
+    ok(!strcmp((char *)endpoint, "pipetest"), "endpoint should have been pipetest instead of %s\n", endpoint);
+    todo_wine
+    ok(options && !strcmp((char *)options, ""), "options should have been \"\" of \"%s\"\n", options);
+    RpcStringFreeA(&uuid);
+    RpcStringFreeA(&protseq);
+    RpcStringFreeA(&network_addr);
+    RpcStringFreeA(&endpoint);
+    RpcStringFreeA(&options);
+
+    /* test with as many parameters NULL as possible */
+    status = RpcStringBindingParseA(valid_binding, NULL, &protseq, NULL, NULL, NULL);
+    ok(status == RPC_S_OK, "RpcStringBindingParseA failed with error %ld\n", status);
+    ok(!strcmp((char *)protseq, "ncacn_np"), "protseq should have been ncacn_np instead of %s\n", protseq);
+    RpcStringFreeA(&protseq);
+
+    /* test with invalid uuid */
+    status = RpcStringBindingParseA(invalid_uuid_binding, NULL, &protseq, NULL, NULL, NULL);
+    todo_wine
+    ok(status == RPC_S_INVALID_STRING_UUID, "RpcStringBindingParseA should have returned RPC_S_INVALID_STRING_UUID instead of %ld\n", status);
+    todo_wine
+    ok(protseq == NULL, "protseq was %p instead of NULL\n", protseq);
+
+    /* test with invalid endpoint */
+    status = RpcStringBindingParseA(invalid_ep_binding, NULL, &protseq, NULL, NULL, NULL);
+    ok(status == RPC_S_OK, "RpcStringBindingParseA failed with error %ld\n", status);
+    RpcStringFreeA(&protseq);
+
+    /* test with invalid binding */
+    status = RpcStringBindingParseA(invalid_binding, &uuid, &protseq, &network_addr, &endpoint, &options);
+    todo_wine
+    ok(status == RPC_S_INVALID_STRING_BINDING, "RpcStringBindingParseA should have returned RPC_S_INVALID_STRING_BINDING instead of %ld\n", status);
+    todo_wine
+    ok(uuid == NULL, "uuid was %p instead of NULL\n", uuid);
+    ok(protseq == NULL, "protseq was %p instead of NULL\n", protseq);
+    todo_wine
+    ok(network_addr == NULL, "network_addr was %p instead of NULL\n", network_addr);
+    ok(endpoint == NULL, "endpoint was %p instead of NULL\n", endpoint);
+    ok(options == NULL, "options was %p instead of NULL\n", options);
+}
+
 START_TEST( rpc )
 {
     trace ( " ** Uuid Conversion and Comparison Tests **\n" );
@@ -542,4 +619,5 @@ START_TEST( rpc )
     test_rpc_ncacn_ip_tcp();
     test_towers();
     test_I_RpcMapWin32Status();
+    test_RpcStringBindingParseA();
 }




More information about the wine-cvs mailing list