~ubuntu-branches/ubuntu/gutsy/poco/gutsy

« back to all changes in this revision

Viewing changes to Foundation/testsuite/src/PriorityEventTest.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Krzysztof Burghardt
  • Date: 2007-04-27 18:33:48 UTC
  • Revision ID: james.westby@ubuntu.com-20070427183348-xgnpct0qd6a2ip34
Tags: upstream-1.2.9
ImportĀ upstreamĀ versionĀ 1.2.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// PriorityEventTest.cpp
 
3
//
 
4
// $Id: //poco/1.2/Foundation/testsuite/src/PriorityEventTest.cpp#2 $
 
5
//
 
6
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
 
7
// and Contributors.
 
8
//
 
9
// Permission is hereby granted, free of charge, to any person or organization
 
10
// obtaining a copy of the software and accompanying documentation covered by
 
11
// this license (the "Software") to use, reproduce, display, distribute,
 
12
// execute, and transmit the Software, and to prepare derivative works of the
 
13
// Software, and to permit third-parties to whom the Software is furnished to
 
14
// do so, all subject to the following:
 
15
// 
 
16
// The copyright notices in the Software and this entire statement, including
 
17
// the above license grant, this restriction and the following disclaimer,
 
18
// must be included in all copies of the Software, in whole or in part, and
 
19
// all derivative works of the Software, unless such copies or derivative
 
20
// works are solely in the form of machine-executable object code generated by
 
21
// a source language processor.
 
22
// 
 
23
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
24
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
25
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
 
26
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
 
27
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
 
28
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 
29
// DEALINGS IN THE SOFTWARE.
 
30
//
 
31
 
 
32
 
 
33
#include "PriorityEventTest.h"
 
34
#include "DummyDelegate.h"
 
35
#include "CppUnit/TestCaller.h"
 
36
#include "CppUnit/TestSuite.h"
 
37
#include "Poco/PriorityDelegate.h"
 
38
#include "Poco/PriorityExpire.h"
 
39
#include "Poco/Thread.h"
 
40
#include "Poco/Exception.h"
 
41
 
 
42
 
 
43
using namespace Poco;
 
44
 
 
45
 
 
46
#define LARGEINC 100
 
47
 
 
48
 
 
49
PriorityEventTest::PriorityEventTest(const std::string& name): CppUnit::TestCase(name)
 
50
{
 
51
}
 
52
 
 
53
 
 
54
PriorityEventTest::~PriorityEventTest()
 
55
{
 
56
}
 
57
 
 
58
void PriorityEventTest::testNoDelegate()
 
59
{
 
60
        int tmp = 0;
 
61
        EventArgs args;
 
62
 
 
63
        assert (_count == 0);
 
64
        Simple.notify(this, tmp);
 
65
        assert (_count == 0);
 
66
 
 
67
        Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
 
68
        Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
 
69
        Simple.notify(this, tmp);
 
70
        assert (_count == 0);
 
71
        
 
72
        ConstSimple += PriorityDelegate<PriorityEventTest, const int>(this, &PriorityEventTest::onConstSimple, 0);
 
73
        ConstSimple -= PriorityDelegate<PriorityEventTest, const int>(this, &PriorityEventTest::onConstSimple, 0);
 
74
        ConstSimple.notify(this, tmp);
 
75
        assert (_count == 0);
 
76
        
 
77
        //Note: passing &args will not work due to &
 
78
        EventArgs* pArgs = &args;
 
79
        Complex += PriorityDelegate<PriorityEventTest, Poco::EventArgs*>(this, &PriorityEventTest::onComplex, 0);
 
80
        Complex -= PriorityDelegate<PriorityEventTest, Poco::EventArgs*>(this, &PriorityEventTest::onComplex, 0);
 
81
        Complex.notify(this, pArgs);
 
82
        assert (_count == 0);
 
83
 
 
84
        Complex2 += PriorityDelegate<PriorityEventTest, Poco::EventArgs>(this, &PriorityEventTest::onComplex2, 0);
 
85
        Complex2 -= PriorityDelegate<PriorityEventTest, Poco::EventArgs>(this, &PriorityEventTest::onComplex2, 0);
 
86
        Complex2.notify(this, args);
 
87
        assert (_count == 0);
 
88
 
 
89
        const EventArgs* pCArgs = &args;
 
90
        ConstComplex += PriorityDelegate<PriorityEventTest, const Poco::EventArgs*>(this, &PriorityEventTest::onConstComplex, 0);
 
91
        ConstComplex -= PriorityDelegate<PriorityEventTest, const Poco::EventArgs*>(this, &PriorityEventTest::onConstComplex, 0);
 
92
        ConstComplex.notify(this, pCArgs);
 
93
        assert (_count == 0);
 
94
 
 
95
        Const2Complex += PriorityDelegate<PriorityEventTest, const Poco::EventArgs* const>(this, &PriorityEventTest::onConst2Complex, 0);
 
96
        Const2Complex -= PriorityDelegate<PriorityEventTest, const Poco::EventArgs* const>(this, &PriorityEventTest::onConst2Complex, 0);
 
97
        Const2Complex.notify(this, pArgs);
 
98
        assert (_count == 0);
 
99
}
 
