/[resiprocate]/main/resip/stack/test/testHeaderFieldValueList.cxx
ViewVC logotype

Contents of /main/resip/stack/test/testHeaderFieldValueList.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5948 - (show annotations) (download)
Fri Feb 17 15:30:16 2006 UTC (13 years, 9 months ago) by dworley
File MIME type: text/plain
File size: 9063 byte(s)
Setting more svn: properties, and adding EOLs to the ends of files
that need it.

1 #include "resip/stack/StringSubComponent.hxx"
2 #include "resip/stack/SubComponentList.hxx"
3 #include "resip/stack/HeaderFieldValueList.hxx"
4 #include <iostream>
5
6 using namespace resip;
7 using namespace std;
8
9 int main(int argc, char** argv)
10 {
11
12 HeaderFieldValueList *h = new HeaderFieldValueList;
13 cout << "Empty list: " << endl;
14 cout << *h << endl;
15
16 HeaderFieldValue *myHeader1 = new HeaderFieldValue("foobar", 6);
17 HeaderFieldValue *myHeader2 = new HeaderFieldValue("weekend", 7);
18
19 h->push_front(myHeader1);
20 h->push_front(myHeader2);
21
22 cout << "List with two elements: " << endl;
23 cout << *h;
24 cout << "Front of h " << *(h->first) << endl;
25 cout << "Back of h " << *(h->last) << endl;
26 cout << endl;
27
28 myHeader1 = new HeaderFieldValue("asdfgh", 6);
29 myHeader2 = new HeaderFieldValue("qwertyu", 7);
30
31 h->push_front(myHeader1);
32 h->push_front(myHeader2);
33
34 cout << "List with four elements: " << endl;
35 cout << *h;
36 cout << "Front of h " << *(h->first) << endl;
37 cout << "Back of h " << *(h->last) << endl;
38 cout << endl;
39
40 myHeader1 = new HeaderFieldValue("poifds", 6);
41 myHeader2 = new HeaderFieldValue("nmbhers", 7);
42
43 h->push_back(myHeader1);
44 h->push_back(myHeader2);
45
46 cout << "List with six elements: " << endl;
47 cout << *h;
48 cout << "Front of h " << *(h->first) << endl;
49 cout << "Back of h " << *(h->last) << endl;
50 cout << endl;
51
52 HeaderFieldValueList *i = new HeaderFieldValueList(*h);
53
54 cout << "List h with six elements: " << endl;
55 cout << *h;
56 cout << "Front of h " << *(h->first) << endl;
57 cout << "Back of h " << *(h->last) << endl;
58 cout << endl;
59
60 cout << "List i with six elements: " << endl;
61 cout << *i;
62 cout << "Front of i " << *(i->first) << endl;
63 cout << "Back of i " << *(i->last) << endl;
64 cout << endl;
65
66 i->pop_front();
67
68 cout << "List h with six elements: " << endl;
69 cout << *h;
70 cout << "Front of h " << *(h->first) << endl;
71 cout << "Back of h " << *(h->last) << endl;
72 cout << endl;
73
74 cout << "List i with five elements: " << endl;
75 cout << *i;
76 cout << "Front of i " << *(i->first) << endl;
77 cout << "Back of i " << *(i->last) << endl;
78 cout << endl;
79
80 i->pop_front();
81
82 cout << "List h with six elements: " << endl;
83 cout << *h;
84 cout << "Front of h " << *(h->first) << endl;
85 cout << "Back of h " << *(h->last) << endl;
86 cout << endl;
87
88 cout << "List i with four elements: " << endl;
89 cout << *i;
90 cout << "Front of i " << *(i->first) << endl;
91 cout << "Back of i " << *(i->last) << endl;
92 cout << endl;
93
94 i->pop_front();
95 i->pop_front();
96 i->pop_front();
97
98 cout << "List h with six elements: " << endl;
99 cout << *h;
100 cout << "Front of h " << *(h->first) << endl;
101 cout << "Back of h " << *(h->last) << endl;
102 cout << endl;
103
104 cout << "List i with one element: " << endl;
105 cout << *i;
106 cout << "Front of i " << *(i->first) << endl;
107 cout << "Back of i " << *(i->last) << endl;
108 cout << endl;
109
110 i->pop_front();
111
112 cout << "List h with six elements: " << endl;
113 cout << *h;
114 cout << "Front of h " << *(h->first) << endl;
115 cout << "Back of h " << *(h->last) << endl;
116 cout << endl;
117
118 cout << "List i with zero element: " << endl;
119 cout << *i;
120 cout << "Front of i " << (i->first) << endl;
121 cout << "Back of i " << (i->last) << endl;
122 cout << endl;
123
124 myHeader1 = new HeaderFieldValue("jgjgjg", 6);
125 myHeader2 = new HeaderFieldValue("asasasa", 7);
126
127 i->push_front(myHeader1);
128
129 cout << "List h with six elements: " << endl;
130 cout << *h;
131 cout << "Front of h " << *(h->first) << endl;
132 cout << "Back of h " << *(h->last) << endl;
133 cout << endl;
134
135 cout << "List i with one element: " << endl;
136 cout << *i;
137 cout << "Front of i " << *(i->first) << endl;
138 cout << "Back of i " << *(i->last) << endl;
139 cout << endl;
140
141
142
143 i->push_front(myHeader2);
144
145 cout << "List h with six elements: " << endl;
146 cout << *h;
147 cout << "Front of h " << *(h->first) << endl;
148 cout << "Back of h " << *(h->last) << endl;
149 cout << endl;
150
151 cout << "List i with two elements: " << endl;
152 cout << *i;
153 cout << "Front of i " << *(i->first) << endl;
154 cout << "Back of i " << *(i->last) << endl;
155 cout << endl;
156
157
158
159
160
161 /*
162 SubComponentList* p = new SubComponentList;
163 cout << *p << endl;
164 assert(p->find(SubComponent::TTL) == 0);
165 delete p;
166
167 p = new SubComponentList();
168 p->insert(new StringSubComponent(SubComponent::TTL, "foo"));
169 cout << *p << endl;
170 assert(p->find(SubComponent::TTL)->getType() == SubComponent::TTL);
171 delete p;
172
173 p = new SubComponentList();
174 p->insert(new StringSubComponent(SubComponent::TTL, "foo"));
175 p->insert(new StringSubComponent(SubComponent::Transport, "bar"));
176 cout << *p << endl;
177 assert(p->find(SubComponent::TTL)->getType() == SubComponent::TTL);
178 assert(p->find(SubComponent::Transport)->getType() == SubComponent::Transport);
179 delete p;
180
181 p = new SubComponentList();
182 p->insert(new StringSubComponent(SubComponent::Method, "baz"));
183 p->insert(new StringSubComponent(SubComponent::TTL, "foo"));
184 p->insert(new StringSubComponent(SubComponent::Transport, "bar"));
185 cout << *p << endl;
186 assert(p->find(SubComponent::TTL)->getType() == SubComponent::TTL);
187 assert(p->find(SubComponent::Transport)->getType() == SubComponent::Transport);
188 assert(p->find(SubComponent::Method)->getType() == SubComponent::Method);
189 delete p;
190
191 cout << "Finished Insertion Tests." << endl;
192
193 p = new SubComponentList();
194 p->insert(new StringSubComponent(SubComponent::TTL, "foo"));
195 p->erase(SubComponent::TTL);
196 cout << *p << endl;
197 assert(p->find(SubComponent::TTL) == 0);
198 delete p;
199
200 p = new SubComponentList();
201 p->insert(new StringSubComponent(SubComponent::TTL, "foo"));
202 p->insert(new StringSubComponent(SubComponent::Transport, "bar"));
203 p->erase(SubComponent::TTL);
204 cout << *p << endl;
205 assert(p->find(SubComponent::TTL) == 0);
206 delete p;
207
208 p = new SubComponentList();
209 p->insert(new StringSubComponent(SubComponent::Method, "baz"));
210 p->insert(new StringSubComponent(SubComponent::TTL, "foo"));
211 p->insert(new StringSubComponent(SubComponent::Transport, "bar"));
212 p->erase(SubComponent::TTL);
213 cout << *p << endl;
214 assert(p->find(SubComponent::TTL) == 0);
215 delete p;
216
217 cout << "Deep copy test." << endl;
218
219 p = new SubComponentList();
220 p->insert(new StringSubComponent(SubComponent::Method, "baz"));
221 p->insert(new StringSubComponent(SubComponent::TTL, "foo"));
222 p->insert(new StringSubComponent(SubComponent::Transport, "bar"));
223
224 cout << *p << endl;
225
226 SubComponentList* p2 = new SubComponentList(*p);
227
228 delete p;
229
230 cout << *p2 << endl;
231
232 delete p2;
233 */
234
235
236 return 0;
237 }
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256 /* ====================================================================
257 * The Vovida Software License, Version 1.0
258 *
259 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
260 *
261 * Redistribution and use in source and binary forms, with or without
262 * modification, are permitted provided that the following conditions
263 * are met:
264 *
265 * 1. Redistributions of source code must retain the above copyright
266 * notice, this list of conditions and the following disclaimer.
267 *
268 * 2. Redistributions in binary form must reproduce the above copyright
269 * notice, this list of conditions and the following disclaimer in
270 * the documentation and/or other materials provided with the
271 * distribution.
272 *
273 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
274 * and "Vovida Open Communication Application Library (VOCAL)" must
275 * not be used to endorse or promote products derived from this
276 * software without prior written permission. For written
277 * permission, please contact vocal@vovida.org.
278 *
279 * 4. Products derived from this software may not be called "VOCAL", nor
280 * may "VOCAL" appear in their name, without prior written
281 * permission of Vovida Networks, Inc.
282 *
283 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
284 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
285 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
286 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
287 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
288 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
289 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
290 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
291 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
292 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
293 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
294 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
295 * DAMAGE.
296 *
297 * ====================================================================
298 *
299 * This software consists of voluntary contributions made by Vovida
300 * Networks, Inc. and many individuals on behalf of Vovida Networks,
301 * Inc. For more information on Vovida Networks, Inc., please see
302 * <http://www.vovida.org/>.
303 *
304 */

Properties

Name Value
svn:eol-style native
svn:mime-type text/plain

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27