2 * Tests for record 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
29 #include "wine/test.h"
31 static char name1
[] = "localhost";
32 static char name2
[] = "LOCALHOST";
34 static DNS_RECORDA r1
= { NULL
, name1
, DNS_TYPE_A
, sizeof(DNS_A_DATA
), { 0 }, 1200, 0, { { 0xffffffff } } };
35 static DNS_RECORDA r2
= { NULL
, name1
, DNS_TYPE_A
, sizeof(DNS_A_DATA
), { 0 }, 1200, 0, { { 0xffffffff } } };
36 static DNS_RECORDA r3
= { NULL
, name1
, DNS_TYPE_A
, sizeof(DNS_A_DATA
), { 0 }, 1200, 0, { { 0xffffffff } } };
38 static void test_DnsRecordCompare( void )
40 ok( DnsRecordCompare( (PDNS_RECORD
)&r1
, (PDNS_RECORD
)&r1
) == TRUE
, "failed unexpectedly\n" );
43 ok( DnsRecordCompare( (PDNS_RECORD
)&r1
, (PDNS_RECORD
)&r2
) == TRUE
, "failed unexpectedly\n" );
45 r2
.Flags
.S
.CharSet
= DnsCharSetUnicode
;
46 ok( DnsRecordCompare( (PDNS_RECORD
)&r1
, (PDNS_RECORD
)&r2
) == FALSE
, "succeeded unexpectedly\n" );
48 r2
.Flags
.S
.CharSet
= DnsCharSetAnsi
;
49 ok( DnsRecordCompare( (PDNS_RECORD
)&r1
, (PDNS_RECORD
)&r2
) == FALSE
, "succeeded unexpectedly\n" );
51 r1
.Flags
.S
.CharSet
= DnsCharSetAnsi
;
52 ok( DnsRecordCompare( (PDNS_RECORD
)&r1
, (PDNS_RECORD
)&r2
) == TRUE
, "failed unexpectedly\n" );
55 ok( DnsRecordCompare( (PDNS_RECORD
)&r1
, (PDNS_RECORD
)&r2
) == TRUE
, "failed unexpectedly\n" );
57 r2
.Data
.A
.IpAddress
= 0;
58 ok( DnsRecordCompare( (PDNS_RECORD
)&r1
, (PDNS_RECORD
)&r2
) == FALSE
, "succeeded unexpectedly\n" );
61 static void test_DnsRecordSetCompare( void )
69 r2
.Data
.A
.IpAddress
= 0xffffffff;
71 DNS_RRSET_INIT( rr1
);
72 DNS_RRSET_INIT( rr2
);
74 DNS_RRSET_ADD( rr1
, &r1
);
75 DNS_RRSET_ADD( rr2
, &r2
);
77 DNS_RRSET_TERMINATE( rr1
);
78 DNS_RRSET_TERMINATE( rr2
);
80 ok( DnsRecordSetCompare( NULL
, NULL
, NULL
, NULL
) == FALSE
, "succeeded unexpectedly\n" );
81 ok( DnsRecordSetCompare( rr1
.pFirstRR
, NULL
, NULL
, NULL
) == FALSE
, "succeeded unexpectedly\n" );
82 ok( DnsRecordSetCompare( NULL
, rr2
.pFirstRR
, NULL
, NULL
) == FALSE
, "succeeded unexpectedly\n" );
87 ok( DnsRecordSetCompare( NULL
, NULL
, &diff1
, &diff2
) == FALSE
, "succeeded unexpectedly\n" );
88 ok( diff1
== NULL
&& diff2
== NULL
, "unexpected result: %p, %p\n", diff1
, diff2
);
90 ok( DnsRecordSetCompare( rr1
.pFirstRR
, NULL
, &diff1
, &diff2
) == FALSE
, "succeeded unexpectedly\n" );
91 ok( diff1
!= NULL
&& diff2
== NULL
, "unexpected result: %p, %p\n", diff1
, diff2
);
93 ok( DnsRecordSetCompare( NULL
, rr2
.pFirstRR
, &diff1
, &diff2
) == FALSE
, "succeeded unexpectedly\n" );
94 ok( diff1
== NULL
&& diff2
!= NULL
, "unexpected result: %p, %p\n", diff1
, diff2
);
96 ok( DnsRecordSetCompare( rr1
.pFirstRR
, rr2
.pFirstRR
, NULL
, &diff2
) == TRUE
, "failed unexpectedly\n" );
97 ok( diff2
== NULL
, "unexpected result: %p\n", diff2
);
99 ok( DnsRecordSetCompare( rr1
.pFirstRR
, rr2
.pFirstRR
, &diff1
, NULL
) == TRUE
, "failed unexpectedly\n" );
100 ok( diff1
== NULL
, "unexpected result: %p\n", diff1
);
102 ok( DnsRecordSetCompare( rr1
.pFirstRR
, rr2
.pFirstRR
, &diff1
, &diff2
) == TRUE
, "failed unexpectedly\n" );
103 ok( diff1
== NULL
&& diff2
== NULL
, "unexpected result: %p, %p\n", diff1
, diff2
);
105 r2
.Data
.A
.IpAddress
= 0;
107 ok( DnsRecordSetCompare( rr1
.pFirstRR
, rr2
.pFirstRR
, NULL
, &diff2
) == FALSE
, "succeeded unexpectedly\n" );
108 ok( DnsRecordSetCompare( rr1
.pFirstRR
, rr2
.pFirstRR
, &diff1
, NULL
) == FALSE
, "succeeded unexpectedly\n" );
109 ok( DnsRecordSetCompare( rr1
.pFirstRR
, rr2
.pFirstRR
, &diff1
, &diff2
) == FALSE
, "succeeded unexpectedly\n" );
112 static void test_DnsRecordSetDetach( void )
117 DNS_RRSET_INIT( rr
);
118 DNS_RRSET_ADD( rr
, &r1
);
119 DNS_RRSET_ADD( rr
, &r2
);
120 DNS_RRSET_ADD( rr
, &r3
);
121 DNS_RRSET_TERMINATE( rr
);
123 ok( !DnsRecordSetDetach( NULL
), "succeeded unexpectedly\n" );
126 s
= DnsRecordSetDetach( r
);
128 ok( s
== &r3
, "failed unexpectedly: got %p, expected %p\n", s
, &r3
);
129 ok( r
== &r1
, "failed unexpectedly: got %p, expected %p\n", r
, &r1
);
130 ok( !r2
.pNext
, "failed unexpectedly\n" );
135 test_DnsRecordCompare();
136 test_DnsRecordSetCompare();
137 test_DnsRecordSetDetach();