Split routines that don't rely on C functions into winetest.pm so that
[wine/multimedia.git] / programs / winetest / tests / wine.pl
blob53ad23058b1bc89733633bcd4bf834c02bbf9d99
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;
22 use winetest;
24 use kernel32;
26 ################################################################
27 # Test some simple function calls
29 # Test string arguments
30 $atom = GlobalAddAtomA("foo");
31 ok( $atom >= 0xc000 && $atom <= 0xffff );
32 ok( !defined($wine::err) );
34 # Test integer and string reference arguments
35 $buffer = "xxxxxx";
36 $ret = GlobalGetAtomNameA( $atom, \$buffer, length(buffer) );
37 ok( !defined($wine::err) );
38 ok( $ret == 3 );
39 ok( lc $buffer eq "foo\000xx" );
41 # Test integer reference
42 $code = 0;
43 $ret = GetExitCodeThread( GetCurrentThread(), \$code );
44 ok( !defined($wine::err) );
45 ok( $ret );
46 ok( $code == 0x103 );
48 # Test string return value
49 $str = lstrcatA( "foo\0foo", "bar" );
50 ok( !defined($wine::err) );
51 ok( $str eq "foobar" );
53 ################################################################
54 # Test last error handling
56 SetLastError( 123 );
57 $ret = GetLastError();
58 ok( $ret == 123 );
60 ################################################################
61 # Test various error cases
63 eval { SetLastError(1,2); };
64 ok( $@ =~ /Wrong number of arguments, expected 1, got 2/ );
66 wine::declare("kernel32", "SetLastError" => "int" ); # disable prototype
67 eval { SetLastError(1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7); };
68 ok( $@ =~ /Too many arguments/ );
70 wine::declare("kernel32", "non_existent_func" => ["int",["int"]]);
71 eval { non_existent_func(1); };
72 ok( $@ =~ /Could not get address for kernel32\.non_existent_func/ );
74 my $funcptr = GetProcAddress( GetModuleHandleA("kernel32"), "SetLastError" );
75 ok( $funcptr );
76 eval { wine::call_wine_API( $funcptr, 10, $wine::debug-1, 0); };
77 ok( $@ =~ /Bad return type 10 at/ );
79 eval { foobar(1,2,3); };
80 ok( $@ =~ /Function 'foobar' not declared at/ );
82 ################################################################
83 # Test assert
85 assert( 1, "cannot fail" );
87 eval { assert( 0, "this must fail" ); };
88 ok( $@ =~ /Assertion failed/ );
89 ok( $@ =~ /this must fail/ );
91 ################################################################
92 # Test todo blocks
94 todo_wine
96 ok( $wine::platform ne "wine", "Must fail only on Wine" );
99 todo( $wine::platform,
100 sub { ok( 0, "Failure must be ignored inside todo" ); } );
101 todo( $wine::platform . "xxx",
102 sub { ok( 1, "Success must not cause error inside todo for other platform" ); } );