Added LGPL standard comment, and copyright notices where necessary.
[wine/multimedia.git] / programs / winetest / tests / wine.pl
blob17e5d9fecf304a584e8ee874c8363733f7c7ee9a
1 ################################################################
2 # Tests for wine.pm module functions
4 # Copyright 2001 Alexandre Julliard
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 use wine;
23 use kernel32;
25 ################################################################
26 # Test some simple function calls
28 # Test string arguments
29 $atom = GlobalAddAtomA("foo");
30 ok( $atom >= 0xc000 && $atom <= 0xffff );
31 ok( !defined($wine::err) );
33 # Test integer and string reference arguments
34 $buffer = "xxxxxx";
35 $ret = GlobalGetAtomNameA( $atom, \$buffer, length(buffer) );
36 ok( !defined($wine::err) );
37 ok( $ret == 3 );
38 ok( lc $buffer eq "foo\000xx" );
40 # Test integer reference
41 $code = 0;
42 $ret = GetExitCodeThread( GetCurrentThread(), \$code );
43 ok( !defined($wine::err) );
44 ok( $ret );
45 ok( $code == 0x103 );
47 # Test string return value
48 $str = lstrcatA( "foo\0foo", "bar" );
49 ok( !defined($wine::err) );
50 ok( $str eq "foobar" );
52 ################################################################
53 # Test last error handling
55 SetLastError( 123 );
56 $ret = GetLastError();
57 ok( $ret == 123 );
59 ################################################################
60 # Test various error cases
62 eval { SetLastError(1,2); };
63 ok( $@ =~ /Wrong number of arguments, expected 1, got 2/ );
65 wine::declare("kernel32", "SetLastError" => "int" ); # disable prototype
66 eval { SetLastError(1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7); };
67 ok( $@ =~ /Too many arguments/ );
69 wine::declare("kernel32", "non_existent_func" => ["int",["int"]]);
70 eval { non_existent_func(1); };
71 ok( $@ =~ /Could not get address for kernel32\.non_existent_func/ );
73 my $funcptr = GetProcAddress( GetModuleHandleA("kernel32"), "SetLastError" );
74 ok( $funcptr );
75 eval { wine::call_wine_API( $funcptr, 10, $wine::debug-1, 0); };
76 ok( $@ =~ /Bad return type 10 at/ );
78 eval { foobar(1,2,3); };
79 ok( $@ =~ /Function 'foobar' not declared at/ );
81 ################################################################
82 # Test assert
84 assert( 1, "cannot fail" );
86 eval { assert( 0, "this must fail" ); };
87 ok( $@ =~ /Assertion failed/ );
88 ok( $@ =~ /this must fail/ );
90 ################################################################
91 # Test todo blocks
93 todo_wine
95 ok( $wine::platform ne "wine", "Must fail only on Wine" );
98 todo( $wine::platform,
99 sub { ok( 0, "Failure must be ignored inside todo" ); } );
100 todo( $wine::platform . "xxx",
101 sub { ok( 1, "Success must not cause error inside todo for other platform" ); } );