olena: olena-2.0-853-g11434c3 Improve tests on mln::border::mirror.

* tests/border/mirror.cc: Revamp. * tests/border/Makefile.am (check_PROGRAMS): Reenable mirror_full. --- milena/ChangeLog | 7 ++++ milena/tests/border/Makefile.am | 5 +-- milena/tests/border/mirror.cc | 74 ++++++++++++++++++++++----------------- 3 files changed, 51 insertions(+), 35 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index a2e295e..acf88b9 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,3 +1,10 @@ +2014-05-20 Roland Levillain <roland@lrde.epita.fr> + + Improve tests on mln::border::mirror. + + * tests/border/mirror.cc: Revamp. + * tests/border/Makefile.am (check_PROGRAMS): Reenable mirror_full. + 2012-10-02 Guillaume Lazzara <z@lrde.epita.fr> Fix a precondition (Trac ticket #256). diff --git a/milena/tests/border/Makefile.am b/milena/tests/border/Makefile.am index 64c8197..a268a5b 100644 --- a/milena/tests/border/Makefile.am +++ b/milena/tests/border/Makefile.am @@ -1,5 +1,5 @@ -# Copyright (C) 2007, 2008, 2009, 2010, 2011 EPITA Research and Development -# Laboratory (LRDE). +# Copyright (C) 2007, 2008, 2009, 2010, 2011, 2014 EPITA Research and +# Development Laboratory (LRDE). # # This file is part of Olena. # @@ -26,6 +26,7 @@ check_PROGRAMS = \ find \ get \ mirror \ + mirror_full \ resize_equal \ resize_image1d_1 \ resize_image1d_2 \ diff --git a/milena/tests/border/mirror.cc b/milena/tests/border/mirror.cc index 09435e5..58a038e 100644 --- a/milena/tests/border/mirror.cc +++ b/milena/tests/border/mirror.cc @@ -1,5 +1,5 @@ -// Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development -// Laboratory (LRDE) +// Copyright (C) 2007, 2008, 2009, 2011, 2014 EPITA Research and Development +// Laboratory (LRDE). // // This file is part of Olena. // @@ -24,7 +24,7 @@ // exception does not however invalidate any other reasons why the // executable file might be covered by the GNU General Public License. -/// \file +// Exercise mln::border::mirror. #include <mln/core/image/image1d.hh> #include <mln/core/image/image2d.hh> @@ -35,46 +35,54 @@ #include <mln/data/paste_without_localization.hh> #include <mln/data/compare.hh> -using namespace mln; - int -main (void) +main() { - { - image1d<int> ima(2, 3); - debug::iota(ima); - border::mirror(ima); - mln_assertion(opt::element(ima, 0) == 2); - mln_assertion(opt::element(ima, 1) == 2); - mln_assertion(opt::element(ima, 2) == 1); - mln_assertion(opt::element(ima, 3) == 1); - mln_assertion(opt::element(ima, 4) == 2); - mln_assertion(opt::element(ima, 5) == 2); - mln_assertion(opt::element(ima, 6) == 1); - mln_assertion(opt::element(ima, 7) == 1); - } - + using namespace mln; - // Image2d + // image1d. { - unsigned ref_data[6][7] = { - { 1, 1, 4, 5, 6, 3, 3 }, - { 1, 1, 1, 2, 3, 3, 3 }, - { 2, 1, 1, 2, 3, 3, 2 }, - { 5, 4, 4, 5, 6, 6, 5 }, - { 4, 4, 4, 5, 6, 6, 6 }, - { 4, 4, 1, 2, 3, 6, 6 } - }; + // A 2-pixel 1D image with a 3-pixel border. + image1d<unsigned> input(2, 3); + debug::iota(input); + border::mirror(input); + // Data are framed; other values form the border. + unsigned ref_data[8] = + // ,-------------. + { 2, 2, 1, /* | */ 1, 2, /* | */ 2, 1, 1 }; + // `-------------' + image1d<unsigned> ref = make::image(ref_data); - image2d<unsigned> ref = make::image(ref_data); + image1d<unsigned> output(8, 0); + data::paste_without_localization(extended_to(input, input.vbbox()), + output); + mln_assertion(output == ref); + } + + // image2d. + { + // A 2x3-pixel 2D image with a 2-pixel border. image2d<unsigned> input(2, 3, 2); - image2d<unsigned> res(6, 7, 0); debug::iota(input, 0); border::mirror(input); - data::paste_without_localization(extended_to(input, input.vbbox()), res); + // Data are framed; other values form the border. + unsigned ref_data[6][7] = { + { 1, 1, 4, 5, 6, 3, 3 }, + { 1, 1, 1, 2, 3, 3, 3 }, + // ,----------------. + { 2, 1, /* | */ 1, 2, 3, /* | */ 3, 2 }, + { 5, 4, /* | */ 4, 5, 6, /* | */ 6, 5 }, + // `----------------' + { 4, 4, 4, 5, 6, 6, 6 }, + { 4, 4, 1, 2, 3, 6, 6 } + }; + image2d<unsigned> ref = make::image(ref_data); - mln_assertion(res == ref); + image2d<unsigned> output(6, 7, 0); + data::paste_without_localization(extended_to(input, input.vbbox()), + output); + mln_assertion(output == ref); } } -- 1.7.10.4
participants (1)
-
Roland Levillain