100
 
 
101
void PriorityEventTest::testSingleDelegate()
 
102
{
 
103
        int tmp = 0;
 
104
        EventArgs args;
 
105
 
 
106
        assert (_count == 0);
 
107
 
 
108
        Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
 
109
        // unregistering with a different priority --> different observer, is ignored
 
110
        Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 3);
 
111
        Simple.notify(this, tmp);
 
112
        assert (_count == 1);
 
113
        
 
114
        ConstSimple += PriorityDelegate<PriorityEventTest, const int>(this, &PriorityEventTest::onConstSimple, 0);
 
115
        ConstSimple -= PriorityDelegate<PriorityEventTest, const int>(this, &PriorityEventTest::onConstSimple, 3);
 
116
        ConstSimple.notify(this, tmp);
 
117
        assert (_count == 2);
 
118
        
 
119
        EventArgs* pArgs = &args;
 
120
        Complex += PriorityDelegate<PriorityEventTest, Poco::EventArgs*>(this, &PriorityEventTest::onComplex, 0);
 
121
        Complex -= PriorityDelegate<PriorityEventTest, Poco::EventArgs*>(this, &PriorityEventTest::onComplex, 3);
 
122
        Complex.notify(this, pArgs);
 
123
        assert (_count == 3);
 
124
 
 
125
        Complex2 += PriorityDelegate<PriorityEventTest, Poco::EventArgs>(this, &PriorityEventTest::onComplex2, 0);
 
126
        Complex2 -= PriorityDelegate<PriorityEventTest, Poco::EventArgs>(this, &PriorityEventTest::onComplex2, 3);
 
127
        Complex2.notify(this, args);
 
128
        assert (_count == 4);
 
129
 
 
130
        const EventArgs* pCArgs = &args;
 
131
        ConstComplex += PriorityDelegate<PriorityEventTest, const Poco::EventArgs*>(this, &PriorityEventTest::onConstComplex, 0);
 
132
        ConstComplex -= PriorityDelegate<PriorityEventTest, const Poco::EventArgs*>(this, &PriorityEventTest::onConstComplex, 3);
 
133
        ConstComplex.notify(this, pCArgs);
 
134
        assert (_count == 5);
 
135
 
 
136
        Const2Complex += PriorityDelegate<PriorityEventTest, const Poco::EventArgs* const>(this, &PriorityEventTest::onConst2Complex, 0);
 
137
        Const2Complex -= PriorityDelegate<PriorityEventTest, const Poco::EventArgs* const>(this, &PriorityEventTest::onConst2Complex, 3);
 
138
        Const2Complex.notify(this, pArgs);
 
139
        assert (_count == 6);
 
140
        // check if 2nd notify also works
 
141
        Const2Complex.notify(this, pArgs);
 
142
        assert (_count == 7);
 
143
        
 
144
}
 
