crypt32: CryptProtectData/CryptUnprotectData take 2

Mike McCormack mike at codeweavers.com
Tue Apr 5 20:29:37 CDT 2005


Kees Cook wrote:

> Sure, I can write something.  I'll look around for docs on how to run 
> tests -- I didn't find that when I looked around this morning.

The best way to write a test is to look at some of the test cases that 
are there already.  Write and run the test under Windows, and make sure 
it passes on Windows first.  The test is something like this:

/* filename is dlls/crypt32/tests/protect.c */
#include "wine/test.h"

START_TEST(protect)
{
     /* basic form of the test */
     ok(TRUE, "This should be true\n");

     /* try with incorrect parameters */
     ok(!CryptProtectData(NULL,NULL,NULL,NULL,NULL,0,NULL), "crypt 
protect data should fail\n");
     ok(GetLastError() == ERROR_INVALID_PARAMETER, "error returned 
incorrect\n");
     ...

     /* try with correct parameters */
     ...

     /* for tests that pass on windows, but not on Wine */
     wine_todo {
         ok( failing_test(), "this test should pass\n");
     }
}

> Also: I realize I should provide full documentation for the actual 
> Windows API calls themselves.  I documented everything BUT those.  :)  
> What's the convention for the number after the API name?  I've seen some 
> with numbers, and some with just an "@" sign?

Describing the function is good, but IMO, test cases are a more accurate 
description :)  You're probably safe using [crypt32.@], as crypt32 
probably doesn't export functions via ordinal (number).  You can check 
the crypt32.spec file to see.

Mike



More information about the wine-devel mailing list