From d564deba259dc62509dd9f11b6a1f92524aff4e9 Mon Sep 17 00:00:00 2001
From: Juan Lang <juan.lang@gmail.com>
Date: Wed, 3 Mar 2010 11:42:28 -0800
Subject: [PATCH] Add tests for UuidCreateSequential

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

diff --git a/dlls/rpcrt4/tests/rpc.c b/dlls/rpcrt4/tests/rpc.c
index 3acb46e..cb38aec 100644
--- a/dlls/rpcrt4/tests/rpc.c
+++ b/dlls/rpcrt4/tests/rpc.c
@@ -804,6 +804,60 @@ static void test_UuidCreate(void)
     }
 }
 
+static void test_UuidCreateSequential(void)
+{
+    UUID guid1;
+    BYTE version;
+    RPC_STATUS (WINAPI *pUuidCreateSequential)(UUID *) = (void *)GetProcAddress(GetModuleHandle("rpcrt4.dll"), "UuidCreateSequential");
+    RPC_STATUS ret;
+
+    if (!pUuidCreateSequential)
+    {
+        skip("UuidCreateSequential not exported\n");
+        return;
+    }
+    ret = pUuidCreateSequential(&guid1);
+    ok(!ret || ret == RPC_S_UUID_LOCAL_ONLY,
+       "expected RPC_S_OK or RPC_S_UUID_LOCAL_ONLY, got %08x\n", ret);
+    version = (guid1.Data3 & 0xf000) >> 12;
+    todo_wine
+    ok(version == 1, "unexpected version %d\n", version);
+    if (version == 1)
+    {
+        UUID guid2;
+
+        ok((guid1.Data4[0] & 0xc0) == 0x80,
+           "unexpected value in Data4[0]: %02x\n", guid1.Data4[0] & 0xc0);
+        if (!ret)
+        {
+            /* If the call succeeded, there's a valid (non-multicast) MAC
+             * address in the uuid:
+             */
+            ok(!(guid1.Data4[2] & 0x01),
+               "GUID does not appear to contain a MAC address\n");
+        }
+        else
+        {
+            /* Otherwise, there's a randomly generated multicast MAC address
+             * address in the uuid:
+             */
+            ok((guid1.Data4[2] & 0x01),
+               "GUID does not appear to contain a multicast MAC address\n");
+        }
+        /* Generate another GUID, and make sure its MAC address matches the
+         * first.
+         */
+        ret = pUuidCreateSequential(&guid2);
+        ok(!ret || ret == RPC_S_UUID_LOCAL_ONLY,
+           "expected RPC_S_OK or RPC_S_UUID_LOCAL_ONLY, got %08x\n", ret);
+        version = (guid2.Data3 & 0xf000) >> 12;
+        todo_wine
+        ok(version == 1, "unexpected version %d\n", version);
+        ok(!memcmp(guid1.Data4, guid2.Data4, sizeof(guid2.Data4)),
+           "unexpected value in MAC address\n");
+    }
+}
+
 static void test_RpcBindingFree(void)
 {
     RPC_BINDING_HANDLE binding = NULL;
@@ -826,5 +880,6 @@ START_TEST( rpc )
     test_I_RpcExceptionFilter();
     test_RpcStringBindingFromBinding();
     test_UuidCreate();
+    test_UuidCreateSequential();
     test_RpcBindingFree();
 }
-- 
1.6.0.6

