Store the function pointer in the %prototypes hash instead of the
[wine/multimedia.git] / programs / winetest / test.pl
blob2b67384d74f795f2ca237ba13bc2b4f8685186fc
2 # Test script for the winetest program
5 use wine;
7 $wine::debug = 0;
9 ################################################################
10 # Declarations for functions we use in this script
12 wine::declare( "kernel32",
13 SetLastError => "void",
14 GetLastError => "int",
15 GlobalAddAtomA => "word",
16 GlobalGetAtomNameA => "int",
17 GetCurrentThread => "int",
18 GetExitCodeThread => "int",
19 GetModuleHandleA => "int",
20 GetProcAddress => "int",
21 lstrcatA => "ptr"
24 ################################################################
25 # Test some simple function calls
27 # Test string arguments
28 $atom = GlobalAddAtomA("foo");
29 assert( $atom >= 0xc000 && $atom <= 0xffff );
30 assert( !defined($wine::err) );
32 # Test integer and string reference arguments
33 $buffer = "xxxxxx";
34 $ret = GlobalGetAtomNameA( $atom, \$buffer, length(buffer) );
35 assert( !defined($wine::err) );
36 assert( $ret == 3 );
37 assert( lc $buffer eq "foo\000xx" );
39 # Test integer reference
40 $code = 0;
41 $ret = GetExitCodeThread( GetCurrentThread(), \$code );
42 assert( !defined($wine::err) );
43 assert( $ret );
44 assert( $code == 0x103 );
46 # Test string return value
47 $str = lstrcatA( "foo\0foo", "bar" );
48 assert( !defined($wine::err) );
49 assert( $str eq "foobar" );
51 ################################################################
52 # Test last error handling
54 SetLastError( 123 );
55 $ret = GetLastError();
56 assert( $ret == 123 );
58 ################################################################
59 # Test various error cases
61 eval { SetLastError(1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7); };
62 assert( $@ =~ /Too many arguments at/ );
64 my $funcptr = GetProcAddress( GetModuleHandleA("kernel32"), "SetLastError" );
65 assert( $funcptr );
66 eval { wine::call_wine_API( $funcptr, 10, $wine::debug, 0); };
67 assert( $@ =~ /Bad return type 10 at/ );
69 eval { foobar(1,2,3); };
70 assert( $@ =~ /Function 'foobar' not declared at/ );
72 print "OK\n";