|
From: <den...@us...> - 2010-09-11 15:42:55
|
Revision: 129
http://dsim.svn.sourceforge.net/dsim/?rev=129&view=rev
Author: denis_arnaud
Date: 2010-09-11 15:42:49 +0000 (Sat, 11 Sep 2010)
Log Message:
-----------
[Test] Added a sub-directory for Boost.Intrusive.
Modified Paths:
--------------
trunk/dsim/configure.ac
trunk/dsim/test/boost/Makefile.am
Added Paths:
-----------
trunk/dsim/test/boost/intrusive/
trunk/dsim/test/boost/intrusive/Makefile.am
trunk/dsim/test/boost/intrusive/intrusive.cpp
Modified: trunk/dsim/configure.ac
===================================================================
--- trunk/dsim/configure.ac 2010-09-11 00:48:16 UTC (rev 128)
+++ trunk/dsim/configure.ac 2010-09-11 15:42:49 UTC (rev 129)
@@ -496,6 +496,7 @@
test/boost/asio/logger/Makefile
test/boost/asio/chat/Makefile
test/boost/filesystem/Makefile
+ test/boost/intrusive/Makefile
test/boost/iostreams/Makefile
test/boost/mpi/Makefile
test/boost/mpi/master_slave/Makefile
Modified: trunk/dsim/test/boost/Makefile.am
===================================================================
--- trunk/dsim/test/boost/Makefile.am 2010-09-11 00:48:16 UTC (rev 128)
+++ trunk/dsim/test/boost/Makefile.am 2010-09-11 15:42:49 UTC (rev 129)
@@ -5,7 +5,7 @@
MAINTAINERCLEANFILES = Makefile.in
##
-SUBDIRS = accumulators asio filesystem mpi mpl serialization signals spirit \
- smart_pointers
+SUBDIRS = accumulators asio filesystem intrusive mpi mpl \
+ serialization signals spirit smart_pointers
EXTRA_DIST =
Property changes on: trunk/dsim/test/boost/intrusive
___________________________________________________________________
Added: svn:ignore
+ .deps
.libs
Makefile.in
Makefile
intrusive
Added: trunk/dsim/test/boost/intrusive/Makefile.am
===================================================================
--- trunk/dsim/test/boost/intrusive/Makefile.am (rev 0)
+++ trunk/dsim/test/boost/intrusive/Makefile.am 2010-09-11 15:42:49 UTC (rev 129)
@@ -0,0 +1,20 @@
+## test/boost/intrusive sub-directory
+include $(top_srcdir)/Makefile.common
+
+MAINTAINERCLEANFILES = Makefile.in
+
+##
+SUBDIRS =
+
+EXTRA_DIST =
+##
+
+check_PROGRAMS = intrusive
+#TESTS = $(check_PROGRAMS)
+TESTS =
+XFAIL_TESTS = #IndexBuildingTestSuite
+
+intrusive_SOURCES = intrusive.cpp
+intrusive_CXXFLAGS= $(BOOST_CFLAGS)
+intrusive_LDFLAGS = $(BOOST_LIBS)
+intrusive_LDADD =
Added: trunk/dsim/test/boost/intrusive/intrusive.cpp
===================================================================
--- trunk/dsim/test/boost/intrusive/intrusive.cpp (rev 0)
+++ trunk/dsim/test/boost/intrusive/intrusive.cpp 2010-09-11 15:42:49 UTC (rev 129)
@@ -0,0 +1,71 @@
+#include <boost/intrusive/list.hpp>
+#include <vector>
+
+using namespace boost::intrusive;
+
+/** Object to be inserted in the intrusive list. */
+class MyClass : public list_base_hook<> {
+ int _int;
+public:
+ list_member_hook<> member_hook_;
+
+ MyClass (int i) : _int (i) {}
+};
+
+//Define a list that will store MyClass using the base hook
+typedef list<MyClass> BaseList;
+
+//Define a list that will store MyClass using the member hook
+typedef member_hook
+<MyClass, list_member_hook<>, &MyClass::member_hook_> MemberOption;
+typedef list<MyClass, MemberOption> MemberList;
+
+
+// /////////////////////// M A I N /////////////////////
+int main() {
+
+ typedef std::vector<MyClass>::iterator VectIt;
+ typedef std::vector<MyClass>::reverse_iterator VectRit;
+
+ //Create several MyClass objects, each one with a different value
+ std::vector<MyClass> values;
+ for (int i = 0; i < 100; ++i) {
+ values.push_back (MyClass(i));
+ }
+
+ BaseList baselist;
+ MemberList memberlist;
+
+ //Now insert them in the reverse order in the base hook list
+ for (VectIt it(values.begin()), itend(values.end()); it != itend; ++it) {
+ baselist.push_front (*it);
+ }
+
+ //Now insert them in the same order as in vector in the member hook list
+ for (VectIt it(values.begin()), itend(values.end()); it != itend; ++it) {
+ memberlist.push_back (*it);
+ }
+
+ //Now test lists
+ {
+ BaseList::reverse_iterator rbit(baselist.rbegin()), rbitend(baselist.rend());
+ MemberList::iterator mit (memberlist.begin()), mitend(memberlist.end());
+ VectIt it (values.begin()), itend (values.end());
+
+ //Test the objects inserted in the base hook list
+ for (; it != itend; ++it, ++rbit) {
+ if (&*rbit != &*it) {
+ return 1;
+ }
+ }
+
+ //Test the objects inserted in the member hook list
+ for (it = values.begin(); it != itend; ++it, ++mit) {
+ if (&*mit != &*it) {
+ return 1;
+ }
+ }
+ }
+
+ return 0;
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|