Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Add test for neighborhood.
* tests/core/neighb2d.cc: New.
* tests/core/Makefile.am: .
* oln/core/automatic/impl.hh: .
* oln/core/abstract/internal/image_impl.hh: .
oln/core/abstract/internal/image_impl.hh | 2
oln/core/automatic/impl.hh | 2
tests/core/Makefile.am | 2
tests/core/neighb2d.cc | 65 +++++++++++++++++++++++++++++++
4 files changed, 69 insertions(+), 2 deletions(-)
Index: tests/core/neighb2d.cc
--- tests/core/neighb2d.cc (revision 0)
+++ tests/core/neighb2d.cc (revision 0)
@@ -0,0 +1,65 @@
+// 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.
+
+/// Test oln::neighb2d.
+
+#include <oln/core/2d/image2d.hh>
+#include <oln/core/2d/neighb2d.hh>
+
+
+namespace test
+{
+
+ template <typename I>
+ unsigned run(const oln::Image_with_Nbh<I>& input)
+ {
+ oln_piter(I) p(input.points());
+ oln_niter(I) n(p, input.nbhood());
+ unsigned count = 0;
+
+ for_all(p)
+ {
+ for_all(n)
+ if (input.owns_(n))
+ ++count;
+ }
+ return count;
+ }
+}
+
+
+int main()
+{
+ using namespace oln;
+
+ image2d<bool> ima(3, 3);
+ // 2 + 3 + 2 +
+ // 3 + 4 + 3 +
+ // 2 + 3 + 2 = 24
+ std::cout << test::run(ima + c4) << std::endl;
+ assert(test::run(ima + c4) == 24);
+}
Index: tests/core/Makefile.am
--- tests/core/Makefile.am (revision 860)
+++ tests/core/Makefile.am (working copy)
@@ -24,6 +24,7 @@
grid \
image2d \
npoints \
+ neighb2d \
window2d \
at
@@ -34,6 +35,7 @@
image2d_SOURCES = image2d.cc
npoints_SOURCES = npoints.cc
window2d_SOURCES = window2d.cc
+neighb2d_SOURCES = neighb2d.cc
# Methods.
at_SOURCES = at.cc
Index: oln/core/automatic/impl.hh
--- oln/core/automatic/impl.hh (revision 860)
+++ oln/core/automatic/impl.hh (working copy)
@@ -28,7 +28,7 @@
#ifndef OLN_CORE_AUTOMATIC_IMPL_HH
# define OLN_CORE_AUTOMATIC_IMPL_HH
-# include <oln/core/typedefs.hh>
+// # include <oln/core/typedefs.hh>
namespace oln
Index: oln/core/abstract/internal/image_impl.hh
--- oln/core/abstract/internal/image_impl.hh (revision 860)
+++ oln/core/abstract/internal/image_impl.hh (working copy)
@@ -29,7 +29,7 @@
# define OLN_CORE_ABSTRACT_INTERNAL_IMAGE_IMPL_HH
# include <mlc/flags.hh>
-# include <oln/core/typedefs.hh>
+// # include <oln/core/typedefs.hh>
# include <oln/core/abstract/any.hh>
# include <oln/core/macros.hh>