145
 
 
146
void PriorityEventTest::testDuplicateRegister()
 
147
{
 
148
        int tmp = 0;
 
149
        
 
150
        assert (_count == 0);
 
151
 
 
152
        Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
 
153
        Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
 
154
        Simple.notify(this, tmp);
 
155
        assert (_count == 1);
 
156
        Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
 
157
        Simple.notify(this, tmp);
 
158
        assert (_count == 1);
 
159
 
 
160
        Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
 
161
        Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimpleOther, 1);
 
162
        Simple.notify(this, tmp);
 
163
        assert (_count == 2 + LARGEINC);
 
164
        Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimpleOther, 1);
 
165
        Simple.notify(this, tmp);
 
166
        assert (_count == 3 + LARGEINC);
 
167
}
 
168
 
 
169
void PriorityEventTest::testDuplicateUnregister()
 
170
{
 
171
        // duplicate unregister shouldn't give an error,
 
172
        int tmp = 0;
 
173
        
 
174
        assert (_count == 0);
 
175
 
 
176
        Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0); // should work
 
177
        Simple.notify(this, tmp);
 
178
        assert (_count == 0);
 
179
 
 
180
        Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
 
181
        Simple.notify(this, tmp);
 
182
        assert (_count == 1);
 
183
 
 
184
        Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
 
185
        Simple.notify(this, tmp);
 
186
        assert (_count == 1);
 
187
 
 
188
        Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
 
189
        Simple.notify(this, tmp);
 
190
        assert (_count == 1);
 
191
}
 
192
 
 
193
 
 
194
void PriorityEventTest::testDisabling()
 
195
{
 
196
        int tmp = 0;
 
197
        
 
198
        assert (_count == 0);
 
199
 
 
200
        Simple += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
 
201
        Simple.disable();
 
202
        Simple.notify(this, tmp);
 
203
        assert (_count == 0);
 
204
        Simple.enable();
 
205
        Simple.notify(this, tmp);
 
206
        assert (_count == 1);
 
207
 
 
208
        // unregister should also work with disabled event
 
209
        Simple.disable();
 
210
        Simple -= PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 0);
 
211
        Simple.enable();
 
212
        Simple.notify(this, tmp);
 
213
        assert (_count == 1);
 
214
}
 
215
 
 
216
void PriorityEventTest::testPriorityOrder()
 
217
{
 
218
        DummyDelegate o1;
 
219
        DummyDelegate o2;
 
220
 
 
221
        assert (_count == 0);
 
222
 
 
223
        Simple += PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 1);
 
224
        Simple += PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0);
 
225
 
 
226
        int tmp = 0;
 
227
        Simple.notify(this, tmp);
 
228
        assert (tmp == 2);
 
229
 
 
230
        Simple -= PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0);
 
231
        Simple -= PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 1);
 
232
        
 
233
        // now try with the wrong order
 
234
        Simple += PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 0);
 
235
        Simple += PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 1);
 
236
 
 
237
        try
 
238
        {
 
239
                tmp = 0;
 
240
                Simple.notify(this, tmp);
 
241
                failmsg ("Notify should not work");
 
242
        }
 
243
        catch (Poco::InvalidArgumentException&)
 
244
        {
 
245
        }
 
246
 
 
247
        Simple -= PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 0);
 
248
        Simple -= PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 1);
 
249
}
 
250
 
 
251
void PriorityEventTest::testPriorityOrderExpire()
 
252
{
 
253
        // expire must not break order!
 
254
        DummyDelegate o1;
 
255
        DummyDelegate o2;
 
256
 
 
257
        assert (_count == 0);
 
258
 
 
259
        Simple += PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 1), 500000);
 
260
        Simple += PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0), 500000);
 
261
        int tmp = 0;
 
262
        Simple.notify(this, tmp);
 
263
        assert (tmp == 2);
 
264
 
 
265
        // both ways of unregistering should work
 
266
        Simple -= PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0), 600000);
 
267
        Simple -= PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 1);
 
268
        Simple.notify(this, tmp);
 
269
        assert (tmp == 2);
 
