https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Cleanup accu::image and add take_n_times.
* mln/accu/image/take.hh: Copy to...
* mln/accu/image/take_n_times.hh: ...this new file.
Update.
* mln/accu/image/all.hh: Update.
* mln/accu/image/init.hh,
* mln/accu/image/set_value.hh,
* mln/accu/image/to_result.hh: Fix missing static checks.
* mln/accu/image/take.hh (todo): New.
(take_tests): New.
(generic::take, take_fastest): Update.
Fix missing static checks.
* tests/accu/image/to_result.cc,
* tests/accu/image/init.cc,
* tests/accu/image/take.cc,
* tests/accu/image/set_value.cc,
* tests/accu/image/take_as_init.cc:
Change debug log into quiet test.
* tests/accu/image/take_n_times.cc: New.
* tests/accu/image/Makefile.am: Update.
* mln/border/resize_equal.hh: New.
* mln/border/all.hh: Update.
* tests/border/resize_equal.cc: New.
* tests/border/resize.cc: Cleanup.
* tests/border/Makefile.am: Update.
mln/accu/image/all.hh | 1
mln/accu/image/init.hh | 4 +
mln/accu/image/set_value.hh | 7 +
mln/accu/image/take.hh | 55 +++++++++++--
mln/accu/image/take_n_times.hh | 154 +++++++++++++++++++++++++--------------
mln/accu/image/to_result.hh | 4 +
mln/border/all.hh | 11 +-
mln/border/resize_equal.hh | 96 ++++++++++++++++++++++++
tests/accu/image/Makefile.am | 2
tests/accu/image/init.cc | 5 +
tests/accu/image/set_value.cc | 6 +
tests/accu/image/take.cc | 13 +--
tests/accu/image/take_as_init.cc | 12 +--
tests/accu/image/take_n_times.cc | 22 ++---
tests/accu/image/to_result.cc | 7 +
tests/border/Makefile.am | 2
tests/border/resize.cc | 34 ++++----
tests/border/resize_equal.cc | 43 ++++++++++
18 files changed, 365 insertions(+), 113 deletions(-)
Index: mln/accu/image/take_n_times.hh
--- mln/accu/image/take_n_times.hh (revision 3738)
+++ mln/accu/image/take_n_times.hh (working copy)
@@ -25,16 +25,19 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_ACCU_IMAGE_TAKE_HH
-# define MLN_ACCU_IMAGE_TAKE_HH
+#ifndef MLN_ACCU_IMAGE_TAKE_N_TIMES_HH
+# define MLN_ACCU_IMAGE_TAKE_N_TIMES_HH
-/// \file mln/accu/image/take.hh
+/// \file mln/accu/image/take_n_times.hh
///
/// Update an image of accumulators by taking the contents of another
-/// image.
+/// image with a multiplicity.
+///
+/// \todo Add "take(input, n, arg_value)".
# include <mln/core/concept/accumulator.hh>
# include <mln/core/concept/image.hh>
+# include <mln/border/resize.hh>
namespace mln
@@ -46,14 +49,45 @@
namespace image
{
- template <typename I, typename J>
+ template <typename I, typename J, typename K>
void
- take(Image<I>& input, const Image<J>& arg);
+ take_n_times(Image<I>& input, const Image<J>& n_times, const
Image<K>& arg);
# ifndef MLN_INCLUDE_ONLY
+
+ // Tests.
+
+ namespace internal
+ {
+
+ template <typename I, typename J, typename K>
+ void
+ take_n_times_tests(Image<I>& input_, const Image<J>& n_times_, const
Image<K>& arg_)
+ {
+ I& input = exact(input_);
+ const J& n_times = exact(n_times_);
+ const K& arg = exact(arg_);
+
+ mln_precondition(input.is_valid());
+ mln_precondition(n_times.is_valid());
+ mln_precondition(arg.is_valid());
+
+ mln_precondition(arg.domain() <= input.domain());
+ mln_precondition(arg.domain() <= n_times.domain());
+
+ (void) input;
+ (void) n_times;
+ (void) arg;
+ }
+
+ } // end of namespace mln::accu::image::internal
+
+
+ // Implementations.
+
namespace impl
{
@@ -62,24 +96,27 @@
namespace generic
{
- template <typename I, typename J>
+ template <typename I, typename J, typename K>
void
- take(Image<I>& input_, const Image<J>& arg_)
+ take_n_times(Image<I>& input_, const Image<J>& n_times_, const
Image<K>& arg_)
{
- trace::entering("accu::impl::image::generic::take");
+ trace::entering("accu::impl::image::generic::take_n_times");
+
+ mlc_is_a(mln_value(I), Accumulator)::check();
+ mlc_converts_to(mln_value(J), unsigned)::check();
+ mlc_converts_to(mln_value(K), mln_deduce(I, value, argument))::check();
I& input = exact(input_);
- const J& arg = exact(arg_);
+ const J& n_times = exact(n_times_);
+ const K& arg = exact(arg_);
- mln_precondition(input.is_valid());
- mln_precondition(arg.is_valid());
- mln_precondition(arg.domain() <= input.domain());
+ internal::take_n_times_tests(input, n_times, arg);
mln_piter(J) p(arg.domain());
for_all(p)
- input(p).take(arg(p));
+ input(p).take_n_times(n_times(p), arg(p));
- trace::exiting("accu::impl::image::generic::take");
+ trace::exiting("accu::impl::image::generic::take_n_times");
}
} // end of namespace mln::accu::image::impl::generic
@@ -87,25 +124,36 @@
// Fastest version.
- template <typename I, typename J>
+ template <typename I, typename J, typename K>
void
- take_fastest(Image<I>& input_, const Image<J>& arg_)
+ take_n_times_fastest(Image<I>& input_, const Image<J>& n_times_,
const Image<K>& arg_)
{
- trace::entering("accu::impl::image::take_fastest");
+ trace::entering("accu::impl::image::take_n_times_fastest");
+
+ mlc_is_a(mln_value(I), Accumulator)::check();
+ mlc_converts_to(mln_value(J), unsigned)::check();
+ mlc_converts_to(mln_value(K), mln_deduce(I, value, argument))::check();
I& input = exact(input_);
- const J& arg = exact(arg_);
+ const J& n_times = exact(n_times_);
+ const K& arg = exact(arg_);
- mln_precondition(input.is_valid());
- mln_precondition(arg.is_valid());
+ internal::take_n_times_tests(input, n_times, arg);
+
+ // Extra (stronger) tests.
mln_precondition(arg.domain() == input.domain());
+ mln_precondition(arg.domain() == n_times.domain());
+
+ border::resize(n_times, input.border());
+ border::resize(arg, input.border());
mln_pixter(I) p_in(input);
- mln_pixter(const J) p_arg(arg);
- for_all_2(p_in, p_arg)
- p_in.val().take( p_arg.val() );
+ mln_pixter(const J) p_ntm(n_times);
+ mln_pixter(const K) p_arg(arg);
+ for_all_3(p_in, p_ntm, p_arg)
+ p_in.val().take_n_times( p_ntm.val(), p_arg.val() );
- trace::exiting("accu::impl::image::take_fastest");
+ trace::exiting("accu::impl::image::take_n_times_fastest");
}
} // end of namespace mln::accu::image::impl
@@ -117,34 +165,38 @@
namespace internal
{
- template <typename I, typename J>
+ template <typename I, typename J, typename K>
void
- take_dispatch(trait::image::speed::any,
+ take_n_times_dispatch(trait::image::speed::any,
trait::image::speed::any,
- Image<I>& input, const Image<J>& arg)
+ trait::image::speed::any,
+ Image<I>& input, const Image<J>& n_times, const
Image<K>& arg)
{
- impl::generic::take(input, arg);
+ impl::generic::take_n_times(input, n_times, arg);
}
- template <typename I, typename J>
+ template <typename I, typename J, typename K>
void
- take_dispatch(trait::image::speed::fastest,
+ take_n_times_dispatch(trait::image::speed::fastest,
+ trait::image::speed::fastest,
trait::image::speed::fastest,
- Image<I>& input, const Image<J>& arg)
+ Image<I>& input, const Image<J>& n_times, const
Image<K>& arg)
{
- if (exact(arg).domain() == exact(input).domain())
- impl::take_fastest(input, arg);
+ if (exact(n_times).domain() == exact(input).domain() &&
+ exact(arg) .domain() == exact(input).domain())
+ impl::take_n_times_fastest(input, n_times, arg);
else
- impl::generic::take(input, arg);
+ impl::generic::take_n_times(input, n_times, arg);
}
- template <typename I, typename J>
+ template <typename I, typename J, typename K>
void
- take_dispatch(Image<I>& input, const Image<J>& arg)
+ take_n_times_dispatch(Image<I>& input, const Image<J>& n_times,
const Image<K>& arg)
{
- take_dispatch(mln_trait_image_speed(I)(),
+ take_n_times_dispatch(mln_trait_image_speed(I)(),
mln_trait_image_speed(J)(),
- input, arg);
+ mln_trait_image_speed(K)(),
+ input, n_times, arg);
}
} // end of namespace mln::accu::image::internal
@@ -152,26 +204,24 @@
// Facade.
- template <typename I, typename J>
+ template <typename I, typename J, typename K>
void
- take(Image<I>& input_, const Image<J>& arg_)
+ take_n_times(Image<I>& input_, const Image<J>& n_times_, const
Image<K>& arg_)
{
- trace::entering("accu::image::take");
+ trace::entering("accu::image::take_n_times");
mlc_is_a(mln_value(I), Accumulator)::check();
- mlc_converts_to(mln_value(J),
- mln_deduce(I, value, argument))::check();
+ mlc_converts_to(mln_value(J), unsigned)::check();
+ mlc_converts_to(mln_value(K), mln_deduce(I, value, argument))::check();
I& input = exact(input_);
- const J& arg = exact(arg_);
-
- mln_precondition(input.is_valid());
- mln_precondition(arg.is_valid());
- mln_precondition(arg.domain() <= input.domain());
+ const J& n_times = exact(n_times_);
+ const K& arg = exact(arg_);
- internal::take_dispatch(input, arg);
+ internal::take_n_times_tests(input, n_times, arg);
+ internal::take_n_times_dispatch(input, n_times, arg);
- trace::exiting("accu::image::take");
+ trace::exiting("accu::image::take_n_times");
}
# endif // ! MLN_INCLUDE_ONLY
@@ -183,4 +233,4 @@
} // end of namespace mln
-#endif // ! MLN_ACCU_IMAGE_TAKE_HH
+#endif // ! MLN_ACCU_IMAGE_TAKE_N_TIMES_HH
Property changes on: mln/accu/image/take_n_times.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: mln/accu/image/init.hh
--- mln/accu/image/init.hh (revision 3738)
+++ mln/accu/image/init.hh (working copy)
@@ -67,6 +67,8 @@
{
trace::entering("accu::impl::image::generic::init");
+ mlc_is_a(mln_value(I), Accumulator)::check();
+
I& input = exact(input_);
mln_precondition(input.is_valid());
@@ -88,6 +90,8 @@
{
trace::entering("accu::impl::image::init_fastest");
+ mlc_is_a(mln_value(I), Accumulator)::check();
+
I& input = exact(input_);
mln_precondition(input.is_valid());
Index: mln/accu/image/take.hh
--- mln/accu/image/take.hh (revision 3738)
+++ mln/accu/image/take.hh (working copy)
@@ -32,9 +32,12 @@
///
/// Update an image of accumulators by taking the contents of another
/// image.
+///
+/// \todo Add "take(input, arg_value)".
# include <mln/core/concept/accumulator.hh>
# include <mln/core/concept/image.hh>
+# include <mln/border/resize_equal.hh>
namespace mln
@@ -54,6 +57,34 @@
# ifndef MLN_INCLUDE_ONLY
+
+ // Tests.
+
+ namespace internal
+ {
+
+ template <typename I, typename J>
+ void
+ take_tests(Image<I>& input_, const Image<J>& arg_)
+ {
+ I& input = exact(input_);
+ const J& arg = exact(arg_);
+
+ mln_precondition(input.is_valid());
+ mln_precondition(arg.is_valid());
+
+ mln_precondition(arg.domain() <= input.domain());
+
+ (void) input;
+ (void) arg;
+ }
+
+ } // end of namespace mln::accu::image::internal
+
+
+
+ // Implementations.
+
namespace impl
{
@@ -68,12 +99,13 @@
{
trace::entering("accu::impl::image::generic::take");
+ mlc_is_a(mln_value(I), Accumulator)::check();
+ mlc_converts_to(mln_value(J), mln_deduce(I, value, argument))::check();
+
I& input = exact(input_);
const J& arg = exact(arg_);
- mln_precondition(input.is_valid());
- mln_precondition(arg.is_valid());
- mln_precondition(arg.domain() <= input.domain());
+ internal::take_tests(input, arg);
mln_piter(J) p(arg.domain());
for_all(p)
@@ -93,13 +125,18 @@
{
trace::entering("accu::impl::image::take_fastest");
+ mlc_is_a(mln_value(I), Accumulator)::check();
+ mlc_converts_to(mln_value(J), mln_deduce(I, value, argument))::check();
+
I& input = exact(input_);
const J& arg = exact(arg_);
- mln_precondition(input.is_valid());
- mln_precondition(arg.is_valid());
+ internal::take_tests(input, arg);
+ // Extra (stronger) test.
mln_precondition(arg.domain() == input.domain());
+ border::resize_equal(input, arg);
+
mln_pixter(I) p_in(input);
mln_pixter(const J) p_arg(arg);
for_all_2(p_in, p_arg)
@@ -159,16 +196,12 @@
trace::entering("accu::image::take");
mlc_is_a(mln_value(I), Accumulator)::check();
- mlc_converts_to(mln_value(J),
- mln_deduce(I, value, argument))::check();
+ mlc_converts_to(mln_value(J), mln_deduce(I, value, argument))::check();
I& input = exact(input_);
const J& arg = exact(arg_);
- mln_precondition(input.is_valid());
- mln_precondition(arg.is_valid());
- mln_precondition(arg.domain() <= input.domain());
-
+ internal::take_tests(input, arg);
internal::take_dispatch(input, arg);
trace::exiting("accu::image::take");
Index: mln/accu/image/set_value.hh
--- mln/accu/image/set_value.hh (revision 3738)
+++ mln/accu/image/set_value.hh (working copy)
@@ -31,6 +31,8 @@
/// \file mln/accu/image/set_value.hh
///
/// Set the values of an image of accumulators.
+///
+/// \todo Add "set_value(Image<I>& input, const Image<J>&
values)".
# include <mln/core/concept/accumulator.hh>
# include <mln/core/concept/image.hh>
@@ -51,7 +53,6 @@
const mln_deduce(I, value, result)& res);
-
# ifndef MLN_INCLUDE_ONLY
namespace impl
@@ -69,6 +70,8 @@
{
trace::entering("accu::impl::image::generic::set_value");
+ mlc_is_a(mln_value(I), Accumulator)::check();
+
I& input = exact(input_);
mln_precondition(input.is_valid());
@@ -91,6 +94,8 @@
{
trace::entering("accu::impl::image::set_value_fastest");
+ mlc_is_a(mln_value(I), Accumulator)::check();
+
I& input = exact(input_);
mln_precondition(input.is_valid());
Index: mln/accu/image/all.hh
--- mln/accu/image/all.hh (revision 3738)
+++ mln/accu/image/all.hh (working copy)
@@ -50,6 +50,7 @@
# include <mln/accu/image/set_value.hh>
# include <mln/accu/image/take_as_init.hh>
# include <mln/accu/image/take.hh>
+# include <mln/accu/image/take_n_times.hh>
# include <mln/accu/image/to_result.hh>
Index: mln/accu/image/to_result.hh
--- mln/accu/image/to_result.hh (revision 3738)
+++ mln/accu/image/to_result.hh (working copy)
@@ -67,6 +67,8 @@
{
trace::entering("accu::impl::image::generic::to_result");
+ mlc_is_a(mln_value(I), Accumulator)::check();
+
const I& input = exact(input_);
mln_precondition(input.is_valid());
@@ -93,6 +95,8 @@
{
trace::entering("accu::impl::image::to_result_fastest");
+ mlc_is_a(mln_value(I), Accumulator)::check();
+
const I& input = exact(input_);
mln_precondition(input.is_valid());
Index: mln/border/all.hh
--- mln/border/all.hh (revision 3738)
+++ mln/border/all.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2009 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
@@ -28,10 +29,9 @@
#ifndef MLN_BORDER_ALL_HH
# define MLN_BORDER_ALL_HH
-/*! \file mln/border/all.hh
- *
- * \brief File that includes all border-related routines.
- */
+/// \file mln/border/all.hh
+///
+/// File that includes all border-related routines.
namespace mln
@@ -60,6 +60,7 @@
# include <mln/border/get.hh>
# include <mln/border/mirror.hh>
# include <mln/border/resize.hh>
+# include <mln/border/resize_equal.hh>
# include <mln/border/thickness.hh>
Index: mln/border/resize_equal.hh
--- mln/border/resize_equal.hh (revision 0)
+++ mln/border/resize_equal.hh (revision 0)
@@ -0,0 +1,96 @@
+// Copyright (C) 2009 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.
+
+#ifndef MLN_BORDER_RESIZE_EQUAL_HH
+# define MLN_BORDER_RESIZE_EQUAL_HH
+
+/// \file mln/border/resize_equal.hh
+///
+/// Define a function that resizes the virtual border of a couple of
+/// images so that they eventually have the same border thickness.
+
+# include <mln/border/resize.hh>
+
+
+namespace mln
+{
+
+ namespace border
+ {
+
+ // FIXEM: Doc!
+ template <typename I, typename J>
+ void
+ resize_equal(const Image<I>& ima1, const Image<J>& ima2);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I, typename J>
+ inline
+ void
+ resize_equal(const Image<I>& ima1_, const Image<J>& ima2_)
+ {
+ trace::entering("border::resize_equal");
+
+ // Static checks.
+ mlc_equal(mln_trait_image_ext_domain(I),
+ trait::image::ext_domain::extendable)::check();
+ mlc_equal(mln_trait_image_ext_domain(J),
+ trait::image::ext_domain::extendable)::check();
+
+ const I& ima1 = exact(ima1_);
+ const J& ima2 = exact(ima2_);
+
+ // Dynamic tests.
+ mln_precondition(ima1.is_valid());
+ mln_precondition(ima2.is_valid());
+ mln_precondition(ima2.domain() == ima1.domain());
+
+ unsigned
+ b1 = border::get(ima1),
+ b2 = border::get(ima2);
+
+ if (b2 > b1)
+ border::resize(ima1, b2);
+ else
+ if (b1 > b2)
+ border::resize(ima2, b1);
+ // else no-op when b2 == b1.
+
+ trace::exiting("border::resize_equal");
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::border
+
+} // end of namespace mln
+
+
+#endif // ! MLN_BORDER_RESIZE_EQUAL_HH
Index: tests/accu/image/to_result.cc
--- tests/accu/image/to_result.cc (revision 3738)
+++ tests/accu/image/to_result.cc (working copy)
@@ -33,7 +33,10 @@
#include <mln/accu/count.hh>
#include <mln/accu/image/init.hh>
#include <mln/accu/image/to_result.hh>
-#include <mln/debug/println.hh>
+
+#include <mln/level/compare.hh>
+#include <mln/pw/cst.hh>
+#include <mln/pw/image.hh>
int main()
@@ -45,5 +48,5 @@
accu::image::init(ima);
image2d<unsigned> res = accu::image::to_result(ima);
- debug::println(res);
+ mln_assertion(res == (pw::cst(0u) | res.domain()));
}
Index: tests/accu/image/take_n_times.cc
--- tests/accu/image/take_n_times.cc (revision 3738)
+++ tests/accu/image/take_n_times.cc (working copy)
@@ -25,34 +25,32 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/// \file tests/accu/image/take.cc
+/// \file tests/accu/image/take_n_times.cc
///
-/// Tests on mln::accu::image::take.
+/// Tests on mln::accu::image::take_n_times.
#include <mln/core/image/image2d.hh>
#include <mln/data/fill.hh>
+#include <mln/level/compare.hh>
+#include <mln/pw/cst.hh>
+#include <mln/pw/image.hh>
+
#include <mln/accu/sum.hh>
#include <mln/accu/image/init.hh>
-#include <mln/accu/image/take.hh>
-
-#include <mln/debug/println.hh>
+#include <mln/accu/image/take_n_times.hh>
int main()
{
using namespace mln;
- typedef accu::sum<int> A;
+ typedef accu::sum<int,int> A;
image2d<A> ima(2, 2);
accu::image::init(ima);
- debug::println(ima);
image2d<int> dta(2, 2);
data::fill(dta, 7);
- accu::image::take(ima, dta);
- debug::println(ima);
-
- accu::image::take(ima, ima);
- debug::println(ima);
+ accu::image::take_n_times(ima, dta, dta);
+ mln_assertion(ima == (pw::cst(49) | ima.domain()));
}
Property changes on: tests/accu/image/take_n_times.cc
___________________________________________________________________
Added: svn:mergeinfo
Index: tests/accu/image/init.cc
--- tests/accu/image/init.cc (revision 3738)
+++ tests/accu/image/init.cc (working copy)
@@ -30,6 +30,10 @@
/// Tests on mln::accu::image::init.
#include <mln/core/image/image2d.hh>
+#include <mln/level/compare.hh>
+#include <mln/pw/cst.hh>
+#include <mln/pw/image.hh>
+
#include <mln/accu/count.hh>
#include <mln/accu/image/init.hh>
@@ -42,4 +46,5 @@
image2d<A> ima(2, 2);
accu::image::init(ima);
+ mln_assertion(ima == (pw::cst(0u) | ima.domain()));
}
Index: tests/accu/image/take.cc
--- tests/accu/image/take.cc (revision 3738)
+++ tests/accu/image/take.cc (working copy)
@@ -31,28 +31,29 @@
#include <mln/core/image/image2d.hh>
#include <mln/data/fill.hh>
+#include <mln/level/compare.hh>
+#include <mln/pw/cst.hh>
+#include <mln/pw/image.hh>
+
#include <mln/accu/sum.hh>
#include <mln/accu/image/init.hh>
#include <mln/accu/image/take.hh>
-#include <mln/debug/println.hh>
-
int main()
{
using namespace mln;
- typedef accu::sum<int> A;
+ typedef accu::sum<int,int> A;
image2d<A> ima(2, 2);
accu::image::init(ima);
- debug::println(ima);
image2d<int> dta(2, 2);
data::fill(dta, 7);
accu::image::take(ima, dta);
- debug::println(ima);
+ mln_assertion(ima == (pw::cst(7) | ima.domain()));
accu::image::take(ima, ima);
- debug::println(ima);
+ mln_assertion(ima == (pw::cst(14) | ima.domain()));
}
Index: tests/accu/image/Makefile.am
--- tests/accu/image/Makefile.am (revision 3738)
+++ tests/accu/image/Makefile.am (working copy)
@@ -7,12 +7,14 @@
set_value \
take \
take_as_init \
+ take_n_times \
to_result
init_SOURCES = init.cc
set_value_SOURCES = set_value.cc
take_SOURCES = take.cc
take_as_init_SOURCES = take_as_init.cc
+take_n_times_SOURCES = take_n_times.cc
to_result_SOURCES = to_result.cc
TESTS = $(check_PROGRAMS)
Index: tests/accu/image/set_value.cc
--- tests/accu/image/set_value.cc (revision 3738)
+++ tests/accu/image/set_value.cc (working copy)
@@ -33,7 +33,9 @@
#include <mln/accu/count.hh>
#include <mln/accu/image/set_value.hh>
-#include <mln/debug/println.hh>
+#include <mln/level/compare.hh>
+#include <mln/pw/cst.hh>
+#include <mln/pw/image.hh>
int main()
@@ -44,5 +46,5 @@
image2d<A> ima(2, 2);
accu::image::set_value(ima, 3);
- debug::println(ima);
+ mln_assertion(ima == (pw::cst(3u) | ima.domain()));
}
Index: tests/accu/image/take_as_init.cc
--- tests/accu/image/take_as_init.cc (revision 3738)
+++ tests/accu/image/take_as_init.cc (working copy)
@@ -30,22 +30,24 @@
/// Tests on mln::accu::image::take_as_init.
#include <mln/core/image/image2d.hh>
+#include <mln/level/compare.hh>
+#include <mln/pw/cst.hh>
+#include <mln/pw/image.hh>
+
#include <mln/accu/sum.hh>
#include <mln/accu/image/take_as_init.hh>
-#include <mln/debug/println.hh>
-
int main()
{
using namespace mln;
- typedef accu::sum<int> A;
+ typedef accu::sum<int,int> A;
image2d<A> ima(2, 2);
accu::image::take_as_init(ima, 3);
- debug::println(ima);
+ mln_assertion(ima == (pw::cst(3) | ima.domain()));
accu::image::take_as_init(ima, ima);
- debug::println(ima);
+ mln_assertion(ima == (pw::cst(3) | ima.domain()));
}
Index: tests/border/resize.cc
--- tests/border/resize.cc (revision 3738)
+++ tests/border/resize.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2009 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
@@ -25,29 +26,28 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/border/resize.cc
- *
- * \brief Tests on mln::border::resize.
- */
-
+/// \file tests/border/resize.cc
+///
+/// Tests on mln::border::resize.
#include <mln/core/image/image2d.hh>
-#include <mln/value/int_u8.hh>
#include <mln/border/resize.hh>
-#include <mln/border/get.hh>
-using namespace mln;
-int
-main (void)
+int main()
{
- unsigned border = 1;
- unsigned new_border = 3;
+ using namespace mln;
+
+ const unsigned
+ border = 1,
+ new_border = 3;
+
+ image2d<int> ima(3, 2, border);
+ mln_assertion(ima.border() == border);
- image2d<value::int_u8> ima(3, 2, border);
- mln_assertion(border::get(ima) == border);
border::resize (ima, new_border);
- mln_assertion(border::get(ima) == new_border);
+ mln_assertion(ima.border() == new_border);
+
border::resize (ima, border);
- mln_assertion(border::get(ima) == border);
+ mln_assertion(ima.border() == border);
}
Index: tests/border/Makefile.am
--- tests/border/Makefile.am (revision 3738)
+++ tests/border/Makefile.am (working copy)
@@ -11,6 +11,7 @@
find \
get \
mirror \
+ resize_equal \
resize_image1d_1 \
resize_image1d_2 \
resize_image1d_3 \
@@ -32,6 +33,7 @@
find_SOURCES = find.cc
get_SOURCES = get.cc
mirror_SOURCES = mirror.cc
+resize_equal_SOURCES = resize_equal.cc
resize_image1d_1_SOURCES = resize_image1d_1.cc
resize_image1d_2_SOURCES = resize_image1d_2.cc
resize_image1d_3_SOURCES = resize_image1d_3.cc
Index: tests/border/resize_equal.cc
--- tests/border/resize_equal.cc (revision 0)
+++ tests/border/resize_equal.cc (revision 0)
@@ -0,0 +1,43 @@
+// Copyright (C) 2009 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/border/resize_equal.cc
+///
+/// Tests on mln::border::resize_equal.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/border/resize_equal.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ image2d<int> ima1(1,1, 1), ima2(1,1, 2);
+ border::resize_equal(ima1, ima2);
+ mln_assertion(ima1.border() == 2);
+}