dbghelp: Base and symbols.
[wine] / dlls / dnsapi / tests / record.c
1 /*
2  * Tests for record handling functions
3  *
4  * Copyright 2006 Hans Leidekker
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 <stdarg.h>
22
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winnls.h"
26 #include "windns.h"
27
28 #include "wine/test.h"
29
30 static HMODULE dnsapi;
31
32 static BOOL        (WINAPI *pDnsRecordCompare)(PDNS_RECORD,PDNS_RECORD);
33
34 #define GETFUNCPTR(func) p##func = (void *)GetProcAddress( dnsapi, #func ); \
35     if (!p##func) return FALSE;
36
37 static BOOL init_function_ptrs( void )
38 {
39     GETFUNCPTR( DnsRecordCompare )
40     return TRUE;
41 }
42
43 static void test_DnsRecordCompare( void )
44 {
45     char name1[] = "localhost";
46     char name2[] = "LOCALHOST";
47     static DNS_RECORDA r1, r2;
48            
49     r1.pName = name1;
50     r1.wType = DNS_TYPE_A;
51     r1.wDataLength = sizeof(DNS_A_DATA);
52     r1.Data.A.IpAddress = 0xffffffff;
53
54     r2.pName = name1;
55     r2.wType = DNS_TYPE_A;
56     r2.wDataLength = sizeof(DNS_A_DATA);
57     r2.Data.A.IpAddress = 0xffffffff;
58
59     ok( pDnsRecordCompare( (PDNS_RECORD)&r1, (PDNS_RECORD)&r1 ) == TRUE, "failed unexpectedly\n" );
60
61     r2.pName = name2;
62     ok( pDnsRecordCompare( (PDNS_RECORD)&r1, (PDNS_RECORD)&r2 ) == TRUE, "failed unexpectedly\n" );
63
64     r2.Flags.S.CharSet = DnsCharSetUnicode;
65     ok( pDnsRecordCompare( (PDNS_RECORD)&r1, (PDNS_RECORD)&r2 ) == FALSE, "succeeded unexpectedly\n" );
66
67     r2.Flags.S.CharSet = DnsCharSetAnsi;
68     ok( pDnsRecordCompare( (PDNS_RECORD)&r1, (PDNS_RECORD)&r2 ) == FALSE, "succeeded unexpectedly\n" );
69
70     r1.Flags.S.CharSet = DnsCharSetAnsi;
71     ok( pDnsRecordCompare( (PDNS_RECORD)&r1, (PDNS_RECORD)&r2 ) == TRUE, "failed unexpectedly\n" );
72
73     r2.Data.A.IpAddress = 0;
74     ok( pDnsRecordCompare( (PDNS_RECORD)&r1, (PDNS_RECORD)&r2 ) == FALSE, "succeeded unexpectedly\n" );
75 }
76
77 START_TEST(record)
78 {
79     dnsapi = LoadLibraryA( "dnsapi.dll" );
80     if (!dnsapi) return;
81
82     if (!init_function_ptrs())
83     {
84         FreeLibrary( dnsapi );
85         return;
86     }
87
88     test_DnsRecordCompare();
89
90     FreeLibrary( dnsapi );
91 }