3998: Cleanup tests io::p*m tests and add new tests for io::p*ms.

* mln/io/pgms/load.hh, * mln/io/pnms/load.hh, * mln/io/ppms/load.hh: fix invalid calls to pnm::load. * tests/io/pbm/pbm.cc, * tests/io/pgm/pgm.cc, * tests/io/ppm/ppm.cc: remove tests related to routines located in namespace p*ms. * tests/io/Makefile.am, * tests/io/pbms/Makefile.am, * tests/io/pgms/Makefile.am, * tests/io/ppms/Makefile.am, * tests/io/pbms/load.cc, * tests/io/pgms/load.cc, * tests/io/ppms/load.cc: new tests. --- milena/ChangeLog | 22 ++++++++++++++++ milena/mln/io/pgms/load.hh | 2 +- milena/mln/io/pnms/load.hh | 35 +++++++++++++++++++++++++- milena/mln/io/ppms/load.hh | 2 +- milena/tests/io/Makefile.am | 5 +++- milena/tests/io/pbm/pbm.cc | 16 ------------ milena/tests/io/pbms/Makefile.am | 10 +++++++ milena/tests/io/{pbm/pbm.cc => pbms/load.cc} | 28 ++++++-------------- milena/tests/io/pgm/pgm.cc | 20 -------------- milena/tests/io/pgms/Makefile.am | 10 +++++++ milena/tests/io/{pgm/pgm.cc => pgms/load.cc} | 32 ++++------------------- milena/tests/io/ppm/ppm.cc | 17 ------------ milena/tests/io/ppms/Makefile.am | 10 +++++++ milena/tests/io/{ppm/ppm.cc => ppms/load.cc} | 31 ++++++++++------------ 14 files changed, 120 insertions(+), 120 deletions(-) create mode 100644 milena/tests/io/pbms/Makefile.am copy milena/tests/io/{pbm/pbm.cc => pbms/load.cc} (77%) create mode 100644 milena/tests/io/pgms/Makefile.am copy milena/tests/io/{pgm/pgm.cc => pgms/load.cc} (74%) create mode 100644 milena/tests/io/ppms/Makefile.am copy milena/tests/io/{ppm/ppm.cc => ppms/load.cc} (76%) diff --git a/milena/ChangeLog b/milena/ChangeLog index 3887983..8d7d5a3 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,27 @@ 2009-06-05 Guillaume Lazzara <guillaume.lazzara@lrde.epita.fr> + Cleanup tests io::p*m tests and add new tests for io::p*ms. + + * mln/io/pgms/load.hh, + * mln/io/pnms/load.hh, + * mln/io/ppms/load.hh: fix invalid calls to pnm::load. + + + * tests/io/pbm/pbm.cc, + * tests/io/pgm/pgm.cc, + * tests/io/ppm/ppm.cc: remove tests related to routines located in + namespace p*ms. + + * tests/io/Makefile.am, + * tests/io/pbms/Makefile.am, + * tests/io/pgms/Makefile.am, + * tests/io/ppms/Makefile.am, + * tests/io/pbms/load.cc, + * tests/io/pgms/load.cc, + * tests/io/ppms/load.cc: new tests. + +2009-06-05 Guillaume Lazzara <guillaume.lazzara@lrde.epita.fr> + Improve documentation build system. * doc/Makefile.am, diff --git a/milena/mln/io/pgms/load.hh b/milena/mln/io/pgms/load.hh index d0240b7..362c9c2 100644 --- a/milena/mln/io/pgms/load.hh +++ b/milena/mln/io/pgms/load.hh @@ -74,7 +74,7 @@ namespace mln { trace::entering("mln::io::pgms::load"); - io::pnms::load<image2d<V> >(PGM, ima, filenames); + io::pnms::load<V>(PGM, ima, filenames); trace::exiting("mln::io::pgms::load"); } diff --git a/milena/mln/io/pnms/load.hh b/milena/mln/io/pnms/load.hh index d494039..117f586 100644 --- a/milena/mln/io/pnms/load.hh +++ b/milena/mln/io/pnms/load.hh @@ -42,6 +42,7 @@ # include <mln/core/image/image3d.hh> # include <mln/value/int_u8.hh> # include <mln/io/pnm/load.hh> +# include <mln/io/pbm/load.hh> # include <mln/make/image3d.hh> @@ -60,12 +61,19 @@ namespace mln /// \param[out] ima A reference to the 3D image which will receive /// data. /// \param[in] filenames The list of 2D images to load.. - /// + // template <typename V> void load(char type, image3d<V>& ima, const util::array<std::string>& filenames); + /// \overload + // + void load(char type, + image3d<bool>& ima, + const util::array<std::string>& filenames); + + # ifndef MLN_INCLUDE_ONLY @@ -92,6 +100,31 @@ namespace mln trace::exiting("mln::io::pnms::load"); } + + inline + void load(char type, + image3d<bool>& ima, + const util::array<std::string>& filenames) + { + trace::entering("mln::io::pnms::load"); + mln_precondition(!filenames.is_empty()); + (void) type; + + util::array< image2d<bool> > slices; + + for (unsigned i = 0; i < filenames.nelements(); ++i) + { + image2d<bool> tmp; + io::pbm::load(tmp, filenames[i]); + slices.append(tmp); + } + + ima = make::image3d(slices); + + trace::exiting("mln::io::pnms::load"); + } + + # endif // ! MLN_INCLUDE_ONLY } // end of namespace mln::io::pnms diff --git a/milena/mln/io/ppms/load.hh b/milena/mln/io/ppms/load.hh index f2500c5..e7964d0 100644 --- a/milena/mln/io/ppms/load.hh +++ b/milena/mln/io/ppms/load.hh @@ -72,7 +72,7 @@ namespace mln { trace::entering("mln::io::ppms::load"); - io::pnms::load<image2d<V> >(PPM, ima, filenames); + io::pnms::load<V>(PPM, ima, filenames); trace::exiting("mln::io::ppms::load"); } diff --git a/milena/tests/io/Makefile.am b/milena/tests/io/Makefile.am index 6f91495..c4d5cc3 100644 --- a/milena/tests/io/Makefile.am +++ b/milena/tests/io/Makefile.am @@ -10,10 +10,13 @@ SUBDIRS = \ dump \ off \ pbm \ + pbms \ pfm \ pgm \ + pgms \ pnm \ - ppm + ppm \ + ppms ## ------------------------------------------------- ## ## I/O routines depending on a third-party library. ## diff --git a/milena/tests/io/pbm/pbm.cc b/milena/tests/io/pbm/pbm.cc index 1a90eae..7bc7214 100644 --- a/milena/tests/io/pbm/pbm.cc +++ b/milena/tests/io/pbm/pbm.cc @@ -36,7 +36,6 @@ #include <mln/io/pbm/load.hh> #include <mln/io/pbm/save.hh> -#include <mln/io/pbms/load.hh> #include <mln/data/compare.hh> @@ -53,21 +52,6 @@ int main() mln_assertion(pic == pic2); - - pic2(point2d(0,0)) = true; - io::pbm::save(pic2, "out.pbm"); - - util::array<std::string> files(2); - files[0] = MLN_IMG_DIR "/picasso.pbm"; - files[1] = "out.pbm"; - - image3d<bool> ima3d; - io::pbms::load(ima3d, files); - - mln_assertion(ima3d.nslices() == 2); - mln_assertion(slice(ima3d, 0) == pic); - mln_assertion(slice(ima3d, 1) == pic2); - } diff --git a/milena/tests/io/pbms/Makefile.am b/milena/tests/io/pbms/Makefile.am new file mode 100644 index 0000000..3dbd00b --- /dev/null +++ b/milena/tests/io/pbms/Makefile.am @@ -0,0 +1,10 @@ +## Process this file through Automake to create Makefile.in. + +include $(top_srcdir)/milena/tests/tests.mk + +check_PROGRAMS = \ + load + +load_SOURCES = load.cc + +TESTS = $(check_PROGRAMS) diff --git a/milena/tests/io/pbm/pbm.cc b/milena/tests/io/pbms/load.cc similarity index 77% copy from milena/tests/io/pbm/pbm.cc copy to milena/tests/io/pbms/load.cc index 1a90eae..3e53523 100644 --- a/milena/tests/io/pbm/pbm.cc +++ b/milena/tests/io/pbms/load.cc @@ -1,5 +1,5 @@ -// Copyright (C) 2007, 2008, 2009 EPITA Research and Development -// Laboratory (LRDE) +// Copyright (C) 2009 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of the Milena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -26,13 +26,14 @@ // reasons why the executable file might be covered by the GNU General // Public License. -/// \file tests/io/pbm/pbm.cc +/// \file tests/io/pbms/load.cc /// -/// Test on mln::io::pbm::. +/// Test on mln::io::pbms::load.cc #include <mln/core/image/image2d.hh> #include <mln/core/image/image3d.hh> #include <mln/core/image/dmorph/slice_image.hh> +#include <mln/core/routine/duplicate.hh> #include <mln/io/pbm/load.hh> #include <mln/io/pbm/save.hh> @@ -47,18 +48,14 @@ int main() { using namespace mln; - image2d<bool> pic = io::pbm::load(MLN_IMG_DIR "/picasso.pbm"); - io::pbm::save(pic, "out.pbm"); - image2d<bool> pic2 = io::pbm::load("out.pbm"); - - mln_assertion(pic == pic2); - + image2d<bool> pic = io::pbm::load(MLN_IMG_DIR "/tiny.pbm"); + image2d<bool> pic2 = duplicate(pic); pic2(point2d(0,0)) = true; io::pbm::save(pic2, "out.pbm"); util::array<std::string> files(2); - files[0] = MLN_IMG_DIR "/picasso.pbm"; + files[0] = MLN_IMG_DIR "/tiny.pbm"; files[1] = "out.pbm"; image3d<bool> ima3d; @@ -71,12 +68,3 @@ int main() } -// sample binary image to test with xv, imview, and display -// to bring into the fore the binary image bug with raw pbm. - -// | | | | - -// | | - - - -// | - - - - -// - - - - - -// - - - - - -// - - - - - diff --git a/milena/tests/io/pgm/pgm.cc b/milena/tests/io/pgm/pgm.cc index 2d93006..0838cb9 100644 --- a/milena/tests/io/pgm/pgm.cc +++ b/milena/tests/io/pgm/pgm.cc @@ -41,7 +41,6 @@ #include <mln/io/pgm/load.hh> #include <mln/io/pgm/save.hh> -#include <mln/io/pgms/load.hh> #include <mln/data/compare.hh> @@ -73,23 +72,4 @@ int main() mln_assertion(lena2 == lena); } - { - image2d<int_u8> lena = io::pgm::load<int_u8>(MLN_IMG_DIR "/lena.pgm"); - - image2d<int_u8> lena2 = duplicate(lena); - lena2(point2d(0,0)) = 200; - - io::pgm::save(lena2, "out.pgm"); - - util::array<std::string> files(2); - files[0] = MLN_IMG_DIR "/lena.pgm"; - files[1] = "out.pgm"; - - image3d<int_u8> ima3d; - io::pgms::load(ima3d, files); - - mln_assertion(ima3d.nslices() == 2); - mln_assertion(slice(ima3d, 0) == lena); - mln_assertion(slice(ima3d, 1) == lena2); - } } diff --git a/milena/tests/io/pgms/Makefile.am b/milena/tests/io/pgms/Makefile.am new file mode 100644 index 0000000..3dbd00b --- /dev/null +++ b/milena/tests/io/pgms/Makefile.am @@ -0,0 +1,10 @@ +## Process this file through Automake to create Makefile.in. + +include $(top_srcdir)/milena/tests/tests.mk + +check_PROGRAMS = \ + load + +load_SOURCES = load.cc + +TESTS = $(check_PROGRAMS) diff --git a/milena/tests/io/pgm/pgm.cc b/milena/tests/io/pgms/load.cc similarity index 74% copy from milena/tests/io/pgm/pgm.cc copy to milena/tests/io/pgms/load.cc index 2d93006..9913077 100644 --- a/milena/tests/io/pgm/pgm.cc +++ b/milena/tests/io/pgms/load.cc @@ -1,5 +1,5 @@ -// Copyright (C) 2007, 2008, 2009 EPITA Research and Development -// Laboratory (LRDE) +// Copyright (C) 2009 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of the Milena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -26,11 +26,9 @@ // reasons why the executable file might be covered by the GNU General // Public License. -/// \file tests/io/pgm/pgm.cc +/// \file tests/io/pgms/load.cc /// -/// Test on mln::io::pgm::load and mln::io::pgm::save. - - +/// Test on mln::io::pgms::load. #include <mln/core/image/image2d.hh> #include <mln/core/image/image3d.hh> @@ -56,25 +54,7 @@ int main() using value::int_u8; { - image2d<int_u8> lena = io::pgm::load<int_u8>(MLN_IMG_DIR "/lena.pgm"); - io::pgm::save(lena, "out.pgm"); - - image2d<int_u8> lena2 = io::pgm::load<int_u8>("out.pgm"); - mln_assertion(lena2 == lena); - } - - { - image2d< value::int_u<8> > lena, lena2; - io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm"); - - io::pgm::save(lena, "out.pgm"); - - io::pgm::load(lena2, "out.pgm"); - mln_assertion(lena2 == lena); - } - - { - image2d<int_u8> lena = io::pgm::load<int_u8>(MLN_IMG_DIR "/lena.pgm"); + image2d<int_u8> lena = io::pgm::load<int_u8>(MLN_IMG_DIR "/tiny.pgm"); image2d<int_u8> lena2 = duplicate(lena); lena2(point2d(0,0)) = 200; @@ -82,7 +62,7 @@ int main() io::pgm::save(lena2, "out.pgm"); util::array<std::string> files(2); - files[0] = MLN_IMG_DIR "/lena.pgm"; + files[0] = MLN_IMG_DIR "/tiny.pgm"; files[1] = "out.pgm"; image3d<int_u8> ima3d; diff --git a/milena/tests/io/ppm/ppm.cc b/milena/tests/io/ppm/ppm.cc index bde91f4..8820ebf 100644 --- a/milena/tests/io/ppm/ppm.cc +++ b/milena/tests/io/ppm/ppm.cc @@ -38,7 +38,6 @@ #include <mln/io/ppm/load.hh> #include <mln/io/ppm/save.hh> -#include <mln/io/ppms/load.hh> #include <mln/data/compare.hh> @@ -60,21 +59,5 @@ int main() image2d<rgb8> lena2; io::ppm::load(lena2, "out.ppm"); mln_assertion(lena2 == lena); - - - - lena2(point2d(0,0)) = literal::green; - io::ppm::save(lena2, "out.ppm"); - - util::array<std::string> files(2); - files[0] = MLN_IMG_DIR "/lena.ppm"; - files[1] = "out.ppm"; - - image3d<rgb8> ima3d; - io::ppms::load(ima3d, files); - - mln_assertion(ima3d.nslices() == 2); - mln_assertion(slice(ima3d, 0) == lena); - mln_assertion(slice(ima3d, 1) == lena2); } diff --git a/milena/tests/io/ppms/Makefile.am b/milena/tests/io/ppms/Makefile.am new file mode 100644 index 0000000..3dbd00b --- /dev/null +++ b/milena/tests/io/ppms/Makefile.am @@ -0,0 +1,10 @@ +## Process this file through Automake to create Makefile.in. + +include $(top_srcdir)/milena/tests/tests.mk + +check_PROGRAMS = \ + load + +load_SOURCES = load.cc + +TESTS = $(check_PROGRAMS) diff --git a/milena/tests/io/ppm/ppm.cc b/milena/tests/io/ppms/load.cc similarity index 76% copy from milena/tests/io/ppm/ppm.cc copy to milena/tests/io/ppms/load.cc index bde91f4..b510853 100644 --- a/milena/tests/io/ppm/ppm.cc +++ b/milena/tests/io/ppms/load.cc @@ -1,5 +1,5 @@ -// Copyright (C) 2007, 2008, 2009 EPITA Research and Development -// Laboratory (LRDE) +// Copyright (C) 2009 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of the Milena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -26,14 +26,15 @@ // reasons why the executable file might be covered by the GNU General // Public License. -/// \file tests/io/ppm/ppm.cc +/// \file tests/io/ppms/load.cc /// -/// Test on mln::io::ppm::load and mln::io::ppm::save. - +/// Test on mln::io::ppms::load.cc #include <mln/core/image/image2d.hh> #include <mln/core/image/image3d.hh> #include <mln/core/image/dmorph/slice_image.hh> +#include <mln/core/routine/duplicate.hh> + #include <mln/value/rgb8.hh> #include <mln/io/ppm/load.hh> @@ -54,27 +55,23 @@ int main() using namespace mln; using value::rgb8; - image2d<rgb8> lena = io::ppm::load<rgb8>(MLN_IMG_DIR "/lena.ppm"); - io::ppm::save(lena, "out.ppm"); - - image2d<rgb8> lena2; - io::ppm::load(lena2, "out.ppm"); - mln_assertion(lena2 == lena); - + image2d<rgb8> ima = io::ppm::load<rgb8>(MLN_IMG_DIR "/fly.ppm"); + io::ppm::save(ima, "out.ppm"); + image2d<rgb8> ima2 = duplicate(ima); - lena2(point2d(0,0)) = literal::green; - io::ppm::save(lena2, "out.ppm"); + ima2(point2d(0,0)) = literal::green; + io::ppm::save(ima2, "out.ppm"); util::array<std::string> files(2); - files[0] = MLN_IMG_DIR "/lena.ppm"; + files[0] = MLN_IMG_DIR "/fly.ppm"; files[1] = "out.ppm"; image3d<rgb8> ima3d; io::ppms::load(ima3d, files); mln_assertion(ima3d.nslices() == 2); - mln_assertion(slice(ima3d, 0) == lena); - mln_assertion(slice(ima3d, 1) == lena2); + mln_assertion(slice(ima3d, 0) == ima); + mln_assertion(slice(ima3d, 1) == ima2); } -- 1.5.6.5
participants (1)
-
Guillaume Lazzara