-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathlistlocked_test.cpp
121 lines (85 loc) · 3.07 KB
/
listlocked_test.cpp
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
/***************************************************************************
tag: The SourceWorks Tue Sep 7 00:54:57 CEST 2010 listlocked_test.cpp
listlocked_test.cpp - description
-------------------
begin : Tue September 07 2010
copyright : (C) 2010 The SourceWorks
email : [email protected]
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "unit.hpp"
#include <internal/ListLocked.hpp>
#include <boost/bind/protect.hpp>
#include <rtt-detail-fwd.hpp>
using namespace RTT::detail;
using namespace std;
using namespace RTT;
using namespace boost;
void foo(double d)
{
}
struct ListTest
{
struct Cont : public boost::intrusive::list_base_hook<> {
double data;
};
typedef boost::intrusive::list<Cont> BufferType;
BufferType mlist;
void mfoo(double d)
{}
double mcfoo(Cont& c)
{
return c.data;
}
template<class Function>
static void apply_item(Function func, Cont& c)
{
//func( c->data );
}
template<class Function>
void apply( Function func )
{
//std::for_each (mlist.begin(), mlist.end(), boost::bind( &ListTest::apply_item<Function>, boost::protect(func), _1) );
for (BufferType::iterator it = mlist.begin(); it != mlist.end(); ++it)
func( it->data );
}
};
void cfoo(ListTest::Cont& c)
{
}
bool iffoo(double d)
{
return true;
}
BOOST_FIXTURE_TEST_SUITE( ListTestSuite, ListTest )
BOOST_AUTO_TEST_CASE( test_instatiation )
{
ListLocked<double> lld(10);
typedef boost::shared_ptr<double*> dsp;
ListLocked<dsp> lldsp(10);
}
BOOST_AUTO_TEST_CASE( test_apply )
{
std::for_each (mlist.begin(), mlist.end(), boost::bind( &ListTestSuite::test_apply::mcfoo, this, _1) );
//std::for_each (mlist.begin(), mlist.end(), boost::bind( &ListTest::apply_item, this, boost::protect(boost::bind(foo, _1)), _1) );
//std::for_each (mlist.begin(), mlist.end(), boost::bind( boost::mem_fn(&ListTestSuite::test_apply::apply_item<void(double)>), this, boost::bind(foo, _1), _1) );
Cont c;
//boost::bind( &ListTestSuite::test_apply::apply_item, this, boost::protect( boost::bind(foo,_1)), _1)(c);
apply( boost::bind(&foo,_1) );
#if 1
ListLocked<double> lld(10);
typedef boost::shared_ptr<double*> dsp;
ListLocked<dsp> lldsp(10);
lld.apply( boost::bind( foo, _1 ) );
#endif
lld.clear();
lldsp.clear();
lld.find_if(&iffoo);
}
BOOST_AUTO_TEST_SUITE_END()