Fix signed/unsigned comparison warnings.
[wine] / dlls / kernel / tests / timer.c
1 /*
2  * Unit test suite for time functions
3  *
4  * Copyright 2004 Mike McCormack
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include "wine/test.h"
22 #include "winbase.h"
23
24 typedef HANDLE (WINAPI *fnCreateWaitableTimerA)( SECURITY_ATTRIBUTES*, BOOL, LPSTR );
25 typedef BOOL (WINAPI *fnSetWaitableTimer)(HANDLE, LARGE_INTEGER*, LONG, PTIMERAPCROUTINE, LPVOID, BOOL);
26
27
28 void test_timer(void)
29 {
30     HMODULE hker = GetModuleHandle("kernel32");
31     fnCreateWaitableTimerA pCreateWaitableTimerA;
32     fnSetWaitableTimer pSetWaitableTimer;
33     HANDLE handle;
34     BOOL r;
35     LARGE_INTEGER due;
36
37     pCreateWaitableTimerA = (fnCreateWaitableTimerA) GetProcAddress( hker, "CreateWaitableTimerA");
38     if( !pCreateWaitableTimerA )
39         return;
40
41     pSetWaitableTimer = (fnSetWaitableTimer) GetProcAddress( hker, "SetWaitableTimer");
42     if( !pSetWaitableTimer )
43         return;
44        
45     /* try once with a positive number */
46     handle = pCreateWaitableTimerA( NULL, 0, NULL );
47     ok( handle != NULL, "failed to create waitable timer with no name\n" );
48
49     due.QuadPart = 10000;
50     r = pSetWaitableTimer( handle, &due, 0x1f4, NULL, NULL, FALSE ); 
51     ok( r, "failed to set timer\n");
52
53     CloseHandle( handle );
54
55     /* try once with a negative number */
56     handle = pCreateWaitableTimerA( NULL, 0, NULL );
57     ok( handle != NULL, "failed to create waitable timer with no name\n" );
58
59     due.QuadPart = -10000;
60     r = pSetWaitableTimer( handle, &due, 0x1f4, NULL, NULL, FALSE ); 
61     ok( r, "failed to set timer\n");
62
63     CloseHandle( handle );
64 }
65
66 START_TEST(timer)
67 {
68     test_timer();
69 }