https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Partially check point sets compatibility.
* tests/core/point_set_compatibility.cc: New test.
* tests/core/Makefile.am (check_PROGRAMS): Add
point_set_compatibility.
(point_set_compatibility_SOURCES): New.
Makefile.am | 2 +
point_set_compatibility.cc | 89 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 91 insertions(+)
Index: tests/core/point_set_compatibility.cc
--- tests/core/point_set_compatibility.cc (revision 0)
+++ tests/core/point_set_compatibility.cc (revision 0)
@@ -0,0 +1,89 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/// \file tests/core/point_set_compatibility.cc
+/// \brief Tests on the compatibility of some point sites with some
+/// point sets (and their iterators).
+
+#include <mln/core/point2d.hh>
+
+#include <mln/core/p_array.hh>
+#include <mln/core/graph_psite.hh>
+#include <mln/core/p_graph_piter.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ /*--------------------------------------------------------.
+ | Compatibility of mln::graph_psite with mln::p_array and |
+ | mln::p_array_piter. |
+ `--------------------------------------------------------*/
+
+ // Graph.
+
+ // Points associated to nodes.
+ std::vector<point2d> points;
+ points.push_back(make::point2d(0,0)); // Point associated to node 0.
+ points.push_back(make::point2d(2,2)); // Point associated to node 1.
+ points.push_back(make::point2d(0,4)); // Point associated to node 2.
+ points.push_back(make::point2d(4,3)); // Point associated to node 3.
+ points.push_back(make::point2d(4,4)); // Point associated to node 4.
+
+ // Edges.
+ util::graph<point2d> g;
+ // Populate the graph with nodes.
+ for (unsigned i = 0; i < points.size(); ++i)
+ g.add_node (points[i]);
+ // Populate the graph with edges.
+ g.add_edge(0, 1);
+ g.add_edge(1, 2);
+ g.add_edge(1, 3);
+ g.add_edge(3, 4);
+ g.add_edge(4, 2);
+
+
+ // Graph point set.
+ p_graph<point2d> pg(g);
+
+
+ // Array of graph point sites.
+ typedef graph_psite<point2d> gpsite_t;
+ p_array<gpsite_t> pa;
+
+
+ // Tests: copying all psites from PG to PA.
+ p_graph_fwd_piter_<point2d> p(pg);
+ for_all (p)
+ pa.append (p);
+
+ // Test: create and use an iterator over PA.
+ p_array_fwd_piter_<gpsite_t> p2(pa);
+ for_all (p2)
+ std::cout << p2 << std::endl;
+}
Index: tests/core/Makefile.am
--- tests/core/Makefile.am (revision 1772)
+++ tests/core/Makefile.am (working copy)
@@ -22,6 +22,7 @@
p_queue \
p_queue_fast \
p_runs \
+ point_set_compatibility \
rle_image \
sparse_image \
t_image \
@@ -46,6 +47,7 @@
p_queue_SOURCES = p_priority_queue_fast.cc
p_queue_fast_SOURCES = p_priority_queue_fast.cc
p_runs_SOURCES = p_runs.cc
+point_set_compatibility_SOURCES = point_set_compatibility.cc
rle_image_SOURCES = rle_image.cc
sparse_image_SOURCES = sparse_image.cc
t_image_SOURCES = t_image.cc