ReactOS 0.4.15-dev-8135-g1bc6c90
record.c
Go to the documentation of this file.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21#include <stdarg.h>
22#include <stdio.h>
23
24#include "windef.h"
25#include "winbase.h"
26#include "winnls.h"
27#ifdef __REACTOS__
28#define UNICODE
29#endif
30#include "windns.h"
31
32#include "wine/test.h"
33
34static WCHAR name1[] = {'l','o','c','a','l','h','o','s','t',0};
35static WCHAR name2[] = {'L','O','C','A','L','H','O','S','T',0};
36
37static DNS_RECORDW r1 = { NULL, name1, DNS_TYPE_A, sizeof(DNS_A_DATA), { 0 }, 1200, 0, { { 0xffffffff } } };
38static DNS_RECORDW r2 = { NULL, name1, DNS_TYPE_A, sizeof(DNS_A_DATA), { 0 }, 1200, 0, { { 0xffffffff } } };
39static DNS_RECORDW r3 = { NULL, name1, DNS_TYPE_A, sizeof(DNS_A_DATA), { 0 }, 1200, 0, { { 0xffffffff } } };
40
41static void test_DnsRecordCompare( void )
42{
43 ok( DnsRecordCompare( &r1, &r1 ) == TRUE, "failed unexpectedly\n" );
44
45 r2.pName = name2;
46 ok( DnsRecordCompare( &r1, &r2 ) == TRUE, "failed unexpectedly\n" );
47
49 ok( DnsRecordCompare( &r1, &r2 ) == TRUE, "failed unexpectedly\n" );
50
52 ok( DnsRecordCompare( &r1, &r2 ) == TRUE, "failed unexpectedly\n" );
53
55 ok( DnsRecordCompare( &r1, &r2 ) == TRUE, "failed unexpectedly\n" );
56
57 r1.dwTtl = 0;
58 ok( DnsRecordCompare( &r1, &r2 ) == TRUE, "failed unexpectedly\n" );
59
60 r2.Data.A.IpAddress = 0;
61 ok( DnsRecordCompare( &r1, &r2 ) == FALSE, "succeeded unexpectedly\n" );
62}
63
64static void test_DnsRecordSetCompare( void )
65{
66 DNS_RECORDW *diff1;
67 DNS_RECORDW *diff2;
68 DNS_RRSET rr1, rr2;
69
70 r1.Flags.DW = 0x2019;
71 r2.Flags.DW = 0x2019;
72 r2.Data.A.IpAddress = 0xffffffff;
73
74 DNS_RRSET_INIT( rr1 );
75 DNS_RRSET_INIT( rr2 );
76
77 DNS_RRSET_ADD( rr1, &r1 );
78 DNS_RRSET_ADD( rr2, &r2 );
79
82
83 ok( DnsRecordSetCompare( NULL, NULL, NULL, NULL ) == FALSE, "succeeded unexpectedly\n" );
84 ok( DnsRecordSetCompare( rr1.pFirstRR, NULL, NULL, NULL ) == FALSE, "succeeded unexpectedly\n" );
85 ok( DnsRecordSetCompare( NULL, rr2.pFirstRR, NULL, NULL ) == FALSE, "succeeded unexpectedly\n" );
86
87 diff1 = NULL;
88 diff2 = NULL;
89
90 ok( DnsRecordSetCompare( NULL, NULL, &diff1, &diff2 ) == FALSE, "succeeded unexpectedly\n" );
91 ok( diff1 == NULL && diff2 == NULL, "unexpected result: %p, %p\n", diff1, diff2 );
92
93 ok( DnsRecordSetCompare( rr1.pFirstRR, NULL, &diff1, &diff2 ) == FALSE, "succeeded unexpectedly\n" );
94 ok( diff1 != NULL && diff2 == NULL, "unexpected result: %p, %p\n", diff1, diff2 );
96
97 ok( DnsRecordSetCompare( NULL, rr2.pFirstRR, &diff1, &diff2 ) == FALSE, "succeeded unexpectedly\n" );
98 ok( diff1 == NULL && diff2 != NULL, "unexpected result: %p, %p\n", diff1, diff2 );
100
101 ok( DnsRecordSetCompare( rr1.pFirstRR, rr2.pFirstRR, NULL, &diff2 ) == TRUE, "failed unexpectedly\n" );
102 ok( diff2 == NULL, "unexpected result: %p\n", diff2 );
103
104 ok( DnsRecordSetCompare( rr1.pFirstRR, rr2.pFirstRR, &diff1, NULL ) == TRUE, "failed unexpectedly\n" );
105 ok( diff1 == NULL, "unexpected result: %p\n", diff1 );
106
107 ok( DnsRecordSetCompare( rr1.pFirstRR, rr2.pFirstRR, &diff1, &diff2 ) == TRUE, "failed unexpectedly\n" );
108 ok( diff1 == NULL && diff2 == NULL, "unexpected result: %p, %p\n", diff1, diff2 );
109
110 r2.Data.A.IpAddress = 0;
111
112 ok( DnsRecordSetCompare( rr1.pFirstRR, rr2.pFirstRR, NULL, &diff2 ) == FALSE, "succeeded unexpectedly\n" );
114
115 ok( DnsRecordSetCompare( rr1.pFirstRR, rr2.pFirstRR, &diff1, NULL ) == FALSE, "succeeded unexpectedly\n" );
117
118 ok( DnsRecordSetCompare( rr1.pFirstRR, rr2.pFirstRR, &diff1, &diff2 ) == FALSE, "succeeded unexpectedly\n" );
121}
122
123static void test_DnsRecordSetDetach( void )
124{
125 DNS_RRSET rr;
126 DNS_RECORDW *r, *s;
127
128 DNS_RRSET_INIT( rr );
129 DNS_RRSET_ADD( rr, &r1 );
130 DNS_RRSET_ADD( rr, &r2 );
131 DNS_RRSET_ADD( rr, &r3 );
133
134 ok( !DnsRecordSetDetach( NULL ), "succeeded unexpectedly\n" );
135
136 r = rr.pFirstRR;
138
139 ok( s == &r3, "failed unexpectedly: got %p, expected %p\n", s, &r3 );
140 ok( r == &r1, "failed unexpectedly: got %p, expected %p\n", r, &r1 );
141 ok( !r2.pNext, "failed unexpectedly\n" );
142}
143
145{
149}
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
VOID WINAPI DnsRecordListFree(PDNS_RECORD list, DNS_FREE_TYPE type)
Definition: record.c:526
BOOL WINAPI DnsRecordSetCompare(PDNS_RECORD set1, PDNS_RECORD set2, PDNS_RECORD *diff1, PDNS_RECORD *diff2)
Definition: record.c:627
PDNS_RECORD WINAPI DnsRecordSetDetach(PDNS_RECORD set)
Definition: record.c:741
BOOL WINAPI DnsRecordCompare(PDNS_RECORD r1, PDNS_RECORD r2)
Definition: record.c:104
GLdouble s
Definition: gl.h:2039
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static void test_DnsRecordCompare(void)
Definition: record.c:41
static DNS_RECORDW r3
Definition: record.c:39
static WCHAR name1[]
Definition: record.c:34
static void test_DnsRecordSetCompare(void)
Definition: record.c:64
static void test_DnsRecordSetDetach(void)
Definition: record.c:123
static DNS_RECORDW r1
Definition: record.c:37
static DNS_RECORDW r2
Definition: record.c:38
static WCHAR name2[]
Definition: record.c:35
IP4_ADDRESS IpAddress
Definition: windns.h:246
PDNS_RECORD pFirstRR
Definition: windns.h:640
DWORD CharSet
Definition: windns.h:240
union _DnsRecordW::@3315 Data
DWORD DW
Definition: windns.h:603
LPWSTR pName
Definition: windns.h:599
struct _DnsRecordW * pNext
Definition: windns.h:598
DNS_A_DATA A
Definition: windns.h:609
DNS_RECORD_FLAGS S
Definition: windns.h:604
union _DnsRecordW::@3314 Flags
DWORD dwTtl
Definition: windns.h:606
#define DNS_RRSET_TERMINATE(rrset)
Definition: windns.h:659
@ DnsFreeRecordList
Definition: windns.h:139
@ DnsCharSetUnicode
Definition: windns.h:111
@ DnsCharSetAnsi
Definition: windns.h:113
#define DNS_RRSET_ADD(rrset, pnewRR)
Definition: windns.h:651
#define DNS_RRSET_INIT(rrset)
Definition: windns.h:644
#define DNS_TYPE_A
Definition: windns.h:41
__wchar_t WCHAR
Definition: xmlstorage.h:180