ddraw: Register / unregister the ddraw window class from DllMain().
[wine/testsucceed.git] / dlls / dnsapi / tests / name.c
blobd472687b9d38a5d698b777b02ec996b8db6f4c50
1 /*
2 * Tests for name handling functions
4 * Copyright 2006 Hans Leidekker
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winnls.h"
26 #include "windns.h"
28 #include "wine/test.h"
30 static const struct
32 LPCSTR name;
33 DNS_NAME_FORMAT format;
34 DNS_STATUS status;
36 test_data[] =
38 { "", DnsNameDomain, ERROR_INVALID_NAME },
39 { ".", DnsNameDomain, ERROR_SUCCESS },
40 { "..", DnsNameDomain, ERROR_INVALID_NAME },
41 { ".a", DnsNameDomain, ERROR_INVALID_NAME },
42 { "a.", DnsNameDomain, ERROR_SUCCESS },
43 { "a..", DnsNameDomain, ERROR_INVALID_NAME },
44 { "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", DnsNameDomain, ERROR_INVALID_NAME },
45 { "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", DnsNameDomain, ERROR_INVALID_NAME },
46 { "a.?", DnsNameDomain, DNS_ERROR_INVALID_NAME_CHAR },
47 { "a.*", DnsNameDomain, DNS_ERROR_INVALID_NAME_CHAR },
48 { "a ", DnsNameDomain, DNS_ERROR_INVALID_NAME_CHAR },
49 { "a._b", DnsNameDomain, DNS_ERROR_NON_RFC_NAME },
50 { "123", DnsNameDomain, DNS_ERROR_NUMERIC_NAME },
51 { "123.456", DnsNameDomain, DNS_ERROR_NUMERIC_NAME },
52 { "a.b", DnsNameDomain, ERROR_SUCCESS },
54 { "", DnsNameDomainLabel, ERROR_INVALID_NAME },
55 { ".", DnsNameDomainLabel, ERROR_INVALID_NAME },
56 { "..", DnsNameDomainLabel, ERROR_INVALID_NAME },
57 { ".c", DnsNameDomainLabel, ERROR_INVALID_NAME },
58 { "c.", DnsNameDomainLabel, ERROR_INVALID_NAME },
59 { "c..", DnsNameDomainLabel, ERROR_INVALID_NAME },
60 { "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", DnsNameDomainLabel, ERROR_INVALID_NAME },
61 { "?", DnsNameDomainLabel, DNS_ERROR_INVALID_NAME_CHAR },
62 { "*", DnsNameDomainLabel, DNS_ERROR_INVALID_NAME_CHAR },
63 { "c ", DnsNameDomainLabel, DNS_ERROR_INVALID_NAME_CHAR },
64 { "_c", DnsNameDomainLabel, DNS_ERROR_NON_RFC_NAME },
65 { "456", DnsNameDomainLabel, ERROR_SUCCESS },
66 { "456.789", DnsNameDomainLabel, ERROR_INVALID_NAME },
67 { "c.d", DnsNameDomainLabel, ERROR_INVALID_NAME },
69 { "", DnsNameHostnameFull, ERROR_INVALID_NAME },
70 { ".", DnsNameHostnameFull, ERROR_SUCCESS },
71 { "..", DnsNameHostnameFull, ERROR_INVALID_NAME },
72 { ".e", DnsNameHostnameFull, ERROR_INVALID_NAME },
73 { "e.", DnsNameHostnameFull, ERROR_SUCCESS },
74 { "e..", DnsNameHostnameFull, ERROR_INVALID_NAME },
75 { "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", DnsNameDomain, ERROR_INVALID_NAME },
76 { "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee.eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee.eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee.eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", DnsNameHostnameFull, ERROR_INVALID_NAME },
77 { "?", DnsNameHostnameLabel, DNS_ERROR_INVALID_NAME_CHAR },
78 { "e.?", DnsNameHostnameFull, DNS_ERROR_INVALID_NAME_CHAR },
79 { "e.*", DnsNameHostnameFull, DNS_ERROR_INVALID_NAME_CHAR },
80 { "e ", DnsNameHostnameFull, DNS_ERROR_INVALID_NAME_CHAR },
81 { "e._f", DnsNameHostnameFull, DNS_ERROR_NON_RFC_NAME },
82 { "789", DnsNameHostnameFull, DNS_ERROR_NUMERIC_NAME },
83 { "789.456", DnsNameHostnameFull, DNS_ERROR_NUMERIC_NAME },
84 { "e.f", DnsNameHostnameFull, ERROR_SUCCESS },
86 { "", DnsNameHostnameLabel, ERROR_INVALID_NAME },
87 { ".", DnsNameHostnameLabel, ERROR_INVALID_NAME },
88 { "..", DnsNameHostnameLabel, ERROR_INVALID_NAME },
89 { ".g", DnsNameHostnameLabel, ERROR_INVALID_NAME },
90 { "g.", DnsNameHostnameLabel, ERROR_INVALID_NAME },
91 { "g..", DnsNameHostnameLabel, ERROR_INVALID_NAME },
92 { "gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg", DnsNameHostnameLabel, ERROR_INVALID_NAME },
93 { "*", DnsNameHostnameLabel, DNS_ERROR_INVALID_NAME_CHAR },
94 { "g ", DnsNameHostnameLabel, DNS_ERROR_INVALID_NAME_CHAR },
95 { "_g", DnsNameHostnameLabel, DNS_ERROR_NON_RFC_NAME },
96 { "123", DnsNameHostnameLabel, DNS_ERROR_NUMERIC_NAME },
97 { "123.456", DnsNameHostnameLabel, ERROR_INVALID_NAME },
98 { "g.h", DnsNameHostnameLabel, ERROR_INVALID_NAME },
100 { "", DnsNameWildcard, ERROR_INVALID_NAME },
101 { ".", DnsNameWildcard, ERROR_INVALID_NAME },
102 { "..", DnsNameWildcard, ERROR_INVALID_NAME },
103 { ".j", DnsNameWildcard, ERROR_INVALID_NAME },
104 { "j.", DnsNameWildcard, ERROR_INVALID_NAME },
105 { "j..", DnsNameWildcard, ERROR_INVALID_NAME },
106 { "jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj", DnsNameWildcard, ERROR_INVALID_NAME },
107 { "jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj.jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj.jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj.jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj", DnsNameWildcard, ERROR_INVALID_NAME },
108 { "?", DnsNameWildcard, ERROR_INVALID_NAME },
109 { "i ", DnsNameWildcard, ERROR_INVALID_NAME },
110 { "_i", DnsNameWildcard, ERROR_INVALID_NAME },
111 { "123", DnsNameWildcard, ERROR_INVALID_NAME },
112 { "123.456", DnsNameWildcard, ERROR_INVALID_NAME },
113 { "i.j", DnsNameWildcard, ERROR_INVALID_NAME },
114 { "*", DnsNameWildcard, ERROR_SUCCESS },
115 { "*j", DnsNameWildcard, DNS_ERROR_INVALID_NAME_CHAR },
116 { "*.j", DnsNameWildcard, ERROR_SUCCESS },
117 { "i.*", DnsNameWildcard, ERROR_INVALID_NAME },
119 { "", DnsNameSrvRecord, ERROR_INVALID_NAME },
120 { ".", DnsNameSrvRecord, ERROR_INVALID_NAME },
121 { "..", DnsNameSrvRecord, ERROR_INVALID_NAME },
122 { ".k", DnsNameSrvRecord, ERROR_INVALID_NAME },
123 { "k.", DnsNameSrvRecord, ERROR_INVALID_NAME },
124 { "k..", DnsNameSrvRecord, ERROR_INVALID_NAME },
125 { "kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk", DnsNameSrvRecord, ERROR_INVALID_NAME },
126 { "kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk.kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk.kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk.kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk", DnsNameSrvRecord, ERROR_INVALID_NAME },
127 { "?", DnsNameSrvRecord, ERROR_INVALID_NAME },
128 { "k ", DnsNameSrvRecord, ERROR_INVALID_NAME },
129 { "_k", DnsNameSrvRecord, ERROR_SUCCESS },
130 { "123", DnsNameSrvRecord, ERROR_INVALID_NAME },
131 { "123.456", DnsNameSrvRecord, ERROR_INVALID_NAME },
132 { "k.l", DnsNameSrvRecord, ERROR_INVALID_NAME },
133 { "_", DnsNameSrvRecord, DNS_ERROR_NON_RFC_NAME },
134 { "_k.l", DnsNameSrvRecord, ERROR_SUCCESS },
135 { "k._l", DnsNameSrvRecord, ERROR_INVALID_NAME }
138 static void test_DnsValidateName_A( void )
140 unsigned int i;
141 DNS_STATUS status;
143 status = DnsValidateName_A( NULL, DnsNameDomain );
144 ok( status == ERROR_INVALID_NAME, "succeeded unexpectedly\n" );
146 for (i = 0; i < sizeof(test_data) / sizeof(test_data[0]); i++)
148 status = DnsValidateName_A( test_data[i].name, test_data[i].format );
149 ok( status == test_data[i].status, "%d: \'%s\': got %d, expected %d\n",
150 i, test_data[i].name, status, test_data[i].status );
154 static void test_DnsNameCompare_A( void )
156 static CHAR empty[] = "",
157 dot[] = ".",
158 dotdot[] = "..",
159 A[] = "A",
160 a[] = "a",
161 B[] = "B",
162 b[] = "b",
163 A_dot_B[] = "A.B",
164 a_dot_a[] = "a.a",
165 a_dot_b[] = "a.b",
166 a_dot_b_dot[] = "a.b.",
167 a_dot_b_dotdot[] = "a.b..",
168 B_dot_A[] = "B.A",
169 b_dot_a[] = "b.a",
170 b_dot_a_dot[] = "b.a.",
171 b_dot_a_dotdot[] = "b.a..";
173 ok( DnsNameCompare_A( NULL, NULL ) == TRUE, "failed unexpectedly\n" );
175 ok( DnsNameCompare_A( empty, empty ) == TRUE, "failed unexpectedly\n" );
176 ok( DnsNameCompare_A( dot, empty ) == TRUE, "failed unexpectedly\n" );
177 ok( DnsNameCompare_A( empty, dot ) == TRUE, "failed unexpectedly\n" );
178 ok( DnsNameCompare_A( dot, dotdot ) == TRUE, "failed unexpectedly\n" );
179 ok( DnsNameCompare_A( dotdot, dot ) == TRUE, "failed unexpectedly\n" );
180 ok( DnsNameCompare_A( a, a ) == TRUE, "failed unexpectedly\n" );
181 ok( DnsNameCompare_A( a, A ) == TRUE, "failed unexpectedly\n" );
182 ok( DnsNameCompare_A( A, a ) == TRUE, "failed unexpectedly\n" );
183 ok( DnsNameCompare_A( a_dot_b, A_dot_B ) == TRUE, "failed unexpectedly\n" );
184 ok( DnsNameCompare_A( a_dot_b, a_dot_b ) == TRUE, "failed unexpectedly\n" );
185 ok( DnsNameCompare_A( a_dot_b_dot, a_dot_b_dot ) == TRUE, "failed unexpectedly\n" );
186 ok( DnsNameCompare_A( a_dot_b_dotdot, a_dot_b_dotdot ) == TRUE, "failed unexpectedly\n" );
188 ok( DnsNameCompare_A( empty, NULL ) == FALSE, "succeeded unexpectedly\n" );
189 ok( DnsNameCompare_A( NULL, empty ) == FALSE, "succeeded unexpectedly\n" );
191 ok( DnsNameCompare_A( a, b ) == FALSE, "succeeded unexpectedly\n" );
192 ok( DnsNameCompare_A( a, B ) == FALSE, "succeeded unexpectedly\n" );
193 ok( DnsNameCompare_A( A, b ) == FALSE, "succeeded unexpectedly\n" );
194 ok( DnsNameCompare_A( a_dot_b, B_dot_A ) == FALSE, "succeeded unexpectedly\n" );
195 ok( DnsNameCompare_A( a_dot_b_dot, b_dot_a_dot ) == FALSE, "succeeded unexpectedly\n" );
196 ok( DnsNameCompare_A( a_dot_b, a_dot_a ) == FALSE, "succeeded unexpectedly\n" );
197 ok( DnsNameCompare_A( a_dot_b_dotdot, b_dot_a_dotdot ) == FALSE, "succeeded unexpectedly\n" );
198 ok( DnsNameCompare_A( a_dot_b_dot, b_dot_a_dotdot ) == FALSE, "succeeded unexpectedly\n" );
199 ok( DnsNameCompare_A( a_dot_b_dotdot, b_dot_a_dot ) == FALSE, "succeeded unexpectedly\n" );
200 ok( DnsNameCompare_A( a_dot_b_dot, b_dot_a ) == FALSE, "succeeded unexpectedly\n" );
201 ok( DnsNameCompare_A( a_dot_b, b_dot_a_dot ) == FALSE, "succeeded unexpectedly\n" );
204 START_TEST(name)
206 test_DnsValidateName_A();
207 test_DnsNameCompare_A();