URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-12-03 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Add tests for mln/accu.
* tests/accu/bbox.cc: New.
* tests/accu/compute.cc: New.
* tests/accu/count.cc: New.
* tests/accu/histo.cc: New.
* tests/accu/max.cc: New.
* tests/accu/max_h.cc: New.
* tests/accu/mean.cc: New.
* tests/accu/median.cc: New.
* tests/accu/min_h.cc: New.
* tests/accu/min_max.cc: New.
* tests/accu/pair.cc: New.
---
bbox.cc | 50 +++++++++++++++++++++++++++++++++++++++++++
compute.cc | 55 +++++++++++++++++++++++++++++++++++++++++++++++
count.cc | 54 +++++++++++++++++++++++++++++++++++++++++++++++
histo.cc | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
max.cc | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
max_h.cc | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
mean.cc | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
median.cc | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
min_h.cc | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
min_max.cc | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
pair.cc | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
11 files changed, 691 insertions(+)
Index: trunk/milena/tests/accu/pair.cc
===================================================================
--- trunk/milena/tests/accu/pair.cc (revision 0)
+++ trunk/milena/tests/accu/pair.cc (revision 1580)
@@ -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/accu/mean.cc
+ *
+ * \brief Tests on mln::accu::mean.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/value/int_u8.hh>
+
+#include <mln/accu/mean.hh>
+
+int main()
+{
+ using namespace mln;
+
+ {
+ accu::pair_<accu::mean<int>, accu::max<int> > mean;
+
+ mean.take(10);
+ mean.take(9);
+ mean.take(8);
+ mean.take(7);
+ mean.take(6);
+ mean.take(5);
+ mean.take(4);
+ mean.take(3);
+ mean.take(2);
+ mean.take(1);
+ mean.take(0);
+
+ mln_assertion(mean.to_result() == 5);
+ }
+
+ {
+ mln_accu_with_(accu::mean, int) mean;
+
+ mean.take(10);
+ mean.take(8);
+ mean.take(0);
+
+ mln_assertion(mean.to_result() == 6);
+ }
+}
Index: trunk/milena/tests/accu/compute.cc
===================================================================
--- trunk/milena/tests/accu/compute.cc (revision 0)
+++ trunk/milena/tests/accu/compute.cc (revision 1580)
@@ -0,0 +1,55 @@
+// 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/accu/compute.cc
+ *
+ * \brief Tests on mln::accu::compute.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/value/int_u8.hh>
+
+#include <mln/accu/compute.hh>
+#include <mln/level/compute.hh>
+
+#include <mln/accu/min.hh>
+
+int main()
+{
+ using namespace mln;
+ using typename value::int_u8;
+
+ // FIXME : make this test compile
+// int_u8 vs[3][3] = { {9,8,7},
+// {6,5,4},
+// {3,2,1} };
+
+// image2d<int_u8> ima = make::image2d(vs);
+// int a = accu::compute<accu::min>(ima);
+
+// std::cout << a << std::endl;
+}
Index: trunk/milena/tests/accu/max_h.cc
===================================================================
--- trunk/milena/tests/accu/max_h.cc (revision 0)
+++ trunk/milena/tests/accu/max_h.cc (revision 1580)
@@ -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/accu/max_h.cc
+ *
+ * \brief Tests on mln::accu::max_h.
+ */
+
+#include <mln/value/int_u8.hh>
+#include <mln/accu/max_h.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using namespace mln::value;
+
+ accu::max_h< set<int_u8> > a;
+
+ a.take(1);
+ a.take(1);
+ a.take(1);
+
+ a.take(2);
+ a.take(2);
+ a.take(2);
+ a.take(2);
+ a.take(2);
+ a.take(2);
+
+ a.take(234);
+ a.take(234);
+ a.take(234);
+ a.take(234);
+ a.take(234);
+ a.take(234);
+ mln_assertion(a.to_result() == 234);
+}
Index: trunk/milena/tests/accu/median.cc
===================================================================
--- trunk/milena/tests/accu/median.cc (revision 0)
+++ trunk/milena/tests/accu/median.cc (revision 1580)
@@ -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/accu/median.cc
+ *
+ * \brief Tests on mln::accu::median.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/value/int_u8.hh>
+
+#include <mln/accu/median.hh>
+
+int main()
+{
+ using namespace mln;
+
+ {
+ accu::median< value::set<value::int_u8> > med;
+
+ med.take(10);
+ med.take(9);
+ med.take(8);
+ med.take(7);
+ med.take(6);
+ med.take(5);
+ med.take(4);
+ med.take(3);
+ med.take(2);
+ med.take(1);
+ med.take(0);
+
+ mln_assertion(med.to_result() == 5);
+ }
+
+ {
+ accu::median< value::set<value::int_u8> > med;
+
+ med.take(10);
+ med.take(7);
+ med.take(0);
+
+ mln_assertion(med.to_result() == 7);
+ }
+}
Index: trunk/milena/tests/accu/mean.cc
===================================================================
--- trunk/milena/tests/accu/mean.cc (revision 0)
+++ trunk/milena/tests/accu/mean.cc (revision 1580)
@@ -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/accu/mean.cc
+ *
+ * \brief Tests on mln::accu::mean.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/value/int_u8.hh>
+
+#include <mln/accu/mean.hh>
+
+int main()
+{
+ using namespace mln;
+
+ {
+ mln_accu_with_(accu::mean, int) mean;
+
+ mean.take(10);
+ mean.take(9);
+ mean.take(8);
+ mean.take(7);
+ mean.take(6);
+ mean.take(5);
+ mean.take(4);
+ mean.take(3);
+ mean.take(2);
+ mean.take(1);
+ mean.take(0);
+
+ mln_assertion(mean.to_result() == 5);
+ }
+
+ {
+ mln_accu_with_(accu::mean, int) mean;
+
+ mean.take(10);
+ mean.take(8);
+ mean.take(0);
+
+ mln_assertion(mean.to_result() == 6);
+ }
+}
Index: trunk/milena/tests/accu/max.cc
===================================================================
--- trunk/milena/tests/accu/max.cc (revision 0)
+++ trunk/milena/tests/accu/max.cc (revision 1580)
@@ -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/accu/max.cc
+ *
+ * \brief Tests on mln::accu::max.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/debug/iota.hh>
+
+#include <mln/accu/nil.hh>
+#include <mln/accu/max.hh>
+#include <mln/accu/p.hh>
+#include <mln/accu/v.hh>
+#include <mln/accu/compute.hh>
+
+#include <mln/level/compute.hh>
+
+
+int main()
+{
+ using namespace mln;
+ image2d<int> ima(3, 3);
+ debug::iota(ima);
+ mln_assertion(level::compute< accu::max >(ima) == 9);
+ mln_assertion(level::compute< accu::max_<int> >(ima) == 9);
+
+ accu::compute< accu::nil >(ima); // No-op.
+
+ // FIXME : what's the difference between
+ // accu::compute< accu::max >(ima);
+
+ mln_assertion( accu::compute< accu::val<accu::max> >(ima) == 9);
+
+// std::cout << accu::compute< accu::max >(ima)
+// << std::endl;
+}
Index: trunk/milena/tests/accu/histo.cc
===================================================================
--- trunk/milena/tests/accu/histo.cc (revision 0)
+++ trunk/milena/tests/accu/histo.cc (revision 1580)
@@ -0,0 +1,70 @@
+// 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/accu/histo.cc
+ *
+ * \brief Tests on mln::accu::histo.
+ */
+
+#include <mln/value/int_u8.hh>
+
+#include <mln/accu/histo.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using namespace mln::value;
+
+ accu::histo< set<int_u8> > a;
+
+ a.take(1);
+ a.take(1);
+ a.take(1);
+
+
+ a.take(2);
+ a.take(2);
+ a.take(2);
+
+ a.take(234);
+ a.take(234);
+ a.take(234);
+ a.take(234);
+ a.take(234);
+ a.take(234);
+
+ mln_assertion(a[1] == 3);
+ mln_assertion(a[2] == 3);
+ mln_assertion(a[234] == 6);
+
+ a.untake(234);
+ mln_assertion(a[234] == 5);
+
+ // Abort
+ // a.untake(235);
+}
Index: trunk/milena/tests/accu/min_max.cc
===================================================================
--- trunk/milena/tests/accu/min_max.cc (revision 0)
+++ trunk/milena/tests/accu/min_max.cc (revision 1580)
@@ -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/accu/min_max.cc
+ *
+ * \brief Tests on mln::accu::min_max.
+ */
+
+// FIXME : This test doesn't compile without this include.
+#include <mln/value/builtin/integers.hh>
+
+#include <mln/accu/min_max.hh>
+
+int main()
+{
+ using namespace mln;
+
+ {
+ mln_accu_with_(accu::min_max, int) accu;
+
+ accu.take(7);
+
+ mln_assertion(accu.to_result().first == 7);
+ mln_assertion(accu.to_result().second == 7);
+ }
+
+ {
+ mln_accu_with_(accu::min_max, int) accu;
+
+ accu.take(10);
+ accu.take(9);
+ accu.take(8);
+ accu.take(7);
+ accu.take(6);
+ accu.take(5);
+ accu.take(4);
+ accu.take(3);
+ accu.take(2);
+ accu.take(1);
+ accu.take(0);
+
+ mln_assertion(accu.to_result().first == 0);
+ mln_assertion(accu.to_result().second == 10);
+ }
+}
Index: trunk/milena/tests/accu/count.cc
===================================================================
--- trunk/milena/tests/accu/count.cc (revision 0)
+++ trunk/milena/tests/accu/count.cc (revision 1580)
@@ -0,0 +1,54 @@
+// 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/accu/count.cc
+ *
+ * \brief Tests on mln::accu::count.
+ */
+
+#include <mln/value/int_u8.hh>
+
+#include <mln/accu/count.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ {
+ accu::count_<value::int_u8> accu;
+ mln_assertion(accu.to_result() == 0);
+ }
+
+ {
+ accu::count_<value::int_u8> accu;
+ for (int i = 0; i < 200; i++)
+ accu.take(i);
+ mln_assertion(accu.to_result() == 200);
+ }
+
+}
Index: trunk/milena/tests/accu/min_h.cc
===================================================================
--- trunk/milena/tests/accu/min_h.cc (revision 0)
+++ trunk/milena/tests/accu/min_h.cc (revision 1580)
@@ -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/accu/min_h.cc
+ *
+ * \brief Tests on mln::accu::min_h.
+ */
+
+#include <mln/value/int_u8.hh>
+#include <mln/accu/min_h.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using namespace mln::value;
+
+ accu::min_h< set<int_u8> > a;
+
+ a.take(42);
+ a.take(42);
+ a.take(42);
+
+ a.take(200);
+ a.take(200);
+ a.take(200);
+ a.take(200);
+ a.take(200);
+ a.take(200);
+
+ a.take(234);
+ a.take(234);
+ a.take(234);
+ a.take(234);
+ a.take(234);
+ a.take(234);
+ mln_assertion(a.to_result() == 42);
+}
Index: trunk/milena/tests/accu/bbox.cc
===================================================================
--- trunk/milena/tests/accu/bbox.cc (revision 0)
+++ trunk/milena/tests/accu/bbox.cc (revision 1580)
@@ -0,0 +1,50 @@
+// 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/accu/nil.cc
+ *
+ * \brief Tests on mln::accu::nil.
+ */
+
+
+#include <mln/core/point2d.hh>
+#include <mln/core/box2d.hh>
+
+#include <mln/accu/bbox.hh>
+
+int main()
+{
+ using namespace mln;
+ accu::bbox<point2d> accu;
+
+ accu.take_as_init(make::point2d(0,0));
+ accu.take(make::point2d(0,5));
+ accu.take(make::point2d(5,0));
+ accu.take(make::point2d(5,5));
+
+ mln_assertion(accu.to_result() == make::box2d(0,0,5,5));
+}
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-30 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Add full tests for logical subdirectory.
* tests/logical/and_full.cc,
* tests/logical/and_not_full.cc,
* tests/logical/not_full.cc,
* tests/logical/or_full.cc: New full tests for logical.
---
and_full.cc | 225 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
and_not_full.cc | 225 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
not_full.cc | 187 ++++++++++++++++++++++++++++++++++++++++++++++
or_full.cc | 225 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 862 insertions(+)
Index: trunk/milena/tests/logical/or_full.cc
===================================================================
--- trunk/milena/tests/logical/or_full.cc (revision 0)
+++ trunk/milena/tests/logical/or_full.cc (revision 1576)
@@ -0,0 +1,225 @@
+// 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/logical/or_full.cc
+ *
+ * \brief Tests on mln::logical::or.
+ */
+
+#include <mln/core/image1d.hh>
+#include <mln/core/image2d.hh>
+#include <mln/core/image3d.hh>
+#include <mln/logical/or.hh>
+#include <mln/level/compare.hh>
+#include <mln/level/apply.hh>
+#include <mln/debug/iota.hh>
+#include <mln/debug/println.hh>
+#include <mln/core/concept/function.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/value/int_u16.hh>
+#include <mln/value/int_s8.hh>
+#include <mln/value/int_s16.hh>
+
+#include <mln/literal/zero.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ template <typename V, typename T = V, typename R = T>
+ struct chess_value_t : public Function_v2v< chess_value_t<V,T,R> >
+ {
+ chess_value_t (V mod) : mod_ (mod) {}
+
+ typedef R result;
+ R operator()(const V& v) const
+ {
+ return v % mod_ ? v : literal::zero;
+ }
+
+ V mod_;
+ };
+
+ }
+
+ }
+
+ template <typename I, typename J>
+ void
+ chck(Image<I>& ima1_, const Image<J>& ima2_)
+ {
+ const I& ima1 = exact(ima1_);
+ I& ima3 = exact(ima1_);
+ const J& ima2 = exact(ima2_);
+ mln_concrete(I) log = logical::or_(ima1, ima2);
+
+ mln_assertion (ima2.domain () >= ima1.domain ());
+ mln_piter(I) p (ima1.domain ());
+ for_all(p)
+ mln_assertion ((ima1(p) || ima2(p)) == log(p));
+ logical::or_inplace(ima3, ima2);
+ for_all(p)
+ mln_assertion (ima3(p) == log(p));
+ }
+
+
+ template <typename I, typename J>
+ void
+ chk1d(unsigned col,
+ unsigned mod1, unsigned mod2)
+ {
+ image1d<I> ima1 (col);
+ image1d<J> ima2 (col);
+
+ debug::iota(ima1);
+ debug::iota(ima2);
+
+ level::apply(ima1, fun::v2v::chess_value_t<I>(mod1) );
+ level::apply(ima2, fun::v2v::chess_value_t<J>(mod2) );
+
+ chck(ima1, ima2);
+ }
+
+
+ template <typename I, typename J>
+ void
+ chk2d(unsigned row, unsigned col,
+ unsigned mod1, unsigned mod2)
+ {
+ image2d<I> ima1 (row, col);
+ image2d<J> ima2 (row, col);
+
+ debug::iota(ima1);
+ debug::iota(ima2);
+
+ level::apply(ima1, fun::v2v::chess_value_t<I>(mod1) );
+ level::apply(ima2, fun::v2v::chess_value_t<J>(mod2) );
+
+ chck(ima1, ima2);
+ }
+
+
+ template <typename I, typename J>
+ void
+ chk3d(unsigned sli, unsigned row, unsigned col,
+ unsigned mod1, unsigned mod2)
+ {
+ image3d<I> ima1 (sli, row, col);
+ image3d<J> ima2 (sli, row, col);
+
+ debug::iota(ima1);
+ debug::iota(ima2);
+
+ level::apply(ima1, fun::v2v::chess_value_t<I>(mod1) );
+ level::apply(ima2, fun::v2v::chess_value_t<J>(mod2) );
+
+ chck(ima1, ima2);
+ }
+
+
+}
+
+
+
+
+
+int main()
+{
+ using namespace mln;
+
+ unsigned max_mod1 = 8;
+ unsigned max_mod2 = 8;
+ unsigned max_cols = 16;
+ unsigned max_rows = 8;
+ unsigned max_slis = 2;
+
+ std::cerr << "Tests logical::or" << std::endl;
+
+ (std::cerr << "in 1d ... ").flush ();
+ {
+ for (unsigned i = 1; i < max_mod1; ++i)
+ for (unsigned j = 1; j < max_mod2; ++j)
+ for (unsigned k = 1; k < max_cols; ++k)
+ {
+ chk1d<int, int>(k, i, j);
+ chk1d<unsigned, unsigned>(k, i, j);
+ chk1d<value::int_s8, value::int_s8>(k, i, j);
+ chk1d<int, unsigned>(k, i, j);
+ chk1d<unsigned, value::int_u8>(k, i, j);
+ chk1d<int, value::int_s8>(k, i, j);
+ chk1d<unsigned, value::int_u16>(k, i, j);
+ chk1d<int, value::int_s16>(k, i, j);
+ }
+ }
+ std::cerr << "OK" << std::endl;
+
+ (std::cerr << "in 2d ... ").flush ();
+ {
+ for (unsigned i = 1; i < max_mod1; ++i)
+ for (unsigned j = 1; j < max_mod2; ++j)
+ for (unsigned k = 1; k < max_cols; ++k)
+ for (unsigned l = 1; l < max_rows; ++l)
+ {
+ chk2d<int, int>(l ,k, i, j);
+ chk2d<unsigned, unsigned>(l ,k, i, j);
+ chk2d<value::int_s8, value::int_s8>(l ,k, i, j);
+ chk2d<int, unsigned>(l ,k, i, j);
+ chk2d<unsigned, value::int_u8>(l ,k, i, j);
+ chk2d<int, value::int_s8>(l ,k, i, j);
+ chk2d<unsigned, value::int_u16>(l ,k, i, j);
+ chk2d<int, value::int_s16>(l ,k, i, j);
+ }
+ }
+ std::cerr << "OK" << std::endl;
+
+ (std::cerr << "in 3d ... ").flush ();
+ {
+ for (unsigned i = 1; i < max_mod1; ++i)
+ for (unsigned j = 1; j < max_mod2; ++j)
+ for (unsigned k = 1; k < max_cols; ++k)
+ for (unsigned l = 1; l < max_rows; ++l)
+ for (unsigned m = 1; m < max_slis; ++m)
+ {
+ chk3d<int, int>(m, l ,k, i, j);
+ chk3d<unsigned, unsigned>(m, l ,k, i, j);
+ chk3d<value::int_s8, value::int_s8>(m, l ,k, i, j);
+ chk3d<int, unsigned>(m, l ,k, i, j);
+ chk3d<unsigned, value::int_u8>(m, l ,k, i, j);
+ chk3d<int, value::int_s8>(m, l ,k, i, j);
+ chk3d<unsigned, value::int_u16>(m, l ,k, i, j);
+ chk3d<int, value::int_s16>(m, l ,k, i, j);
+ }
+ }
+ std::cerr << "OK" << std::endl;
+
+}
Index: trunk/milena/tests/logical/not_full.cc
===================================================================
--- trunk/milena/tests/logical/not_full.cc (revision 0)
+++ trunk/milena/tests/logical/not_full.cc (revision 1576)
@@ -0,0 +1,187 @@
+// 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/logical/and_full.cc
+ *
+ * \brief Tests on mln::logical::and.
+ */
+
+#include <mln/core/image1d.hh>
+#include <mln/core/image2d.hh>
+#include <mln/core/image3d.hh>
+#include <mln/logical/not.hh>
+#include <mln/level/compare.hh>
+#include <mln/level/apply.hh>
+#include <mln/debug/iota.hh>
+#include <mln/debug/println.hh>
+#include <mln/core/concept/function.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/value/int_u16.hh>
+#include <mln/value/int_s8.hh>
+#include <mln/value/int_s16.hh>
+
+#include <mln/literal/zero.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ template <typename V, typename T = V, typename R = T>
+ struct chess_value_t : public Function_v2v< chess_value_t<V,T,R> >
+ {
+ chess_value_t (V mod) : mod_ (mod) {}
+
+ typedef R result;
+ R operator()(const V& v) const
+ {
+ return v % mod_ ? v : literal::zero;
+ }
+
+ V mod_;
+ };
+
+ }
+
+ }
+
+ template <typename I>
+ void
+ chck(Image<I>& ima_)
+ {
+ const I& ima = exact(ima_);
+ I& ima2 = exact(ima_);
+ mln_concrete(I) log = logical::not_(ima);
+
+ mln_piter(I) p (ima.domain ());
+ for_all(p)
+ mln_assertion (!ima(p) == log(p));
+ logical::not_inplace(ima2);
+ for_all(p)
+ mln_assertion (ima2(p) == log(p));
+ }
+
+
+ template <typename I>
+ void
+ chk1d(unsigned col, unsigned mod)
+ {
+ image1d<I> ima (col);
+ debug::iota(ima);
+ level::apply(ima, fun::v2v::chess_value_t<I>(mod) );
+
+ chck(ima);
+ }
+
+
+ template <typename I>
+ void
+ chk2d(unsigned row, unsigned col, unsigned mod)
+ {
+ image2d<I> ima (row, col);
+ debug::iota(ima);
+ level::apply(ima, fun::v2v::chess_value_t<I>(mod) );
+
+ chck(ima);
+ }
+
+
+ template <typename I>
+ void
+ chk3d(unsigned sli, unsigned row, unsigned col,
+ unsigned mod)
+ {
+ image3d<I> ima (sli, row, col);
+ debug::iota(ima);
+ level::apply(ima, fun::v2v::chess_value_t<I>(mod) );
+
+ chck(ima);
+ }
+
+}
+
+
+
+int main()
+{
+ using namespace mln;
+
+ unsigned max_mod = 64;
+ unsigned max_cols = 128;
+ unsigned max_rows = 4;
+ unsigned max_slis = 2;
+
+ std::cerr << "Tests logical::not" << std::endl;
+
+ (std::cerr << "in 1d ... ").flush ();
+ {
+ for (unsigned i = 1; i < max_mod; ++i)
+ for (unsigned j = 1; j < max_cols; ++j)
+ {
+ chk1d<int>(j, i);
+ chk1d<unsigned>(j, i);
+ chk1d<value::int_s8>(j, i);
+ chk1d<value::int_s16>(j, i);
+ }
+ }
+ std::cerr << "OK" << std::endl;
+
+ (std::cerr << "in 2d ... ").flush ();
+ {
+ for (unsigned i = 1; i < max_mod; ++i)
+ for (unsigned j = 1; j < max_rows; ++j)
+ for (unsigned k = 1; k < max_cols; ++k)
+ {
+ chk2d<int>(j, k, i);
+ chk2d<unsigned>(j, k, i);
+ chk2d<value::int_s8>(j, k, i);
+ chk2d<value::int_s16>(j, k, i);
+ }
+ }
+ std::cerr << "OK" << std::endl;
+
+ (std::cerr << "in 3d ... ").flush ();
+ {
+ for (unsigned i = 1; i < max_mod; ++i)
+ for (unsigned j = 1; j < max_slis; ++j)
+ for (unsigned k = 1; k < max_rows; ++k)
+ for (unsigned l = 1; l < max_cols; ++l)
+ {
+ chk3d<int>(j, k, l, i);
+ chk3d<unsigned>(j, k, l, i);
+ chk3d<value::int_s8>(j, k, l, i);
+ chk3d<value::int_s16>(j, k, l, i);
+ }
+ }
+ std::cerr << "OK" << std::endl;
+
+}
Index: trunk/milena/tests/logical/and_not_full.cc
===================================================================
--- trunk/milena/tests/logical/and_not_full.cc (revision 0)
+++ trunk/milena/tests/logical/and_not_full.cc (revision 1576)
@@ -0,0 +1,225 @@
+// 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/logical/and_not_full.cc
+ *
+ * \brief Tests on mln::logical::and.
+ */
+
+#include <mln/core/image1d.hh>
+#include <mln/core/image2d.hh>
+#include <mln/core/image3d.hh>
+#include <mln/logical/and_not.hh>
+#include <mln/level/compare.hh>
+#include <mln/level/apply.hh>
+#include <mln/debug/iota.hh>
+#include <mln/debug/println.hh>
+#include <mln/core/concept/function.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/value/int_u16.hh>
+#include <mln/value/int_s8.hh>
+#include <mln/value/int_s16.hh>
+
+#include <mln/literal/zero.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ template <typename V, typename T = V, typename R = T>
+ struct chess_value_t : public Function_v2v< chess_value_t<V,T,R> >
+ {
+ chess_value_t (V mod) : mod_ (mod) {}
+
+ typedef R result;
+ R operator()(const V& v) const
+ {
+ return v % mod_ ? v : literal::zero;
+ }
+
+ V mod_;
+ };
+
+ }
+
+ }
+
+ template <typename I, typename J>
+ void
+ chck(Image<I>& ima1_, const Image<J>& ima2_)
+ {
+ const I& ima1 = exact(ima1_);
+ I& ima3 = exact(ima1_);
+ const J& ima2 = exact(ima2_);
+ mln_concrete(I) log = logical::and_not(ima1, ima2);
+
+ mln_assertion (ima2.domain () >= ima1.domain ());
+ mln_piter(I) p (ima1.domain ());
+ for_all(p)
+ mln_assertion ((ima1(p) && !ima2(p)) == log(p));
+ logical::and_not_inplace(ima3, ima2);
+ for_all(p)
+ mln_assertion (ima3(p) == log(p));
+ }
+
+
+ template <typename I, typename J>
+ void
+ chk1d(unsigned col,
+ unsigned mod1, unsigned mod2)
+ {
+ image1d<I> ima1 (col);
+ image1d<J> ima2 (col);
+
+ debug::iota(ima1);
+ debug::iota(ima2);
+
+ level::apply(ima1, fun::v2v::chess_value_t<I>(mod1) );
+ level::apply(ima2, fun::v2v::chess_value_t<J>(mod2) );
+
+ chck(ima1, ima2);
+ }
+
+
+ template <typename I, typename J>
+ void
+ chk2d(unsigned row, unsigned col,
+ unsigned mod1, unsigned mod2)
+ {
+ image2d<I> ima1 (row, col);
+ image2d<J> ima2 (row, col);
+
+ debug::iota(ima1);
+ debug::iota(ima2);
+
+ level::apply(ima1, fun::v2v::chess_value_t<I>(mod1) );
+ level::apply(ima2, fun::v2v::chess_value_t<J>(mod2) );
+
+ chck(ima1, ima2);
+ }
+
+
+ template <typename I, typename J>
+ void
+ chk3d(unsigned sli, unsigned row, unsigned col,
+ unsigned mod1, unsigned mod2)
+ {
+ image3d<I> ima1 (sli, row, col);
+ image3d<J> ima2 (sli, row, col);
+
+ debug::iota(ima1);
+ debug::iota(ima2);
+
+ level::apply(ima1, fun::v2v::chess_value_t<I>(mod1) );
+ level::apply(ima2, fun::v2v::chess_value_t<J>(mod2) );
+
+ chck(ima1, ima2);
+ }
+
+
+}
+
+
+
+
+
+int main()
+{
+ using namespace mln;
+
+ unsigned max_mod1 = 8;
+ unsigned max_mod2 = 8;
+ unsigned max_cols = 16;
+ unsigned max_rows = 8;
+ unsigned max_slis = 2;
+
+ std::cerr << "Tests logical::and_not" << std::endl;
+
+ (std::cerr << "in 1d ... ").flush ();
+ {
+ for (unsigned i = 1; i < max_mod1; ++i)
+ for (unsigned j = 1; j < max_mod2; ++j)
+ for (unsigned k = 1; k < max_cols; ++k)
+ {
+ chk1d<int, int>(k, i, j);
+ chk1d<unsigned, unsigned>(k, i, j);
+ chk1d<value::int_s8, value::int_s8>(k, i, j);
+ chk1d<int, unsigned>(k, i, j);
+ chk1d<unsigned, value::int_u8>(k, i, j);
+ chk1d<int, value::int_s8>(k, i, j);
+ chk1d<unsigned, value::int_u16>(k, i, j);
+ chk1d<int, value::int_s16>(k, i, j);
+ }
+ }
+ std::cerr << "OK" << std::endl;
+
+ (std::cerr << "in 2d ... ").flush ();
+ {
+ for (unsigned i = 1; i < max_mod1; ++i)
+ for (unsigned j = 1; j < max_mod2; ++j)
+ for (unsigned k = 1; k < max_cols; ++k)
+ for (unsigned l = 1; l < max_rows; ++l)
+ {
+ chk2d<int, int>(l ,k, i, j);
+ chk2d<unsigned, unsigned>(l ,k, i, j);
+ chk2d<value::int_s8, value::int_s8>(l ,k, i, j);
+ chk2d<int, unsigned>(l ,k, i, j);
+ chk2d<unsigned, value::int_u8>(l ,k, i, j);
+ chk2d<int, value::int_s8>(l ,k, i, j);
+ chk2d<unsigned, value::int_u16>(l ,k, i, j);
+ chk2d<int, value::int_s16>(l ,k, i, j);
+ }
+ }
+ std::cerr << "OK" << std::endl;
+
+ (std::cerr << "in 3d ... ").flush ();
+ {
+ for (unsigned i = 1; i < max_mod1; ++i)
+ for (unsigned j = 1; j < max_mod2; ++j)
+ for (unsigned k = 1; k < max_cols; ++k)
+ for (unsigned l = 1; l < max_rows; ++l)
+ for (unsigned m = 1; m < max_slis; ++m)
+ {
+ chk3d<int, int>(m, l ,k, i, j);
+ chk3d<unsigned, unsigned>(m, l ,k, i, j);
+ chk3d<value::int_s8, value::int_s8>(m, l ,k, i, j);
+ chk3d<int, unsigned>(m, l ,k, i, j);
+ chk3d<unsigned, value::int_u8>(m, l ,k, i, j);
+ chk3d<int, value::int_s8>(m, l ,k, i, j);
+ chk3d<unsigned, value::int_u16>(m, l ,k, i, j);
+ chk3d<int, value::int_s16>(m, l ,k, i, j);
+ }
+ }
+ std::cerr << "OK" << std::endl;
+
+}
Index: trunk/milena/tests/logical/and_full.cc
===================================================================
--- trunk/milena/tests/logical/and_full.cc (revision 0)
+++ trunk/milena/tests/logical/and_full.cc (revision 1576)
@@ -0,0 +1,225 @@
+// 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/logical/and_full.cc
+ *
+ * \brief Tests on mln::logical::and.
+ */
+
+#include <mln/core/image1d.hh>
+#include <mln/core/image2d.hh>
+#include <mln/core/image3d.hh>
+#include <mln/logical/and.hh>
+#include <mln/level/compare.hh>
+#include <mln/level/apply.hh>
+#include <mln/debug/iota.hh>
+#include <mln/debug/println.hh>
+#include <mln/core/concept/function.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/value/int_u16.hh>
+#include <mln/value/int_s8.hh>
+#include <mln/value/int_s16.hh>
+
+#include <mln/literal/zero.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ template <typename V, typename T = V, typename R = T>
+ struct chess_value_t : public Function_v2v< chess_value_t<V,T,R> >
+ {
+ chess_value_t (V mod) : mod_ (mod) {}
+
+ typedef R result;
+ R operator()(const V& v) const
+ {
+ return v % mod_ ? v : literal::zero;
+ }
+
+ V mod_;
+ };
+
+ }
+
+ }
+
+ template <typename I, typename J>
+ void
+ chck(Image<I>& ima1_, const Image<J>& ima2_)
+ {
+ const I& ima1 = exact(ima1_);
+ I& ima3 = exact(ima1_);
+ const J& ima2 = exact(ima2_);
+ mln_concrete(I) log = logical::and_(ima1, ima2);
+
+ mln_assertion (ima2.domain () >= ima1.domain ());
+ mln_piter(I) p (ima1.domain ());
+ for_all(p)
+ mln_assertion ((ima1(p) && ima2(p)) == log(p));
+ logical::and_inplace(ima3, ima2);
+ for_all(p)
+ mln_assertion (ima3(p) == log(p));
+ }
+
+
+ template <typename I, typename J>
+ void
+ chk1d(unsigned col,
+ unsigned mod1, unsigned mod2)
+ {
+ image1d<I> ima1 (col);
+ image1d<J> ima2 (col);
+
+ debug::iota(ima1);
+ debug::iota(ima2);
+
+ level::apply(ima1, fun::v2v::chess_value_t<I>(mod1) );
+ level::apply(ima2, fun::v2v::chess_value_t<J>(mod2) );
+
+ chck(ima1, ima2);
+ }
+
+
+ template <typename I, typename J>
+ void
+ chk2d(unsigned row, unsigned col,
+ unsigned mod1, unsigned mod2)
+ {
+ image2d<I> ima1 (row, col);
+ image2d<J> ima2 (row, col);
+
+ debug::iota(ima1);
+ debug::iota(ima2);
+
+ level::apply(ima1, fun::v2v::chess_value_t<I>(mod1) );
+ level::apply(ima2, fun::v2v::chess_value_t<J>(mod2) );
+
+ chck(ima1, ima2);
+ }
+
+
+ template <typename I, typename J>
+ void
+ chk3d(unsigned sli, unsigned row, unsigned col,
+ unsigned mod1, unsigned mod2)
+ {
+ image3d<I> ima1 (sli, row, col);
+ image3d<J> ima2 (sli, row, col);
+
+ debug::iota(ima1);
+ debug::iota(ima2);
+
+ level::apply(ima1, fun::v2v::chess_value_t<I>(mod1) );
+ level::apply(ima2, fun::v2v::chess_value_t<J>(mod2) );
+
+ chck(ima1, ima2);
+ }
+
+
+}
+
+
+
+
+
+int main()
+{
+ using namespace mln;
+
+ unsigned max_mod1 = 8;
+ unsigned max_mod2 = 8;
+ unsigned max_cols = 16;
+ unsigned max_rows = 8;
+ unsigned max_slis = 2;
+
+ std::cerr << "Tests logical::and" << std::endl;
+
+ (std::cerr << "in 1d ... ").flush ();
+ {
+ for (unsigned i = 1; i < max_mod1; ++i)
+ for (unsigned j = 1; j < max_mod2; ++j)
+ for (unsigned k = 1; k < max_cols; ++k)
+ {
+ chk1d<int, int>(k, i, j);
+ chk1d<unsigned, unsigned>(k, i, j);
+ chk1d<value::int_s8, value::int_s8>(k, i, j);
+ chk1d<int, unsigned>(k, i, j);
+ chk1d<unsigned, value::int_u8>(k, i, j);
+ chk1d<int, value::int_s8>(k, i, j);
+ chk1d<unsigned, value::int_u16>(k, i, j);
+ chk1d<int, value::int_s16>(k, i, j);
+ }
+ }
+ std::cerr << "OK" << std::endl;
+
+ (std::cerr << "in 2d ... ").flush ();
+ {
+ for (unsigned i = 1; i < max_mod1; ++i)
+ for (unsigned j = 1; j < max_mod2; ++j)
+ for (unsigned k = 1; k < max_cols; ++k)
+ for (unsigned l = 1; l < max_rows; ++l)
+ {
+ chk2d<int, int>(l ,k, i, j);
+ chk2d<unsigned, unsigned>(l ,k, i, j);
+ chk2d<value::int_s8, value::int_s8>(l ,k, i, j);
+ chk2d<int, unsigned>(l ,k, i, j);
+ chk2d<unsigned, value::int_u8>(l ,k, i, j);
+ chk2d<int, value::int_s8>(l ,k, i, j);
+ chk2d<unsigned, value::int_u16>(l ,k, i, j);
+ chk2d<int, value::int_s16>(l ,k, i, j);
+ }
+ }
+ std::cerr << "OK" << std::endl;
+
+ (std::cerr << "in 3d ... ").flush ();
+ {
+ for (unsigned i = 1; i < max_mod1; ++i)
+ for (unsigned j = 1; j < max_mod2; ++j)
+ for (unsigned k = 1; k < max_cols; ++k)
+ for (unsigned l = 1; l < max_rows; ++l)
+ for (unsigned m = 1; m < max_slis; ++m)
+ {
+ chk3d<int, int>(m, l ,k, i, j);
+ chk3d<unsigned, unsigned>(m, l ,k, i, j);
+ chk3d<value::int_s8, value::int_s8>(m, l ,k, i, j);
+ chk3d<int, unsigned>(m, l ,k, i, j);
+ chk3d<unsigned, value::int_u8>(m, l ,k, i, j);
+ chk3d<int, value::int_s8>(m, l ,k, i, j);
+ chk3d<unsigned, value::int_u16>(m, l ,k, i, j);
+ chk3d<int, value::int_s16>(m, l ,k, i, j);
+ }
+ }
+ std::cerr << "OK" << std::endl;
+
+}
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-29 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Add full tests for border.
* tests/border/equalize_full.cc,
* tests/border/find_full.cc,
* tests/border/resize_full.cc: New full tests.
* tests/border/resize.cc: Fix typo.
---
equalize_full.cc | 84 ++++++++++++++++++++++++++++
find_full.cc | 160 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
resize.cc | 2
resize_full.cc | 135 ++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 380 insertions(+), 1 deletion(-)
Index: trunk/milena/tests/border/resize.cc
===================================================================
--- trunk/milena/tests/border/resize.cc (revision 1570)
+++ trunk/milena/tests/border/resize.cc (revision 1571)
@@ -25,7 +25,7 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/border_resize_image2d_1.cc
+/*! \file tests/border/resize.cc
*
* \brief Tests on mln::border::resize.
*/
Index: trunk/milena/tests/border/equalize_full.cc
===================================================================
--- trunk/milena/tests/border/equalize_full.cc (revision 0)
+++ trunk/milena/tests/border/equalize_full.cc (revision 1571)
@@ -0,0 +1,84 @@
+// 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/border/equalize_full.cc
+ *
+ * \brief Tests on mln::border::equalize.
+ */
+
+#include <mln/core/image1d.hh>
+#include <mln/core/image2d.hh>
+#include <mln/core/image3d.hh>
+#include <mln/border/get.hh>
+#include <mln/border/equalize.hh>
+
+int main()
+{
+ using namespace mln;
+ unsigned sli = 5;
+ unsigned row = 10;
+ unsigned col = 20;
+ unsigned border1 = 42;
+ unsigned border2 = 36;
+ unsigned new_border = 51;
+
+
+
+ {
+ typedef image1d<int> I;
+ (std::cerr << "Tests border::equalize in 1d ... ").flush ();
+ I ima1(col, border1);
+ I ima2(col, border2);
+ border::equalize(ima1, ima2, new_border);
+ mln_assertion(border::get(ima1) == new_border);
+ mln_assertion(border::get(ima2) == new_border);
+ std::cerr << "OK" << std::endl;
+ }
+
+ {
+ typedef image2d<int> I;
+ (std::cerr << "Tests border::equalize in 2d ... ").flush ();
+ I ima1(row, col, border1);
+ I ima2(row, col, border2);
+ border::equalize(ima1, ima2, new_border);
+ mln_assertion(border::get(ima1) == new_border);
+ mln_assertion(border::get(ima2) == new_border);
+ std::cerr << "OK" << std::endl;
+ }
+
+ {
+ typedef image3d<int> I;
+ (std::cerr << "Tests border::equalize in 3d ... ").flush ();
+ I ima1(sli, row, col, border1);
+ I ima2(sli, row, col, border2);
+ border::equalize(ima1, ima2, new_border);
+ mln_assertion(border::get(ima1) == new_border);
+ mln_assertion(border::get(ima2) == new_border);
+ std::cerr << "OK" << std::endl;
+ }
+
+}
Index: trunk/milena/tests/border/find_full.cc
===================================================================
--- trunk/milena/tests/border/find_full.cc (revision 0)
+++ trunk/milena/tests/border/find_full.cc (revision 1571)
@@ -0,0 +1,160 @@
+// 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/border/find_full.cc
+ *
+ * \brief Tests on mln::border::find.
+ */
+
+#include <mln/core/image1d.hh>
+#include <mln/core/image2d.hh>
+#include <mln/core/image3d.hh>
+#include <mln/core/sub_image.hh>
+
+#include <mln/core/image_if.hh>
+#include <mln/fun/p2b/chess.hh>
+#include <mln/border/find.hh>
+#include <mln/literal/origin.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/value/rgb8.hh>
+
+
+#include <mln/debug/iota.hh>
+#include <mln/border/find.hh>
+#include <mln/core/clone.hh>
+
+
+struct f_box1d_t : mln::Function_p2b< f_box1d_t >
+{
+ f_box1d_t(const mln::box1d& b)
+ : b_(b)
+ {
+ }
+ mln::box1d b_;
+ bool operator()(const mln::point1d& p) const
+ {
+ return b_.has(p);
+ }
+};
+
+struct f_box2d_t : mln::Function_p2b< f_box2d_t >
+{
+ f_box2d_t(const mln::box2d& b)
+ : b_(b)
+ {
+ }
+ mln::box2d b_;
+ bool operator()(const mln::point2d& p) const
+ {
+ return b_.has(p);
+ }
+};
+
+struct f_box3d_t : mln::Function_p2b< f_box3d_t >
+{
+ f_box3d_t(const mln::box3d& b)
+ : b_(b)
+ {
+ }
+ mln::box3d b_;
+ bool operator()(const mln::point3d& p) const
+ {
+ return b_.has(p);
+ }
+};
+
+
+int main()
+{
+ using namespace mln;
+
+ box1d b1(literal::origin, point1d(1));
+ box2d b2(literal::origin, point2d(1,1));
+ box3d b3(literal::origin, point3d(1,1,1));
+ f_box1d_t f_b1(b1);
+ f_box2d_t f_b2(b2);
+ f_box3d_t f_b3(b3);
+ mln::fun::p2b::chess_t c_b;
+
+ {
+ typedef image1d<int> I;
+ (std::cerr << "Tests border::find on int in 1d ... ").flush ();
+ I ima(3, 51);
+ debug::iota(ima);
+ mln_assertion(border::find(ima) == 51);
+ sub_image<I, box1d> sub(ima, b1);
+ mln_assertion(border::find(sub) == 51);
+
+ image_if<I, f_box1d_t> imaif(ima, f_b1);
+ mln_assertion(border::find(imaif) == 51);
+
+ mln_assertion(border::find( (ima | b1) ) == 51);
+ mln_assertion(border::find( (ima | b1) | f_b1 ) == 51);
+ std::cerr << "OK" << std::endl;
+ }
+
+ {
+ typedef image2d<value::int_u8> I;
+ (std::cerr << "Tests border::find on int_u8 in 2d ... ").flush ();
+ I ima(10, 10, 42);
+ debug::iota(ima);
+ mln_assertion(border::find(ima) == 42);
+ sub_image<I, box2d> sub(ima, b2);
+ mln_assertion(border::find(sub) == 42);
+
+ image_if<I, f_box2d_t > imaif(ima, f_b2);
+ mln_assertion(border::find(imaif) == 42);
+
+ image_if<I, fun::p2b::chess_t > imaif_chess(ima, c_b);
+ mln_assertion(border::find(imaif_chess) == 42);
+
+
+ mln_assertion(border::find( (ima | b2) ) == 42);
+ mln_assertion(border::find( (ima | b2) | f_b2 ) == 42);
+ mln_assertion(border::find( (ima | b2) | c_b ) == 42);
+ mln_assertion(border::find( (ima | b2) | c_b | f_b2 ) == 42);
+ mln_assertion(border::find( (ima | b2) | f_b2 | c_b ) == 42);
+
+ std::cerr << "OK" << std::endl;
+ }
+
+ {
+ typedef image3d<value::rgb8> I;
+ (std::cerr << "Tests border::find on rgb8 in 3d ... ").flush ();
+ I ima(10, 10, 10, 36);
+ mln_assertion(border::find(ima) == 36);
+ mln_assertion( ima.has(point3d(2,2,2)) == true );
+ sub_image<I, box3d> sub(ima, b3);
+ mln_assertion(border::find(sub) == 36);
+
+ image_if<I, f_box3d_t> imaif(ima, f_b3);
+ mln_assertion(border::find(imaif) == 36);
+ mln_assertion(border::find( (ima | b3) ) == 36);
+ mln_assertion(border::find( (ima | b3) | f_b3 ) == 36);
+ std::cerr << "OK" << std::endl;
+ }
+}
Index: trunk/milena/tests/border/resize_full.cc
===================================================================
--- trunk/milena/tests/border/resize_full.cc (revision 0)
+++ trunk/milena/tests/border/resize_full.cc (revision 1571)
@@ -0,0 +1,135 @@
+// 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/border/resize_full.cc
+ *
+ * \brief Tests on mln::border::resize.
+ */
+
+
+#include <mln/core/image1d.hh>
+#include <mln/core/image2d.hh>
+#include <mln/core/image3d.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/border/resize.hh>
+#include <mln/border/get.hh>
+
+using namespace mln;
+
+int
+main (void)
+{
+ unsigned sli = 51;
+ unsigned row = 42;
+ unsigned col = 100;
+
+
+
+ unsigned border1 = 1;
+ unsigned border2 = 3;
+ unsigned border3 = 42;
+ unsigned border4 = 51;
+ unsigned border5 = 36;
+ unsigned border6 = 2;
+ unsigned border7 = 0;
+ unsigned border8 = 8;
+ unsigned border9 = 1;
+
+
+ {
+ (std::cerr << "Test border::resize in 1d ... ").flush ();
+ image1d<value::int_u8> ima(col, border1);
+
+ mln_assertion(border::get(ima) == border1);
+ border::resize (ima, border2);
+ mln_assertion(border::get(ima) == border2);
+ border::resize (ima, border3);
+ mln_assertion(border::get(ima) == border3);
+ border::resize (ima, border4);
+ mln_assertion(border::get(ima) == border4);
+ border::resize (ima, border5);
+ mln_assertion(border::get(ima) == border5);
+ border::resize (ima, border6);
+ mln_assertion(border::get(ima) == border6);
+ border::resize (ima, border7);
+ mln_assertion(border::get(ima) == border7);
+ border::resize (ima, border8);
+ mln_assertion(border::get(ima) == border8);
+ border::resize (ima, border9);
+ mln_assertion(border::get(ima) == border9);
+ std::cerr << "OK" << std::endl;
+ }
+
+ {
+ (std::cerr << "Test border::resize in 2d ... ").flush ();
+ image2d<value::int_u8> ima(row, col, border1);
+
+ mln_assertion(border::get(ima) == border1);
+ border::resize (ima, border2);
+ mln_assertion(border::get(ima) == border2);
+ border::resize (ima, border3);
+ mln_assertion(border::get(ima) == border3);
+ border::resize (ima, border4);
+ mln_assertion(border::get(ima) == border4);
+ border::resize (ima, border5);
+ mln_assertion(border::get(ima) == border5);
+ border::resize (ima, border6);
+ mln_assertion(border::get(ima) == border6);
+ border::resize (ima, border7);
+ mln_assertion(border::get(ima) == border7);
+ border::resize (ima, border8);
+ mln_assertion(border::get(ima) == border8);
+ border::resize (ima, border9);
+ mln_assertion(border::get(ima) == border9);
+ std::cerr << "OK" << std::endl;
+ }
+
+ {
+ (std::cerr << "Test border::resize in 3d ... ").flush ();
+ image3d<value::int_u8> ima(sli, row, col, border1);
+
+ mln_assertion(border::get(ima) == border1);
+ border::resize (ima, border2);
+ mln_assertion(border::get(ima) == border2);
+ border::resize (ima, border3);
+ mln_assertion(border::get(ima) == border3);
+ border::resize (ima, border4);
+ mln_assertion(border::get(ima) == border4);
+ border::resize (ima, border5);
+ mln_assertion(border::get(ima) == border5);
+ border::resize (ima, border6);
+ mln_assertion(border::get(ima) == border6);
+ border::resize (ima, border7);
+ mln_assertion(border::get(ima) == border7);
+ border::resize (ima, border8);
+ mln_assertion(border::get(ima) == border8);
+ border::resize (ima, border9);
+ mln_assertion(border::get(ima) == border9);
+ std::cerr << "OK" << std::endl;
+ }
+
+}