gdiplus: Access bitmaps by row in alpha_blend_bmp_pixels.
[wine.git] / dlls / dnsapi / tests / name.c
blobfba6955a9371b3c17ede8c838f51df0907d07865
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;
35 DNS_STATUS status_broken;
37 test_data[] =
39 { "", DnsNameDomain, ERROR_INVALID_NAME },
40 { ".", DnsNameDomain, ERROR_SUCCESS },
41 { "..", DnsNameDomain, ERROR_INVALID_NAME },
42 { ".a", DnsNameDomain, ERROR_INVALID_NAME },
43 { "a.", DnsNameDomain, ERROR_SUCCESS },
44 { "a..", DnsNameDomain, ERROR_INVALID_NAME },
45 { "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", DnsNameDomain, ERROR_INVALID_NAME },
46 { "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", DnsNameDomain, ERROR_INVALID_NAME },
47 { "a.?", DnsNameDomain, DNS_ERROR_INVALID_NAME_CHAR },
48 { "a.*", DnsNameDomain, DNS_ERROR_INVALID_NAME_CHAR },
49 { "a ", DnsNameDomain, DNS_ERROR_INVALID_NAME_CHAR },
50 { "a._b", DnsNameDomain, DNS_ERROR_NON_RFC_NAME },
51 { "123", DnsNameDomain, ERROR_SUCCESS, DNS_ERROR_NUMERIC_NAME },
52 { "123.456", DnsNameDomain, ERROR_SUCCESS, DNS_ERROR_NUMERIC_NAME },
53 { "a.b", DnsNameDomain, ERROR_SUCCESS },
55 { "", DnsNameDomainLabel, ERROR_INVALID_NAME },
56 { ".", DnsNameDomainLabel, ERROR_INVALID_NAME },
57 { "..", DnsNameDomainLabel, ERROR_INVALID_NAME },
58 { ".c", DnsNameDomainLabel, ERROR_INVALID_NAME },
59 { "c.", DnsNameDomainLabel, ERROR_INVALID_NAME },
60 { "c..", DnsNameDomainLabel, ERROR_INVALID_NAME },
61 { "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", DnsNameDomainLabel, ERROR_INVALID_NAME },
62 { "?", DnsNameDomainLabel, DNS_ERROR_INVALID_NAME_CHAR },
63 { "*", DnsNameDomainLabel, DNS_ERROR_INVALID_NAME_CHAR },
64 { "c ", DnsNameDomainLabel, DNS_ERROR_INVALID_NAME_CHAR },
65 { "_c", DnsNameDomainLabel, DNS_ERROR_NON_RFC_NAME },
66 { "456", DnsNameDomainLabel, ERROR_SUCCESS },
67 { "456.789", DnsNameDomainLabel, ERROR_INVALID_NAME },
68 { "c.d", DnsNameDomainLabel, ERROR_INVALID_NAME },
70 { "", DnsNameHostnameFull, ERROR_INVALID_NAME },
71 { ".", DnsNameHostnameFull, ERROR_SUCCESS },
72 { "..", DnsNameHostnameFull, ERROR_INVALID_NAME },
73 { ".e", DnsNameHostnameFull, ERROR_INVALID_NAME },
74 { "e.", DnsNameHostnameFull, ERROR_SUCCESS },
75 { "e..", DnsNameHostnameFull, ERROR_INVALID_NAME },
76 { "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", DnsNameDomain, ERROR_INVALID_NAME },
77 { "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee.eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee.eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee.eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", DnsNameHostnameFull, ERROR_INVALID_NAME },
78 { "?", DnsNameHostnameLabel, DNS_ERROR_INVALID_NAME_CHAR },
79 { "e.?", DnsNameHostnameFull, DNS_ERROR_INVALID_NAME_CHAR },
80 { "e.*", DnsNameHostnameFull, DNS_ERROR_INVALID_NAME_CHAR },
81 { "e ", DnsNameHostnameFull, DNS_ERROR_INVALID_NAME_CHAR },
82 { "e._f", DnsNameHostnameFull, DNS_ERROR_NON_RFC_NAME },
83 { "789", DnsNameHostnameFull, ERROR_SUCCESS, DNS_ERROR_NUMERIC_NAME },
84 { "789.456", DnsNameHostnameFull, ERROR_SUCCESS, DNS_ERROR_NUMERIC_NAME },
85 { "e.f", DnsNameHostnameFull, ERROR_SUCCESS },
87 { "", DnsNameHostnameLabel, ERROR_INVALID_NAME },
88 { ".", DnsNameHostnameLabel, ERROR_INVALID_NAME },
89 { "..", DnsNameHostnameLabel, ERROR_INVALID_NAME },
90 { ".g", DnsNameHostnameLabel, ERROR_INVALID_NAME },
91 { "g.", DnsNameHostnameLabel, ERROR_INVALID_NAME },
92 { "g..", DnsNameHostnameLabel, ERROR_INVALID_NAME },
93 { "gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg", DnsNameHostnameLabel, ERROR_INVALID_NAME },
94 { "*", DnsNameHostnameLabel, DNS_ERROR_INVALID_NAME_CHAR },
95 { "g ", DnsNameHostnameLabel, DNS_ERROR_INVALID_NAME_CHAR },
96 { "_g", DnsNameHostnameLabel, DNS_ERROR_NON_RFC_NAME },
97 { "123", DnsNameHostnameLabel, ERROR_SUCCESS, DNS_ERROR_NUMERIC_NAME },
98 { "123.456", DnsNameHostnameLabel, ERROR_INVALID_NAME },
99 { "g.h", DnsNameHostnameLabel, ERROR_INVALID_NAME },
101 { "", DnsNameWildcard, ERROR_INVALID_NAME },
102 { ".", DnsNameWildcard, ERROR_INVALID_NAME },
103 { "..", DnsNameWildcard, ERROR_INVALID_NAME },
104 { ".j", DnsNameWildcard, ERROR_INVALID_NAME },
105 { "j.", DnsNameWildcard, ERROR_INVALID_NAME },
106 { "j..", DnsNameWildcard, ERROR_INVALID_NAME },
107 { "jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj", DnsNameWildcard, ERROR_INVALID_NAME },
108 { "jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj.jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj.jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj.jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj", DnsNameWildcard, ERROR_INVALID_NAME },
109 { "?", DnsNameWildcard, ERROR_INVALID_NAME },
110 { "i ", DnsNameWildcard, ERROR_INVALID_NAME },
111 { "_i", DnsNameWildcard, ERROR_INVALID_NAME },
112 { "123", DnsNameWildcard, ERROR_INVALID_NAME },
113 { "123.456", DnsNameWildcard, ERROR_INVALID_NAME },
114 { "i.j", DnsNameWildcard, ERROR_INVALID_NAME },
115 { "*", DnsNameWildcard, ERROR_SUCCESS },
116 { "*j", DnsNameWildcard, DNS_ERROR_INVALID_NAME_CHAR },
117 { "*.j", DnsNameWildcard, ERROR_SUCCESS },
118 { "i.*", DnsNameWildcard, ERROR_INVALID_NAME },
120 { "", DnsNameSrvRecord, ERROR_INVALID_NAME },
121 { ".", DnsNameSrvRecord, ERROR_INVALID_NAME },
122 { "..", DnsNameSrvRecord, ERROR_INVALID_NAME },
123 { ".k", DnsNameSrvRecord, ERROR_INVALID_NAME },
124 { "k.", DnsNameSrvRecord, ERROR_INVALID_NAME },
125 { "k..", DnsNameSrvRecord, ERROR_INVALID_NAME },
126 { "kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk", DnsNameSrvRecord, ERROR_INVALID_NAME },
127 { "kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk.kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk.kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk.kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk", DnsNameSrvRecord, ERROR_INVALID_NAME },
128 { "?", DnsNameSrvRecord, ERROR_INVALID_NAME },
129 { "k ", DnsNameSrvRecord, ERROR_INVALID_NAME },
130 { "_k", DnsNameSrvRecord, ERROR_SUCCESS },
131 { "123", DnsNameSrvRecord, ERROR_INVALID_NAME },
132 { "123.456", DnsNameSrvRecord, ERROR_INVALID_NAME },
133 { "k.l", DnsNameSrvRecord, ERROR_INVALID_NAME },
134 { "_", DnsNameSrvRecord, DNS_ERROR_NON_RFC_NAME },
135 { "_k.l", DnsNameSrvRecord, ERROR_SUCCESS },
136 { "k._l", DnsNameSrvRecord, ERROR_INVALID_NAME }
139 static void test_DnsValidateName_A( void )
141 unsigned int i;
142 DNS_STATUS status;
144 status = DnsValidateName_A( NULL, DnsNameDomain );
145 ok( status == ERROR_INVALID_NAME, "succeeded unexpectedly\n" );
147 for (i = 0; i < sizeof(test_data) / sizeof(test_data[0]); i++)
149 status = DnsValidateName_A( test_data[i].name, test_data[i].format );
150 ok( status == test_data[i].status || broken(status == test_data[i].status_broken),
151 "%d: \'%s\': got %d, expected %d\n", i, test_data[i].name, status, test_data[i].status );
155 static void test_DnsNameCompare_A( void )
157 static const CHAR empty[] = "",
158 dot[] = ".",
159 dotdot[] = "..",
160 A[] = "A",
161 a[] = "a",
162 B[] = "B",
163 b[] = "b",
164 A_dot_B[] = "A.B",
165 a_dot_a[] = "a.a",
166 a_dot_b[] = "a.b",
167 a_dot_b_dot[] = "a.b.",
168 a_dot_b_dotdot[] = "a.b..",
169 B_dot_A[] = "B.A",
170 b_dot_a[] = "b.a",
171 b_dot_a_dot[] = "b.a.",
172 b_dot_a_dotdot[] = "b.a..";
174 ok( DnsNameCompare_A( NULL, NULL ) == TRUE, "failed unexpectedly\n" );
176 ok( DnsNameCompare_A( empty, empty ) == TRUE, "failed unexpectedly\n" );
177 ok( DnsNameCompare_A( dot, empty ) == TRUE, "failed unexpectedly\n" );
178 ok( DnsNameCompare_A( empty, dot ) == TRUE, "failed unexpectedly\n" );
179 ok( DnsNameCompare_A( dot, dotdot ) == TRUE, "failed unexpectedly\n" );
180 ok( DnsNameCompare_A( dotdot, dot ) == 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, a ) == 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, a_dot_b ) == TRUE, "failed unexpectedly\n" );
186 ok( DnsNameCompare_A( a_dot_b_dot, a_dot_b_dot ) == TRUE, "failed unexpectedly\n" );
187 ok( DnsNameCompare_A( a_dot_b_dotdot, a_dot_b_dotdot ) == TRUE, "failed unexpectedly\n" );
189 ok( DnsNameCompare_A( empty, NULL ) == FALSE, "succeeded unexpectedly\n" );
190 ok( DnsNameCompare_A( NULL, empty ) == 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, b ) == FALSE, "succeeded unexpectedly\n" );
195 ok( DnsNameCompare_A( a_dot_b, B_dot_A ) == FALSE, "succeeded unexpectedly\n" );
196 ok( DnsNameCompare_A( a_dot_b_dot, b_dot_a_dot ) == FALSE, "succeeded unexpectedly\n" );
197 ok( DnsNameCompare_A( a_dot_b, a_dot_a ) == FALSE, "succeeded unexpectedly\n" );
198 ok( DnsNameCompare_A( a_dot_b_dotdot, b_dot_a_dotdot ) == FALSE, "succeeded unexpectedly\n" );
199 ok( DnsNameCompare_A( a_dot_b_dot, b_dot_a_dotdot ) == FALSE, "succeeded unexpectedly\n" );
200 ok( DnsNameCompare_A( a_dot_b_dotdot, b_dot_a_dot ) == FALSE, "succeeded unexpectedly\n" );
201 ok( DnsNameCompare_A( a_dot_b_dot, b_dot_a ) == FALSE, "succeeded unexpectedly\n" );
202 ok( DnsNameCompare_A( a_dot_b, b_dot_a_dot ) == FALSE, "succeeded unexpectedly\n" );
205 START_TEST(name)
207 test_DnsValidateName_A();
208 test_DnsNameCompare_A();