1653: Fix some tests and get rid of many warnings.

https://svn.lrde.epita.fr/svn/oln/trunk/milena Index: ChangeLog from Roland Levillain <roland@lrde.epita.fr> Fix some tests and get rid of many warnings. * mln/value/int_u_sat.hh (int_u_sat<n>::int_u_sat(int)) (int_u_sat<n>::operator=(int)) * tests/accu/max_h.cc, * tests/accu/median.cc, * tests/accu/min_h.cc, * tests/labeling/level.cc, * tests/line_piter.cc, * tests/linear_log.cc, * tests/win/disk2d.cc, * tests/win/octagon2d.cc: Pacify the compiler w.r.t. comparisons between signed and unsigned values. * tests/border/fill.cc: Likewise. (check): Fix the return type of this function. * tests/win/diag2d.cc: Use English in messages, not French. * tests/value/graylevel.cc: Test the division of a gl8 value by an int_s8 value. * tests/line_convolve.cc: Adjust the call to mln::io::load to match the current interface. * tests/value/float01_bis.cc, * tests/sparse_image.cc, * tests/rle_image.cc Disable these tests. * tests/Makefile.am (check_PROGRAMS): Remove chamfer, fun_x2x_composed, fun_x2x_rotation, fun_x2x_translation, h_vec and run_pset. (chamfer_SOURCES, fun_x2x_composed_SOURCES) (fun_x2x_rotation_SOURCES, fun_x2x_translation_SOURCES) (run_pset_SOURCES): Remove. (h_vec_SOURCES): Move... * tests/core/Makefile.am: ...here. (check_PROGRAMS): Add h_vec. * tests/value/builtin.cc: Move... * tests/value/builtin/builtin.cc: ...here. Pacify the compiler w.r.t. unused variables. * tests/value/Makefile.am (check_PROGRAMS): Remove builtin. (builtin_SOURCES): Move... * tests/value/builtin/Makefile.am: ...here. (check_PROGRAMS, TESTS): New. mln/value/int_u_sat.hh | 11 ++++++----- tests/Makefile.am | 17 +++-------------- tests/accu/max_h.cc | 4 ++-- tests/accu/median.cc | 6 +++--- tests/accu/min_h.cc | 4 ++-- tests/border/fill.cc | 8 ++++---- tests/core/Makefile.am | 2 ++ tests/labeling/level.cc | 2 +- tests/line_convolve.cc | 6 +++--- tests/line_piter.cc | 4 ++-- tests/linear_log.cc | 2 +- tests/rle_image.cc | 12 ++++++++++++ tests/sparse_image.cc | 13 +++++++++++++ tests/value/Makefile.am | 2 -- tests/value/builtin/Makefile.am | 8 ++++++++ tests/value/builtin/builtin.cc | 6 +++++- tests/value/float01_bis.cc | 7 +++++++ tests/value/graylevel.cc | 13 +++++++++++-- tests/value/int_u8.cc | 2 ++ tests/win/diag2d.cc | 4 ++-- tests/win/disk2d.cc | 5 +++-- tests/win/octagon2d.cc | 4 ++-- 22 files changed, 94 insertions(+), 48 deletions(-) Index: tests/linear_log.cc --- tests/linear_log.cc (revision 1652) +++ tests/linear_log.cc (working copy) @@ -71,6 +71,6 @@ { int_u8 min, max; estim::min_max(out, min, max); - mln_assertion(min == 0 && max == 255); + mln_assertion(min == 0u && max == 255u); } } Index: tests/accu/max_h.cc --- tests/accu/max_h.cc (revision 1652) +++ tests/accu/max_h.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -58,5 +58,5 @@ a.take(234); a.take(234); a.take(234); - mln_assertion(a.to_result() == 234); + mln_assertion(a.to_result() == 234u); } Index: tests/accu/median.cc --- tests/accu/median.cc (revision 1652) +++ tests/accu/median.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -54,7 +54,7 @@ med.take(1); med.take(0); - mln_assertion(med.to_result() == 5); + mln_assertion(med.to_result() == 5u); } { @@ -64,6 +64,6 @@ med.take(7); med.take(0); - mln_assertion(med.to_result() == 7); + mln_assertion(med.to_result() == 7u); } } Index: tests/accu/min_h.cc --- tests/accu/min_h.cc (revision 1652) +++ tests/accu/min_h.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -58,5 +58,5 @@ a.take(234); a.take(234); a.take(234); - mln_assertion(a.to_result() == 42); + mln_assertion(a.to_result() == 42u); } Index: tests/value/float01_bis.cc --- tests/value/float01_bis.cc (revision 1652) +++ tests/value/float01_bis.cc (working copy) @@ -34,8 +34,14 @@ #include <mln/value/float01_8.hh> #include <mln/value/float01_16.hh> + int main() { + /* FIXME: The contents of this test seens to have nothing to do with + floats. I (Roland) suspect a copy-and-paste error here. Either + rename the test or turn it into an actual test on floats or get + rid of it. */ +#if 0 using namespace mln::value; float01_8 a; @@ -50,4 +56,5 @@ c = (a * 2) / 2; assert(c == white); +#endif } Index: tests/value/int_u8.cc --- tests/value/int_u8.cc (revision 1652) +++ tests/value/int_u8.cc (working copy) @@ -49,6 +49,7 @@ // Assignment. { i = 51; + // FIXME: Triggers a warning about signed vs unsigned comparison. sym_compare_assert(i, ==, 51); i = 51u; @@ -185,6 +186,7 @@ c /= 2; sym_compare_assert(c, ==, 50.f); + // FIXME: Triggers a warning about signed vs unsigned comparison. d /= 2.4f; } Index: tests/value/builtin/Makefile.am --- tests/value/builtin/Makefile.am (revision 1652) +++ tests/value/builtin/Makefile.am (working copy) @@ -1,3 +1,11 @@ ## Process this file through Automake to create Makefile.in -*- Makefile -*- include $(top_srcdir)/milena/tests/tests.mk + +check_PROGRAMS = \ + builtin + +# FIXME: Rename this test, as `builtin' is not enough relevant. +builtin_SOURCES = builtin.cc + +TESTS = $(check_PROGRAMS) Index: tests/value/builtin/builtin.cc --- tests/value/builtin/builtin.cc (revision 1651) +++ tests/value/builtin/builtin.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -114,9 +114,13 @@ { mln::trait::solve_binary< trait::op::test_2, int, value::scalar_< value::int_u8 > >::ret tmp; double& d = tmp; + // Avoid a warning about unused variable D. + d = d; } { mln::trait::solve_unary< trait::op::test, int >::ret tmp; double& d = tmp; + // Avoid a warning about unused variable D. + d = d; } } Index: tests/value/Makefile.am --- tests/value/Makefile.am (revision 1652) +++ tests/value/Makefile.am (working copy) @@ -12,7 +12,6 @@ check_PROGRAMS = \ bool \ - builtin \ equiv \ float01_bis \ float01 \ @@ -33,7 +32,6 @@ # rgb_full bool_SOURCES = bool.cc -builtin_SOURCES = builtin.cc equiv_SOURCES = equiv.cc float01_bis_SOURCES = float01_bis.cc float01_SOURCES = float01.cc Index: tests/value/graylevel.cc --- tests/value/graylevel.cc (revision 1652) +++ tests/value/graylevel.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -37,6 +37,7 @@ #include <mln/value/glf.hh> #include <mln/value/int_u8.hh> +#include <mln/value/int_s8.hh> #include <mln/value/float01_f.hh> #include <mln/value/float01_.hh> @@ -127,12 +128,20 @@ mln_assertion(a / true == a); // gl8 / Integer + /* FIXME: The compiler emits a warning about a comparison between + signed and unsigned for the first line, but not for the second. + This behavior is strange, since + + a * int_u(23); + + triggers no warning. See whether traits and conversions are + handled symmetrically for `*' and `/'. */ a / int_u8(23); + a / int_s8(23); // gl8 / Floating a / float01_f(.23); a / float01_<16>(.23); - } { Index: tests/border/fill.cc --- tests/border/fill.cc (revision 1652) +++ tests/border/fill.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -38,7 +38,7 @@ using namespace mln; -int +void check(int size, int border) { int w = size + 2 * border; @@ -48,11 +48,11 @@ border::fill (ima, 42); for(int i = 0; i < ww; ++i) if ((i / w < border) || (i / w > border + size)) - mln_assertion (ima[i] == 42); + mln_assertion (ima[i] == 42u); else if ((i % w < border) && (border + size <= i % w)) - mln_assertion (ima[i] == 42); + mln_assertion (ima[i] == 42u); } int Index: tests/win/disk2d.cc --- tests/win/disk2d.cc (revision 1652) +++ tests/win/disk2d.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -53,7 +53,8 @@ { mln_assertion(((abs(x) <= 27) && (abs(y) <= 27)) || !disk.has(dpoint2d(y, x))); - mln_assertion(((x * x + y * y) <= l2) == (disk.has(dpoint2d(y, x))) || + mln_assertion(((x * x + y * y) <= static_cast<int>(l2)) == + (disk.has(dpoint2d(y, x))) || abs(x) > 27 || abs(y) > 27); } Index: tests/win/octagon2d.cc --- tests/win/octagon2d.cc (revision 1652) +++ tests/win/octagon2d.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -52,7 +52,7 @@ { mln_assertion(((abs(x) <= 6) && (abs(y) <= 6)) || !oct.has(dpoint2d(y, x))); - mln_assertion((abs(x) + abs(y) <= l / 2 + l / 6) == + mln_assertion((abs(x) + abs(y) <= static_cast<int>(l / 2 + l / 6)) == (oct.has(dpoint2d(y, x))) || abs(x) > 2 || abs(y) > 2); Index: tests/win/diag2d.cc --- tests/win/diag2d.cc (revision 1652) +++ tests/win/diag2d.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -57,7 +57,7 @@ << ", y = " << y << " : " - << ((diag.has(dpoint2d(x, y))) ? "VRAI" : "FAUX") + << ((diag.has(dpoint2d(x, y))) ? "True" : "False") << std::endl; mln_assertion((x == -y) == (diag.has(dpoint2d(y, x))) || abs(x) > 2 || abs(y) > 2); Index: tests/labeling/level.cc --- tests/labeling/level.cc (revision 1652) +++ tests/labeling/level.cc (working copy) @@ -60,7 +60,7 @@ { image2d<unsigned> labels = labeling::level(lena, l, c4(), n); unsigned npix = - accu::compute<accu::count>(labels | (pw::value(labels) != pw::cst(0))); + accu::compute<accu::count>(labels | (pw::value(labels) != pw::cst(0u))); npixels += npix; } mln_assertion(npixels == lena.npoints()); Index: tests/sparse_image.cc --- tests/sparse_image.cc (revision 1652) +++ tests/sparse_image.cc (working copy) @@ -29,6 +29,14 @@ * * \brief Tests on mln::sparse_image. */ + + +// FIXME: There's already a test named sparse_image.cc in tests/core. +// It seems to be pretty old material, not in sync with the current +// version of sparse_image for a long time. Disable it before asking +// for its deletion. + + #include <mln/core/image2d.hh> #include <mln/core/sparse_image.hh> #include <mln/core/sparse_encode.hh> @@ -70,6 +78,9 @@ int main() { + // FIXME: Disabled (cf. supra). +#if 0 + mln::point2d p, q, r; p = mln::make::point2d(0, 1); q = mln::make::point2d(3, 0); @@ -109,4 +120,6 @@ // std::cout << std::endl; return 0; + +#endif } Index: tests/core/Makefile.am --- tests/core/Makefile.am (revision 1652) +++ tests/core/Makefile.am (working copy) @@ -6,6 +6,7 @@ category \ clone \ exact \ + h_vec \ initialize \ mesh_elt_window \ mesh_image \ @@ -25,6 +26,7 @@ category_SOURCES = category.cc clone_SOURCES = clone.cc exact_SOURCES = exact.cc +h_vec_SOURCES = h_vec.cc initialize_SOURCES = initialize.cc mesh_elt_window_SOURCES = mesh_elt_window.cc mesh_image_SOURCES = mesh_image.cc Index: tests/line_convolve.cc --- tests/line_convolve.cc (revision 1652) +++ tests/line_convolve.cc (working copy) @@ -52,9 +52,9 @@ border::thickness = 4; - image2d<int_u8> - lena = io::pgm::load(MLN_IMG_DIR "/lena.pgm"), - out(lena.domain()); + image2d<int_u8> lena; + io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm"); + image2d<int_u8> out(lena.domain()); image2d<float> tmp(lena.domain()); float ws[] = { .11, .11, .11, .11, .11, .11, .11, .11, .11 }; Index: tests/rle_image.cc --- tests/rle_image.cc (revision 1652) +++ tests/rle_image.cc (working copy) @@ -32,6 +32,13 @@ * \todo Trouble with ctor/init since there is no ctor with arg! */ + +// FIXME: There's already a test named rle_image.cc in tests/core. It +// seems to be pretty old material, not in sync with the current +// version of rle_image for a long time. Disable it before asking for +// its deletion. + + #include <mln/core/image2d.hh> #include <mln/core/rle_image.hh> #include <mln/core/rle_encode.hh> @@ -55,6 +62,9 @@ int main() { + // FIXME: Disabled (cf. supra). +#if 0 + mln::point2d p, q, r; r = make::point2d(0, 1); q = make::point2d(2, 2); @@ -90,4 +100,6 @@ // std::cout << std::endl; return 0; + +#endif } Index: tests/Makefile.am --- tests/Makefile.am (revision 1652) +++ tests/Makefile.am (working copy) @@ -24,6 +24,9 @@ value \ win +# FIXME: rle_image.cc and sparse_image.cc are probably garbage now +# (superseded by core/rle_image.cc and core/sparse_image.cc). Ask +# Simon whether we can remove them. check_PROGRAMS = \ border_resize_image1d_1 \ border_resize_image1d_2 \ @@ -41,7 +44,6 @@ box3d \ \ cast_image \ - chamfer \ convert_to_image \ convert_to_tiles \ convert_to_p_array \ @@ -54,13 +56,8 @@ \ estim_mean \ \ - fun_x2x_composed \ - fun_x2x_rotation \ - fun_x2x_translation \ - \ hexa \ histo_to_image1d \ - h_vec \ \ image1d \ image2d \ @@ -101,7 +98,6 @@ pw_value \ \ rle_image \ - run_pset \ \ safe_image \ seed2tiling \ @@ -144,7 +140,6 @@ box3d_SOURCES = box3d.cc cast_image_SOURCES = cast_image.cc -chamfer_SOURCES = chamfer.cc convert_to_image_SOURCES = convert_to_image.cc convert_to_tiles_SOURCES = convert_to_tiles.cc convert_to_p_array_SOURCES = convert_to_p_array.cc @@ -157,13 +152,8 @@ estim_mean_SOURCES = estim_mean.cc -fun_x2x_composed_SOURCES = fun_x2x_composed.cc -fun_x2x_rotation_SOURCES = fun_x2x_rotation.cc -fun_x2x_translation_SOURCES = fun_x2x_translation.cc - hexa_SOURCES = hexa.cc histo_to_image1d_SOURCES = histo_to_image1d.cc -h_vec_SOURCES = h_vec.cc image1d_SOURCES = image1d.cc image2d_SOURCES = image2d.cc @@ -204,7 +194,6 @@ pw_value_SOURCES = pw_value.cc rle_image_SOURCES = rle_image.cc -run_pset_SOURCES = run_pset.cc safe_image_SOURCES = safe_image.cc seed2tiling_SOURCES = seed2tiling.cc Index: tests/line_piter.cc --- tests/line_piter.cc (revision 1652) +++ tests/line_piter.cc (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007, 2008 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 @@ -42,7 +42,7 @@ image2d<int> f(b, border); image2d<int>::line_piter p(f.domain()); - unsigned i = 1; + int i = 1; for_all(p) { mln_assertion(p[1] == 0 && p[0] == i++); Index: mln/value/int_u_sat.hh --- mln/value/int_u_sat.hh (revision 1652) +++ mln/value/int_u_sat.hh (working copy) @@ -151,10 +151,9 @@ static const unsigned max_ = mln_max(int_u<n>); if (i < 0) this->v_ = 0; - // FIXME: This comparison triggers a warning between signed and - // unsigned values from the compiler. If it is valid, use a - // cast and leave a comment about it. - else if (i > max_) + // Explicitly cast I to unsigned to avoid a warning between + // signed and unsigned values from the compiler. + else if (static_cast<unsigned>(i) > max_) this->v_ = max_; else this->v_ = i; @@ -175,7 +174,9 @@ static const unsigned max_ = mln_max(int_u<n>); if (i < 0) this->v_ = 0; - else if (i > max_) + // Explicitly cast I to unsigned to avoid a warning between + // signed and unsigned values from the compiler. + else if (static_cast<unsigned>(i) > max_) this->v_ = max_; else this->v_ = i;
participants (1)
-
Roland Levillain