dnsapi: Implement DnsValidateName_{A,UTF8,W}.
[wine] / dlls / dnsapi / tests / name.c
1 /*
2  * Tests for name 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 *pDnsNameCompare_A)(LPSTR,LPSTR);
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( DnsNameCompare_A )
40     return TRUE;
41 }
42
43 static void test_DnsNameCompare_A( void )
44 {
45     ok( pDnsNameCompare_A( NULL, NULL ) == TRUE, "failed unexpectedly\n" );
46
47     ok( pDnsNameCompare_A( "", "" ) == TRUE, "failed unexpectedly\n" );
48     ok( pDnsNameCompare_A( ".", "" ) == TRUE, "failed unexpectedly\n" );
49     ok( pDnsNameCompare_A( "", "." ) == TRUE, "failed unexpectedly\n" );
50     ok( pDnsNameCompare_A( ".", ".." ) == TRUE, "failed unexpectedly\n" );
51     ok( pDnsNameCompare_A( "..", "." ) == TRUE, "failed unexpectedly\n" );
52     ok( pDnsNameCompare_A( "a", "a" ) == TRUE, "failed unexpectedly\n" );
53     ok( pDnsNameCompare_A( "a", "A" ) == TRUE, "failed unexpectedly\n" );
54     ok( pDnsNameCompare_A( "A", "a" ) == TRUE, "failed unexpectedly\n" );
55     ok( pDnsNameCompare_A( "a.b", "A.B" ) == TRUE, "failed unexpectedly\n" );
56     ok( pDnsNameCompare_A( "a.b", "a.b" ) == TRUE, "failed unexpectedly\n" );
57     ok( pDnsNameCompare_A( "a.b.", "a.b." ) == TRUE, "failed unexpectedly\n" );
58     ok( pDnsNameCompare_A( "a.b..", "a.b.." ) == TRUE, "failed unexpectedly\n" );
59
60     ok( pDnsNameCompare_A( "", NULL ) == FALSE, "succeeded unexpectedly\n" );
61     ok( pDnsNameCompare_A( NULL, "" ) == FALSE, "succeeded unexpectedly\n" );
62
63     ok( pDnsNameCompare_A( "a", "b" ) == FALSE, "succeeded unexpectedly\n" );
64     ok( pDnsNameCompare_A( "a", "B" ) == FALSE, "succeeded unexpectedly\n" );
65     ok( pDnsNameCompare_A( "A", "b" ) == FALSE, "succeeded unexpectedly\n" );
66     ok( pDnsNameCompare_A( "a.b", "B.A" ) == FALSE, "succeeded unexpectedly\n" );
67     ok( pDnsNameCompare_A( "a.b.", "b.a." ) == FALSE, "succeeded unexpectedly\n" );
68     ok( pDnsNameCompare_A( "a.b", "a.a" ) == FALSE, "succeeded unexpectedly\n" );
69     ok( pDnsNameCompare_A( "a.b..", "b.a.." ) == FALSE, "succeeded unexpectedly\n" );
70     ok( pDnsNameCompare_A( "a.b.", "b.a.." ) == FALSE, "succeeded unexpectedly\n" );
71     ok( pDnsNameCompare_A( "a.b..", "b.a." ) == FALSE, "succeeded unexpectedly\n" );
72     ok( pDnsNameCompare_A( "a.b.", "b.a" ) == FALSE, "succeeded unexpectedly\n" );
73     ok( pDnsNameCompare_A( "a.b", "b.a." ) == FALSE, "succeeded unexpectedly\n" );
74 }
75
76 START_TEST(name)
77 {
78     dnsapi = LoadLibraryA( "dnsapi.dll" );
79     if (!dnsapi) return;
80
81     if (!init_function_ptrs())
82     {
83         FreeLibrary( dnsapi );
84         return;
85     }
86
87     test_DnsNameCompare_A();
88
89     FreeLibrary( dnsapi );
90 }