summaryrefslogtreecommitdiff
path: root/test/cases/aapl.d/test_tdlistmel.cpp
blob: a435a3930a3905c36a8d2aafe127fca9bd026398 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*
 * Copyright 2003 Adrian Thurston <thurston@colm.net>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to
 * deal in the Software without restriction, including without limitation the
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 * sell copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

#include <iostream>
#include "tdlistmel.h"
#include "dlistmel.h"

using namespace std;

#define TD

#ifdef TD
struct ListEl1_A : public TDListEl { };
struct ListEl1_B : public TDListEl { };
struct ListEl2_A : public TDListEl { };
struct ListEl2_B : public TDListEl { };
struct ListEl3_A : public TDListEl { };
struct ListEl3_B : public TDListEl { };
struct ListEl4_A : public TDListEl { };
struct ListEl4_B : public TDListEl { };
struct ListEl5_A : public TDListEl { };
struct ListEl5_B : public TDListEl { };
struct ListEl6_A : public TDListEl { };
struct ListEl6_B : public TDListEl { };
struct ListEl1 : public ListEl1_A, public ListEl1_B { int i; };
struct ListEl2 : public ListEl2_A, public ListEl2_B { int i; };
struct ListEl3 : public ListEl3_A, public ListEl3_B { int i; };
struct ListEl4 : public ListEl4_A, public ListEl4_B { int i; };
struct ListEl5 : public ListEl5_A, public ListEl5_B { int i; };
struct ListEl6 : public ListEl6_A, public ListEl6_B { int i; };
typedef TDListMel<ListEl1, ListEl1_A> List1;
typedef TDListMel<ListEl2, ListEl2_A> List2;
typedef TDListMel<ListEl3, ListEl3_A> List3;
typedef TDListMel<ListEl4, ListEl4_A> List4;
typedef TDListMel<ListEl5, ListEl5_A> List5;
typedef TDListMel<ListEl6, ListEl6_A> List6;
#else
struct ListEl1;
struct ListEl2;
struct ListEl3;
struct ListEl4;
struct ListEl5;
struct ListEl1_A : public DListEl<ListEl1> { };
struct ListEl1_B : public DListEl<ListEl1> { };
struct ListEl2_A : public DListEl<ListEl2> { };
struct ListEl2_B : public DListEl<ListEl2> { };
struct ListEl3_A : public DListEl<ListEl3> { };
struct ListEl3_B : public DListEl<ListEl3> { };
struct ListEl4_A : public DListEl<ListEl4> { };
struct ListEl4_B : public DListEl<ListEl4> { };
struct ListEl5_A : public DListEl<ListEl5> { };
struct ListEl5_B : public DListEl<ListEl5> { };
struct ListEl6_A : public DListEl<ListEl6> { };
struct ListEl6_B : public DListEl<ListEl6> { };
struct ListEl1 : public ListEl1_A, public ListEl1_B { int i; };
struct ListEl2 : public ListEl2_A, public ListEl2_B { int i; };
struct ListEl3 : public ListEl3_A, public ListEl3_B { int i; };
struct ListEl4 : public ListEl4_A, public ListEl4_B { int i; };
struct ListEl5 : public ListEl5_A, public ListEl5_B { int i; };
struct ListEl6 : public ListEl6_A, public ListEl6_B { int i; };
typedef DListMel<ListEl1, ListEl1_A> List1;
typedef DListMel<ListEl2, ListEl2_A> List2;
typedef DListMel<ListEl3, ListEl3_A> List3;
typedef DListMel<ListEl4, ListEl4_A> List4;
typedef DListMel<ListEl5, ListEl5_A> List5;
typedef DListMel<ListEl6, ListEl6_A> List6;
#endif


void testTDList1()
{
	List1 list;
	ListEl1 lel;
	list.append( &lel );
	List1::Iter it = list.first();
	for ( ; it.lte(); it++ )
		cout << it->i << endl;
	List1 copy( list );
	copy.empty();
	cout << list.head << endl;
	cout << copy.head << endl;
}

void testTDList2()
{
	List2 list;
	ListEl2 lel;
	list.append( &lel );
	List2::Iter it = list.first();
	for ( ; it.lte(); it++ )
		cout << it->i << endl;
	List2 copy( list );
	copy.empty();
	cout << list.head << endl;
	cout << copy.head << endl;
}


void testTDList3()
{
	List3 list;
	ListEl3 lel;
	list.append( &lel );
	List3::Iter it = list.first();
	for ( ; it.lte(); it++ )
		cout << it->i << endl;
	List3 copy( list );
	copy.empty();
	cout << list.head << endl;
	cout << copy.head << endl;
}


void testTDList4()
{
	List4 list;
	ListEl4 lel;
	list.append( &lel );
	List4::Iter it = list.first();
	for ( ; it.lte(); it++ )
		cout << it->i << endl;
	List4 copy( list );
	copy.empty();
	cout << list.head << endl;
	cout << copy.head << endl;
}


void testTDList5()
{
	List5 list;
	ListEl5 lel;
	list.append( &lel );
	List5::Iter it = list.first();
	for ( ; it.lte(); it++ )
		cout << it->i << endl;
	List5 copy( list );
	copy.empty();
	cout << list.head << endl;
	cout << copy.head << endl;
}

void testTDList6()
{
	List6 list;
	ListEl6 lel;
	list.append( &lel );
	List6::Iter it = list.first();
	for ( ; it.lte(); it++ )
		cout << it->i << endl;
	List6 copy( list );
	copy.empty();
	cout << list.head << endl;
	cout << copy.head << endl;
}

int main()
{
	testTDList1();
	testTDList2();
	testTDList3();
	testTDList4();
	testTDList5();
	return 0;
}