ReactOS 0.4.15-dev-7953-g1f49173
name.c
Go to the documentation of this file.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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
31
32static const struct
33{
36 DNS_STATUS status;
37 DNS_STATUS status_broken;
38}
39test_data[] =
40{
47 { "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", DnsNameDomain, ERROR_INVALID_NAME },
48 { "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", DnsNameDomain, ERROR_INVALID_NAME },
55 { "a.b", DnsNameDomain, ERROR_SUCCESS },
56
63 { "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", DnsNameDomainLabel, ERROR_INVALID_NAME },
71
78 { "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", DnsNameDomain, ERROR_INVALID_NAME },
79 { "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee.eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee.eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee.eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", DnsNameHostnameFull, ERROR_INVALID_NAME },
88
95 { "gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg", DnsNameHostnameLabel, ERROR_INVALID_NAME },
102
109 { "jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj", DnsNameWildcard, ERROR_INVALID_NAME },
110 { "jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj.jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj.jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj.jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj", DnsNameWildcard, ERROR_INVALID_NAME },
115 { "123.456", DnsNameWildcard, ERROR_INVALID_NAME },
119 { "*.j", DnsNameWildcard, ERROR_SUCCESS },
121
128 { "kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk", DnsNameSrvRecord, ERROR_INVALID_NAME },
129 { "kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk.kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk.kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk.kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk", DnsNameSrvRecord, ERROR_INVALID_NAME },
134 { "123.456", DnsNameSrvRecord, ERROR_INVALID_NAME },
137 { "_k.l", DnsNameSrvRecord, ERROR_SUCCESS },
140
141static void test_DnsValidateName_A( void )
142{
143 unsigned int i;
144 DNS_STATUS status;
145
147 ok( status == ERROR_INVALID_NAME, "succeeded unexpectedly\n" );
148
149 for (i = 0; i < ARRAY_SIZE(test_data); i++)
150 {
153 "%d: \'%s\': got %d, expected %d\n", i, test_data[i].name, status, test_data[i].status );
154 }
155}
156
157static void test_DnsNameCompare_A( void )
158{
159 static const CHAR empty[] = "",
160 dot[] = ".",
161 dotdot[] = "..",
162 A[] = "A",
163 a[] = "a",
164 B[] = "B",
165 b[] = "b",
166 A_dot_B[] = "A.B",
167 a_dot_a[] = "a.a",
168 a_dot_b[] = "a.b",
169 a_dot_b_dot[] = "a.b.",
170 a_dot_b_dotdot[] = "a.b..",
171 B_dot_A[] = "B.A",
172 b_dot_a[] = "b.a",
173 b_dot_a_dot[] = "b.a.",
174 b_dot_a_dotdot[] = "b.a..";
175
176 ok( DnsNameCompare_A( NULL, NULL ) == TRUE, "failed unexpectedly\n" );
177
178 ok( DnsNameCompare_A( empty, empty ) == TRUE, "failed unexpectedly\n" );
179 ok( DnsNameCompare_A( dot, empty ) == TRUE, "failed unexpectedly\n" );
180 ok( DnsNameCompare_A( empty, dot ) == TRUE, "failed unexpectedly\n" );
181 ok( DnsNameCompare_A( dot, dotdot ) == TRUE, "failed unexpectedly\n" );
182 ok( DnsNameCompare_A( dotdot, dot ) == TRUE, "failed unexpectedly\n" );
183 ok( DnsNameCompare_A( a, a ) == TRUE, "failed unexpectedly\n" );
184 ok( DnsNameCompare_A( a, A ) == TRUE, "failed unexpectedly\n" );
185 ok( DnsNameCompare_A( A, a ) == TRUE, "failed unexpectedly\n" );
186 ok( DnsNameCompare_A( a_dot_b, A_dot_B ) == TRUE, "failed unexpectedly\n" );
187 ok( DnsNameCompare_A( a_dot_b, a_dot_b ) == TRUE, "failed unexpectedly\n" );
188 ok( DnsNameCompare_A( a_dot_b_dot, a_dot_b_dot ) == TRUE, "failed unexpectedly\n" );
189 ok( DnsNameCompare_A( a_dot_b_dotdot, a_dot_b_dotdot ) == TRUE, "failed unexpectedly\n" );
190
191 ok( DnsNameCompare_A( empty, NULL ) == FALSE, "succeeded unexpectedly\n" );
192 ok( DnsNameCompare_A( NULL, empty ) == FALSE, "succeeded unexpectedly\n" );
193
194 ok( DnsNameCompare_A( a, b ) == FALSE, "succeeded unexpectedly\n" );
195 ok( DnsNameCompare_A( a, B ) == FALSE, "succeeded unexpectedly\n" );
196 ok( DnsNameCompare_A( A, b ) == FALSE, "succeeded unexpectedly\n" );
197 ok( DnsNameCompare_A( a_dot_b, B_dot_A ) == FALSE, "succeeded unexpectedly\n" );
198 ok( DnsNameCompare_A( a_dot_b_dot, b_dot_a_dot ) == FALSE, "succeeded unexpectedly\n" );
199 ok( DnsNameCompare_A( a_dot_b, a_dot_a ) == FALSE, "succeeded unexpectedly\n" );
200 ok( DnsNameCompare_A( a_dot_b_dotdot, b_dot_a_dotdot ) == FALSE, "succeeded unexpectedly\n" );
201 ok( DnsNameCompare_A( a_dot_b_dot, b_dot_a_dotdot ) == FALSE, "succeeded unexpectedly\n" );
202 ok( DnsNameCompare_A( a_dot_b_dotdot, b_dot_a_dot ) == FALSE, "succeeded unexpectedly\n" );
203 ok( DnsNameCompare_A( a_dot_b_dot, b_dot_a ) == FALSE, "succeeded unexpectedly\n" );
204 ok( DnsNameCompare_A( a_dot_b, b_dot_a_dot ) == FALSE, "succeeded unexpectedly\n" );
205}
206
208{
209 BOOL ret;
210 DWORD err;
211
212 SetLastError( 0xdeadbeef );
214 err = GetLastError();
215 ok( !ret, "got %d\n", ret );
216 ok( err == 0xdeadbeef, "got %u\n", err );
217
218 ret = DnsFlushResolverCacheEntry_A( "localhost" );
219 ok( ret, "got %d\n", ret );
220
221 ret = DnsFlushResolverCacheEntry_A( "nxdomain.test.winehq.org" );
222 ok( ret, "got %d\n", ret );
223}
224
226{
230}
#define broken(x)
Definition: _sntprintf.h:21
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define ARRAY_SIZE(A)
Definition: main.h:33
Definition: ehthrow.cxx:93
Definition: ehthrow.cxx:54
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static const WCHAR empty[]
Definition: main.c:47
#define SetLastError(x)
Definition: compat.h:752
#define ERROR_INVALID_NAME
Definition: compat.h:103
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
DNS_STATUS status_broken
Definition: name.c:37
static void test_DnsNameCompare_A(void)
Definition: name.c:157
static void test_DnsValidateName_A(void)
Definition: name.c:141
DNS_STATUS status
Definition: name.c:36
static void test_DnsFlushResolverCacheEntry_A(void)
Definition: name.c:207
DNS_NAME_FORMAT format
Definition: name.c:35
BOOL WINAPI DnsFlushResolverCacheEntry_A(PCSTR)
BOOL WINAPI DnsNameCompare_A(LPCSTR name1, LPCSTR name2)
Definition: names.c:31
DNS_STATUS WINAPI DnsValidateName_A(PCSTR name, DNS_NAME_FORMAT format)
Definition: names.c:81
#define err(...)
Definition: name.c:39
Definition: ps.c:97
const char * PCSTR
Definition: typedefs.h:52
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
@ DnsNameSrvRecord
Definition: windns.h:149
@ DnsNameHostnameLabel
Definition: windns.h:147
@ DnsNameDomainLabel
Definition: windns.h:145
@ DnsNameDomain
Definition: windns.h:144
@ DnsNameHostnameFull
Definition: windns.h:146
@ DnsNameWildcard
Definition: windns.h:148
enum _DNS_NAME_FORMAT DNS_NAME_FORMAT
#define WINAPI
Definition: msvc.h:6
#define DNS_ERROR_NUMERIC_NAME
Definition: winerror.h:1878
#define DNS_ERROR_NON_RFC_NAME
Definition: winerror.h:1872
#define DNS_ERROR_INVALID_NAME_CHAR
Definition: winerror.h:1877
const char * LPCSTR
Definition: xmlstorage.h:183
char CHAR
Definition: xmlstorage.h:175