270
        
 
271
        // now start mixing of expire and non expire
 
272
        tmp = 0;
 
273
        Simple += PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 1), 500000);
 
274
        Simple += PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0);
 
275
        
 
276
        Simple.notify(this, tmp);
 
277
        assert (tmp == 2);
 
278
 
 
279
        Simple -= PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 1);
 
280
        // it is not forbidden to unregister a non expiring event with an expire decorator (it is just stupid ;-))
 
281
        Simple -= PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0), 600000);
 
282
        Simple.notify(this, tmp);
 
283
        assert (tmp == 2);
 
284
 
 
285
        // now try with the wrong order
 
286
        Simple += PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 0), 500000);
 
287
        Simple += PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 1);
 
288
 
 
289
        try
 
290
        {
 
291
                tmp = 0;
 
292
                Simple.notify(this, tmp);
 
293
                failmsg ("Notify should not work");
 
294
        }
 
295
        catch (Poco::InvalidArgumentException&)
 
296
        {
 
297
        }
 
298
 
 
299
        Simple -= PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 0), 500000);
 
300
        Simple -= PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 1);
 
301
 
 
302
}
 
303
 
 
304
void PriorityEventTest::testExpire()
 
305
{
 
306
        int tmp = 0;
 
307
        
 
308
        assert (_count == 0);
 
309
 
 
310
        Simple += PriorityExpire<int>(PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 1), 500);
 
311
        Simple.notify(this, tmp);
 
312
        assert (_count == 1);
 
313
        Poco::Thread::sleep(700);
 
314
        Simple.notify(this, tmp);
 
315
        assert (_count == 1);
 
316
        Simple -= PriorityExpire<int>(PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 1), 500);
 
317
}
 
318
 
 
319
 
 
320
void PriorityEventTest::testExpireReRegister()
 
321
{
 
322
        int tmp = 0;
 
323
        
 
324
        assert (_count == 0);
 
325
 
 
326
        Simple += PriorityExpire<int>(PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 1), 500);
 
327
        Simple.notify(this, tmp);
 
328
        assert (_count == 1);
 
329
        Poco::Thread::sleep(200);
 
330
        Simple.notify(this, tmp);
 
331
        assert (_count == 2);
 
332
        // renew registration
 
333
        Simple += PriorityExpire<int>(PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onSimple, 1), 600);
 
334
        Poco::Thread::sleep(400);
 
335
        Simple.notify(this, tmp);
 
336
        assert (_count == 3);
 
337
        Poco::Thread::sleep(300);
 
338
        Simple.notify(this, tmp);
 
339
        assert (_count == 3);
 
340
}
 
341
 
 
342
 
 
343
void PriorityEventTest::testReturnParams()
 
344
{
 
345
        DummyDelegate o1;
 
346
        Simple += PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0);
 
347
 
 
348
        int tmp = 0;
 
349
        Simple.notify(this, tmp);
 
350
        assert (tmp == 1);
 
351
}
 
352
 
 
353
void PriorityEventTest::testOverwriteDelegate()
 
354
{
 
355
        DummyDelegate o1;
 
356
        Simple += PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple2, 0);
 
357
        // o1 can only have one entry per priority, thus the next line will replace the entry
 
358
        Simple += PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0);
 
359
 
 
360
        int tmp = 0; // onsimple requires 0 as input
 
361
        Simple.notify(this, tmp);
 
362
        assert (tmp == 1);
 
363
        // now overwrite with onsimple2 with requires as input tmp = 1
 
364
        Simple += PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple2, 0), 23000);
 
365
        Simple.notify(this, tmp);
 
366
        assert (tmp == 2);
 
367
        Simple -= PriorityExpire<int>(PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple2, 0), 23000);
 
368
}
 
369
 
 
370
void PriorityEventTest::testAsyncNotify()
 
