URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-23 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Update util tests subdirectory.
* tests/branch_iter.cc: Remove.
* tests/util/branch_iter.cc: New.
* tests/tree.cc: Remove.
* tests/util/tree.cc: New.
* tests/tree_delete_node.cc: Remove.
* tests/util/tree_delete_node.cc: New.
* tests/tree_fast.cc: Remove.
* tests/util/tree_fast.cc: New.
* tests/tree_fast_to_image.cc: Remove.
* tests/util/tree_fast_to_image.cc: New.
* tests/tree_to_image.cc: Remove.
* tests/util/tree_to_image.cc: New.
* tests/util_ordpair.cc: Remove.
* tests/util/util_ordpair.cc: New.
* tests/util/Makefile.am: Update somes tests.
* tests/level/fill.cc: Erase comment header.
---
level/fill.cc | 21 ------
util/Makefile.am | 10 +++
util/branch_iter.cc | 83 ++++++++++++++++++++++++++
util/tree.cc | 62 +++++++++++++++++++
util/tree_delete_node.cc | 69 +++++++++++++++++++++
util/tree_fast.cc | 61 +++++++++++++++++++
util/tree_fast_to_image.cc | 142 +++++++++++++++++++++++++++++++++++++++++++++
util/tree_to_image.cc | 136 +++++++++++++++++++++++++++++++++++++++++++
util/util_ordpair.cc | 48 +++++++++++++++
9 files changed, 611 insertions(+), 21 deletions(-)
Index: trunk/milena/tests/util_ordpair.cc (deleted)
===================================================================
Index: trunk/milena/tests/tree.cc (deleted)
===================================================================
Index: trunk/milena/tests/tree_delete_node.cc (deleted)
===================================================================
Index: trunk/milena/tests/tree_fast.cc (deleted)
===================================================================
Index: trunk/milena/tests/branch_iter.cc (deleted)
===================================================================
Index: trunk/milena/tests/tree_fast_to_image.cc (deleted)
===================================================================
Index: trunk/milena/tests/tree_to_image.cc (deleted)
===================================================================
Index: trunk/milena/tests/level/fill.cc
===================================================================
--- trunk/milena/tests/level/fill.cc (revision 1528)
+++ trunk/milena/tests/level/fill.cc (revision 1529)
@@ -34,10 +34,6 @@
#include <mln/core/sub_image.hh>
#include <mln/level/fill.hh>
-#include <mln/debug/println.hh>
-//#include <mln/value/props.hh>
-
-
int main()
{
using namespace mln;
@@ -54,23 +50,6 @@
box_fwd_piter_<point2d> p(ima.domain());
for_all (p)
mln_assertion (ima(p) == u);
-
}
-// {
-// const unsigned size = 10000;
-// image2d<unsigned char> ima(size, size);
-// for (unsigned i = 0; i < 5; ++i)
-// level::fill(ima, uc);
-// box_fwd_piter_<point2d> p(ima.domain());
-// for_all (p)
-// mln_assertion (ima(p) == uc);
-// }
-
-// {
-// // do *not* compile so that's great since ima is not mutable
-// sub_image< const image2d<int>, box2d > ima;
-// level::fill(ima, 0);
-// }
-
}
Index: trunk/milena/tests/util/tree_fast.cc
===================================================================
--- trunk/milena/tests/util/tree_fast.cc (revision 0)
+++ trunk/milena/tests/util/tree_fast.cc (revision 1529)
@@ -0,0 +1,61 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// 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/util/tree_fast.cc
+ *
+ * \brief test of mln::util::tree_fast
+ *
+ */
+
+#include <mln/util/tree_fast.hh>
+
+int main ()
+{
+ using namespace mln;
+
+ unsigned elt1 = 1;
+ unsigned elt2 = 2;
+ unsigned elt3 = 3;
+ unsigned elt4 = 4;
+ unsigned elt5 = 5;
+ unsigned elt6= 42;
+
+ util::tree_fast<unsigned> tree_fast(elt1);
+ mln_assertion(tree_fast.has (elt1));
+ tree_fast.add_child(tree_fast.search(elt1), elt2);
+ mln_assertion(tree_fast.has (elt2));
+ tree_fast.add_child(tree_fast.search(elt1), elt3);
+ mln_assertion(tree_fast.has (elt3));
+ tree_fast.add_child(tree_fast.search(elt2), elt4);
+ mln_assertion(tree_fast.has (elt4));
+ tree_fast.add_child(tree_fast.search(elt2), elt5);
+ mln_assertion(tree_fast.has (elt5));
+ tree_fast.add_parent(elt6);
+ mln_assertion(tree_fast.has (elt6));
+ mln_assertion(tree_fast.search(elt6) == tree_fast.root_);
+}
Index: trunk/milena/tests/util/util_ordpair.cc
===================================================================
--- trunk/milena/tests/util/util_ordpair.cc (revision 0)
+++ trunk/milena/tests/util/util_ordpair.cc (revision 1529)
@@ -0,0 +1,48 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// 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 util/ordpair.cc
+ *
+ * \brief Tests on mln::util::ordpair.
+ */
+
+#include <mln/core/point2d.hh>
+#include <mln/util/ordpair.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ point2d p1(5,6), p2(5,7), p3(4,2);
+
+ mln_assertion(util::ordpair (p2, p1) == util::ordpair (p1, p2));
+ mln_assertion(util::ordpair (p1, p3) < util::ordpair (p1, p2));
+ mln_assertion(util::ordpair (p1, p2) <= util::ordpair (p1, p2));
+ mln_assertion(util::ordpair (p1, p3) <= util::ordpair (p1, p2));
+}
Index: trunk/milena/tests/util/tree.cc
===================================================================
--- trunk/milena/tests/util/tree.cc (revision 0)
+++ trunk/milena/tests/util/tree.cc (revision 1529)
@@ -0,0 +1,62 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// 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/util/tree.cc
+ *
+ * \brief test of mln::util::tree
+ *
+ */
+
+#include <mln/util/tree.hh>
+
+int main ()
+{
+ using namespace mln;
+
+ unsigned elt1 = 1;
+ unsigned elt2 = 2;
+ unsigned elt3 = 3;
+ unsigned elt4 = 4;
+ unsigned elt5 = 5;
+ unsigned elt6= 42;
+
+ util::node<unsigned> node(elt1);
+ util::node<unsigned>* node2 = node.add_child(elt2);
+ node.add_child(elt3);
+ mln_assertion(node2);
+ node2->add_child(elt4);
+ node2->add_child(elt5);
+ util::node<unsigned>* node3 = node.search(elt4);
+ mln_assertion(node3);
+ node3 = node2->search(elt1);
+ mln_assertion(!node3);
+ util::tree<unsigned>* tre = new util::tree<unsigned>(&node);
+ mln_assertion(tre);
+ tre->add_tree_up(elt6);
+ mln_assertion (tre->check_consistency());
+}
Index: trunk/milena/tests/util/branch_iter.cc
===================================================================
--- trunk/milena/tests/util/branch_iter.cc (revision 0)
+++ trunk/milena/tests/util/branch_iter.cc (revision 1529)
@@ -0,0 +1,83 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// 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/util/branch_iter.cc
+ *
+ * \brief test of mln::util::branch_iter
+ *
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/util/tree.hh>
+#include <mln/util/branch_iter.hh>
+
+int main()
+{
+ using namespace mln;
+
+ util::node<int> n(11);
+ util::tree<int> t(&n);
+ util::node<int>* f = n.add_child(21);
+ util::node<int>* g = f->add_child(31);
+
+ f->add_child(32);
+
g->add_child(41)->add_child(51)->add_child(61)->add_child(71)->add_child(81)->add_child(91);
+ g->add_child(42);
+ f->add_child(33);
+ f->add_child(34);
+ n.add_child(22);
+
+ util::branch<int> b(t, n);
+
+ std::vector< util::node<int>* >::iterator it;
+ util::branch_iter<int> p(b);
+
+ int prev;
+ int current;
+ for(p.start(), prev = util::node<int>(p).elt(), p.next();
+ p.is_valid();
+ prev = util::node<int>(p).elt(), p.next())
+ {
+ current = util::node<int>(p).elt ();
+
+ // children
+ if (prev + 10 == current)
+ continue;
+
+ // brother
+ if (prev + 1 == current)
+ continue;
+
+ // parent
+ if (prev > current)
+ continue;
+
+ mln_assertion (false);
+ }
+
+}
Index: trunk/milena/tests/util/tree_fast_to_image.cc
===================================================================
--- trunk/milena/tests/util/tree_fast_to_image.cc (revision 0)
+++ trunk/milena/tests/util/tree_fast_to_image.cc (revision 1529)
@@ -0,0 +1,142 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// 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/tree_fast_to_image.cc
+ *
+ * \brief test of mln::util::tree_fast_to_image
+ *
+ */
+
+#include <mln/core/contract.hh>
+#include <mln/core/image2d.hh>
+#include <mln/core/p_set.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/level/stretch.hh>
+#include <mln/io/pgm/save.hh>
+#include <vector>
+#include <mln/util/tree_fast_to_image.hh>
+#include <mln/util/tree_fast.hh>
+
+template <typename P, typename V>
+struct fllt_node
+{
+ V value;
+ mln::p_set<P> points;
+ mln::p_set<P> holes;
+};
+
+
+template <typename P, typename V>
+bool operator==(const mln::p_set<P>& lhs, const mln::p_set<P>& rhs)
+{
+ std::size_t n = lhs.npoints ();
+ mln::p_set<P> tmp;
+
+ if (n != rhs.npoints ())
+ return false;
+
+// for (std::size_t i = 0; i < n; ++i)
+// if ()
+
+}
+
+template <typename P, typename V>
+bool operator==(const struct fllt_node<P,V>& lhs, const struct
fllt_node<P,V>& rhs)
+{
+ if (lhs.value != rhs.value)
+ return false;
+
+ /// FIXME
+
+ if (!(lhs.points == rhs.points))
+ return false;
+
+ if (!(lhs.holes == rhs.holes))
+ return false;
+
+ return true;
+}
+
+int main (void)
+{
+ using namespace mln;
+ using value::int_u8;
+
+ typedef p_set<point2d > I;
+ typedef fllt_node<point2d, int_u8> T;
+
+ T s1;
+ T s2;
+ T s3;
+ T s4;
+ T s5;
+ T s6;
+ T s7;
+
+ for (int i = 0; i < 100; ++i)
+ for (int j = 0; j < 100; ++j)
+ s1.points.insert(point2d(i, j));
+ s1.value = 60;
+ for (int i = 200; i < 300; ++i)
+ for (int j = 0; j < 100; ++j)
+ s2.points.insert(point2d(i, j));
+ s2.value = 100;
+ for (int i = 0; i < 100; ++i)
+ for (int j = 0; j < 100; ++j)
+ s3.points.insert(point2d(i, j));
+ s3.value = 110;
+ for (int i = 260; i < 290; ++i)
+ for (int j = 0; j < 50; ++j)
+ s4.points.insert(point2d(i, j));
+ s4.value = 170;
+ for (int i = 200; i < 210; ++i)
+ for (int j = 0; j < 50; ++j)
+ s5.points.insert(point2d(i, j));
+ s5.value = 180;
+ for (int i = 270; i < 280; ++i)
+ for (int j = 50; j < 60; ++j)
+ s6.points.insert(point2d(i, j));
+ s6.value = 210;
+ for (int i = 0; i < 300; ++i)
+ for (int j = 0; j < 200; ++j)
+ s7.points.insert(point2d(i, j));
+ s7.value = 10;
+
+ util::tree_fast<T> tree(s1);
+ tree.add_child(tree.root_, s2);
+ tree.add_child(tree.search(s1), s3);
+ tree.add_child(tree.search(s2), s4);
+ tree.add_child(tree.search(s2), s5);
+ tree.add_child(tree.search(s4), s6);
+ tree.add_parent(s7);
+ image2d<int_u8> out (300,300);
+ util::tree_fast_to_image(tree, out);
+ io::pgm::save(out, "out.pgm");
+ std::cout << "out.pgm generate"
+ << std::endl;
+}
Index: trunk/milena/tests/util/tree_to_image.cc
===================================================================
--- trunk/milena/tests/util/tree_to_image.cc (revision 0)
+++ trunk/milena/tests/util/tree_to_image.cc (revision 1529)
@@ -0,0 +1,136 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// 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/tree_to_image.cc
+ *
+ * \brief test of mln::util::tree_to_image
+ *
+ */
+
+#include <mln/util/tree.hh>
+#include <mln/core/contract.hh>
+#include <mln/core/image2d.hh>
+#include <mln/core/p_set.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/level/stretch.hh>
+#include <mln/level/fill.hh>
+#include <mln/level/compare.hh>
+#include <mln/io/pgm/save.hh>
+#include <vector>
+#include <mln/util/tree_to_image.hh>
+#include <mln/debug/println.hh>
+
+template <typename P, typename V>
+struct fllt_node
+{
+ V value;
+ mln::p_set<P> points;
+ mln::p_set<P> holes;
+};
+
+
+int main (void)
+{
+ using namespace mln;
+ using value::int_u8;
+
+ typedef fllt_node<point2d , int_u8> I;
+
+ image2d<int_u8> output (16, 16);
+
+ I s1;
+ I s2;
+ I s3;
+ I s4;
+ I s5;
+ I s6;
+ I s7;
+
+ for (int i = 0; i < 4; ++i)
+ for (int j = 0; j < 4; ++j)
+ s1.points.insert(point2d(i, j));
+ s1.value = 60;
+ for (int i = 8; i < 16; ++i)
+ for (int j = 0; j < 4; ++j)
+ s2.points.insert(point2d(i, j));
+ s1.value = 100;
+ for (int i = 0; i < 4; ++i)
+ for (int j = 0; j < 4; ++j)
+ s3.points.insert(point2d(i, j));
+ s3.value = 110;
+ for (int i = 10; i < 12; ++i)
+ for (int j = 0; j < 2; ++j)
+ s4.points.insert(point2d(i, j));
+ s4.value = 170;
+ for (int i = 8; i < 14; ++i)
+ for (int j = 0; j < 2; ++j)
+ s5.points.insert(point2d(i, j));
+ s5.value = 180;
+ for (int i = 13; i < 15; ++i)
+ for (int j = 2; j < 4; ++j)
+ s6.points.insert(point2d(i, j));
+ s6.value = 210;
+ for (int i = 0; i < 16; ++i)
+ for (int j = 0; j < 8; ++j)
+ s7.points.insert(point2d(i, j));
+ s7.value = 10;
+
+ util::node<I> node(s1);
+ node.add_child(s2);
+ node.add_child(s3);
+ node.add_child(s4);
+ node.add_child(s5);
+ node.add_child(s6);
+ util::tree<I> tree (&node);
+ tree.add_tree_up(s7);
+ util::tree_to_image(tree, output);
+
+ int_u8 vs[16][16] = {
+
+ {110, 110, 110, 110, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
+ {110, 110, 110, 110, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
+ {110, 110, 110, 110, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
+ {110, 110, 110, 110, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
+ { 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
+ { 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
+ { 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
+ { 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
+ {180, 180, 16, 16, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
+ {180, 180, 16, 16, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
+ {180, 180, 16, 16, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
+ {180, 180, 16, 16, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
+ {180, 180, 16, 16, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
+ {180, 180, 210, 210, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
+ { 16, 16, 210, 210, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0},
+ { 16, 16, 16, 16, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0}
+
+ };
+
+ image2d<int_u8> ref (make::image2d(vs));
+ mln_assertion(ref == output);
+}
Index: trunk/milena/tests/util/Makefile.am
===================================================================
--- trunk/milena/tests/util/Makefile.am (revision 1528)
+++ trunk/milena/tests/util/Makefile.am (revision 1529)
@@ -1,3 +1,13 @@
## Process this file through Automake to create Makefile.in -*- Makefile -*-
+check_PROGRAMS = \
+branch_iter \
+branch_iter_ind \
+graph
+
+branch_iter_SOURCES = branch_iter.cc
+branch_iter_ind_SOURCES = branch_iter_ind.cc
+graph_SOURCES = graph.cc
+
+TESTS = $(check_PROGRAMS)
include $(top_srcdir)/milena/tests/tests.mk
Index: trunk/milena/tests/util/tree_delete_node.cc
===================================================================
--- trunk/milena/tests/util/tree_delete_node.cc (revision 0)
+++ trunk/milena/tests/util/tree_delete_node.cc (revision 1529)
@@ -0,0 +1,69 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// 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/tree_delete_node.cc
+ *
+ * \brief test of mln::util::tree
+ *
+ */
+
+#include <mln/util/tree.hh>
+#include <mln/core/contract.hh>
+
+int main (void)
+{
+ using namespace mln;
+
+ unsigned elt1 = 1;
+ unsigned elt2 = 2;
+ unsigned elt3 = 3;
+ unsigned elt4 = 4;
+ unsigned elt5 = 5;
+ unsigned elt6= 42;
+
+ util::node<unsigned> node(elt1);
+ util::node<unsigned>* node2 = node.add_child(elt2);
+ node.add_child(elt3);
+// util::node<unsigned>* node2 = node.search(elt2);
+ mln_assertion(node2);
+ node2->add_child(elt4);
+ node2->add_child(elt5);
+ util::node<unsigned>* node3 = node.search(elt4);
+ mln_assertion(node3);
+ node3 = node2->search(elt1);
+ mln_assertion(!node3);
+ util::tree<unsigned>* tre = new util::tree<unsigned>(&node);
+ mln_assertion(tre);
+ tre->add_tree_up(elt6);
+ mln_assertion (tre->check_consistency());
+ std::cout << "before delete" << std::endl;
+ node.print (0);
+ std::cout << "after delete" << std::endl;
+ node2->delete_node();
+ node.print (0);
+}