371
{
 
372
        Poco::PriorityEvent<int >* pSimple= new Poco::PriorityEvent<int>();
 
373
        (*pSimple) += PriorityDelegate<PriorityEventTest, int>(this, &PriorityEventTest::onAsync, 0);
 
374
        assert (_count == 0);
 
375
        int tmp = 0;
 
376
        Poco::ActiveResult<int>retArg = pSimple->notifyAsync(this, tmp);
 
377
        delete pSimple; // must work even when the event got deleted!
 
378
        pSimple = NULL;
 
379
        assert (_count == 0);
 
380
        retArg.wait();
 
381
        assert (retArg.data() == tmp);
 
382
        assert (_count == LARGEINC);
 
383
        
 
384
}
 
385
 
 
386
void PriorityEventTest::onSimple(const void* pSender, int& i)
 
387
{
 
388
        _count++;
 
389
}
 
390
 
 
391
void PriorityEventTest::onSimpleOther(const void* pSender, int& i)
 
392
{
 
393
        _count += LARGEINC ;
 
394
}
 
395
 
 
396
void PriorityEventTest::onConstSimple(const void* pSender, const int& i)
 
397
{
 
398
        _count++;
 
399
}
 
400
 
 
401
void PriorityEventTest::onComplex(const void* pSender, Poco::EventArgs* & i)
 
402
{
 
403
        _count++;
 
404
}
 
405
 
 
406
void PriorityEventTest::onComplex2(const void* pSender, Poco::EventArgs & i)
 
407
{
 
408
        _count++;
 
409
}
 
410
 
 
411
void PriorityEventTest::onConstComplex(const void* pSender, const Poco::EventArgs*& i)
 
412
{
 
413
        _count++;
 
414
}
 
415
 
 
416
void PriorityEventTest::onConst2Complex(const void* pSender, const Poco::EventArgs * const & i)
 
417
{
 
418
        _count++;
 
419
}
 
420
 
 
421
void PriorityEventTest::onAsync(const void* pSender, int& i)
 
422
{
 
423
        Poco::Thread::sleep(700);
 
424
        _count += LARGEINC ;
 
425
}
 
426
 
 
427
int PriorityEventTest::getCount() const
 
428
{
 
429
        return _count;
 
430
}
 
431
 
 
432
void PriorityEventTest::setUp()
 
433
{
 
434
        _count = 0;
 
435
        // must clear events, otherwise repeating test executions will fail
 
436
        // because tests are only created once, only setup is called before 
 
437
        // each test run
 
438
        Simple.clear();
 
439
        ConstSimple.clear();
 
440
        Complex.clear();
 
441
        Complex2.clear();
 
442
        ConstComplex.clear();
 
443
        Const2Complex.clear();
 
444
}
 
445
 
 
446
 
 
447
void PriorityEventTest::tearDown()
 
448
{
 
449
}
 
450
 
 
451
 
 
452
CppUnit::Test* PriorityEventTest::suite()
 
453
{
 
454
        CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("PriorityEventTest");
 
455
 
 
456
        CppUnit_addTest(pSuite, PriorityEventTest, testNoDelegate);
 
457
        CppUnit_addTest(pSuite, PriorityEventTest, testSingleDelegate);
 
458
        CppUnit_addTest(pSuite, PriorityEventTest, testReturnParams);
 
459
        CppUnit_addTest(pSuite, PriorityEventTest, testDuplicateRegister);
 
460
        CppUnit_addTest(pSuite, PriorityEventTest, testDuplicateUnregister);
 
461
        CppUnit_addTest(pSuite, PriorityEventTest, testDisabling);
 
462
        CppUnit_addTest(pSuite, PriorityEventTest, testPriorityOrder);
 
463
        CppUnit_addTest(pSuite, PriorityEventTest, testPriorityOrderExpire);
 
464
        CppUnit_addTest(pSuite, PriorityEventTest, testExpire);
 
465
        CppUnit_addTest(pSuite, PriorityEventTest, testExpireReRegister);
 
466
        CppUnit_addTest(pSuite, PriorityEventTest, testOverwriteDelegate);
 
467
        CppUnit_addTest(pSuite, PriorityEventTest, testAsyncNotify);
 
468
        return pSuite;
 
469
}