
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena ChangeLog: 2007-12-03 Matthieu Garrigues <garrigues@lrde.epita.fr> Add tests for mln/accu. * tests/accu/bbox.cc: New. * tests/accu/compute.cc: New. * tests/accu/count.cc: New. * tests/accu/histo.cc: New. * tests/accu/max.cc: New. * tests/accu/max_h.cc: New. * tests/accu/mean.cc: New. * tests/accu/median.cc: New. * tests/accu/min_h.cc: New. * tests/accu/min_max.cc: New. * tests/accu/pair.cc: New. --- bbox.cc | 50 +++++++++++++++++++++++++++++++++++++++++++ compute.cc | 55 +++++++++++++++++++++++++++++++++++++++++++++++ count.cc | 54 +++++++++++++++++++++++++++++++++++++++++++++++ histo.cc | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ max.cc | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ max_h.cc | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ mean.cc | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ median.cc | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ min_h.cc | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ min_max.cc | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ pair.cc | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 11 files changed, 691 insertions(+) Index: trunk/milena/tests/accu/pair.cc =================================================================== --- trunk/milena/tests/accu/pair.cc (revision 0) +++ trunk/milena/tests/accu/pair.cc (revision 1580) @@ -0,0 +1,69 @@ +// 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. + +/*! \file tests/accu/mean.cc + * + * \brief Tests on mln::accu::mean. + */ + +#include <mln/core/image2d.hh> +#include <mln/value/int_u8.hh> + +#include <mln/accu/mean.hh> + +int main() +{ + using namespace mln; + + { + accu::pair_<accu::mean<int>, accu::max<int> > mean; + + mean.take(10); + mean.take(9); + mean.take(8); + mean.take(7); + mean.take(6); + mean.take(5); + mean.take(4); + mean.take(3); + mean.take(2); + mean.take(1); + mean.take(0); + + mln_assertion(mean.to_result() == 5); + } + + { + mln_accu_with_(accu::mean, int) mean; + + mean.take(10); + mean.take(8); + mean.take(0); + + mln_assertion(mean.to_result() == 6); + } +} Index: trunk/milena/tests/accu/compute.cc =================================================================== --- trunk/milena/tests/accu/compute.cc (revision 0) +++ trunk/milena/tests/accu/compute.cc (revision 1580) @@ -0,0 +1,55 @@ +// 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. + +/*! \file tests/accu/compute.cc + * + * \brief Tests on mln::accu::compute. + */ + +#include <mln/core/image2d.hh> +#include <mln/value/int_u8.hh> + +#include <mln/accu/compute.hh> +#include <mln/level/compute.hh> + +#include <mln/accu/min.hh> + +int main() +{ + using namespace mln; + using typename value::int_u8; + + // FIXME : make this test compile +// int_u8 vs[3][3] = { {9,8,7}, +// {6,5,4}, +// {3,2,1} }; + +// image2d<int_u8> ima = make::image2d(vs); +// int a = accu::compute<accu::min>(ima); + +// std::cout << a << std::endl; +} Index: trunk/milena/tests/accu/max_h.cc =================================================================== --- trunk/milena/tests/accu/max_h.cc (revision 0) +++ trunk/milena/tests/accu/max_h.cc (revision 1580) @@ -0,0 +1,62 @@ +// 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. + +/*! \file tests/accu/max_h.cc + * + * \brief Tests on mln::accu::max_h. + */ + +#include <mln/value/int_u8.hh> +#include <mln/accu/max_h.hh> + + +int main() +{ + using namespace mln; + using namespace mln::value; + + accu::max_h< set<int_u8> > a; + + a.take(1); + a.take(1); + a.take(1); + + a.take(2); + a.take(2); + a.take(2); + a.take(2); + a.take(2); + a.take(2); + + a.take(234); + a.take(234); + a.take(234); + a.take(234); + a.take(234); + a.take(234); + mln_assertion(a.to_result() == 234); +} Index: trunk/milena/tests/accu/median.cc =================================================================== --- trunk/milena/tests/accu/median.cc (revision 0) +++ trunk/milena/tests/accu/median.cc (revision 1580) @@ -0,0 +1,69 @@ +// 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. + +/*! \file tests/accu/median.cc + * + * \brief Tests on mln::accu::median. + */ + +#include <mln/core/image2d.hh> +#include <mln/value/int_u8.hh> + +#include <mln/accu/median.hh> + +int main() +{ + using namespace mln; + + { + accu::median< value::set<value::int_u8> > med; + + med.take(10); + med.take(9); + med.take(8); + med.take(7); + med.take(6); + med.take(5); + med.take(4); + med.take(3); + med.take(2); + med.take(1); + med.take(0); + + mln_assertion(med.to_result() == 5); + } + + { + accu::median< value::set<value::int_u8> > med; + + med.take(10); + med.take(7); + med.take(0); + + mln_assertion(med.to_result() == 7); + } +} Index: trunk/milena/tests/accu/mean.cc =================================================================== --- trunk/milena/tests/accu/mean.cc (revision 0) +++ trunk/milena/tests/accu/mean.cc (revision 1580) @@ -0,0 +1,69 @@ +// 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. + +/*! \file tests/accu/mean.cc + * + * \brief Tests on mln::accu::mean. + */ + +#include <mln/core/image2d.hh> +#include <mln/value/int_u8.hh> + +#include <mln/accu/mean.hh> + +int main() +{ + using namespace mln; + + { + mln_accu_with_(accu::mean, int) mean; + + mean.take(10); + mean.take(9); + mean.take(8); + mean.take(7); + mean.take(6); + mean.take(5); + mean.take(4); + mean.take(3); + mean.take(2); + mean.take(1); + mean.take(0); + + mln_assertion(mean.to_result() == 5); + } + + { + mln_accu_with_(accu::mean, int) mean; + + mean.take(10); + mean.take(8); + mean.take(0); + + mln_assertion(mean.to_result() == 6); + } +} Index: trunk/milena/tests/accu/max.cc =================================================================== --- trunk/milena/tests/accu/max.cc (revision 0) +++ trunk/milena/tests/accu/max.cc (revision 1580) @@ -0,0 +1,62 @@ +// 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. + +/*! \file tests/accu/max.cc + * + * \brief Tests on mln::accu::max. + */ + +#include <mln/core/image2d.hh> +#include <mln/debug/iota.hh> + +#include <mln/accu/nil.hh> +#include <mln/accu/max.hh> +#include <mln/accu/p.hh> +#include <mln/accu/v.hh> +#include <mln/accu/compute.hh> + +#include <mln/level/compute.hh> + + +int main() +{ + using namespace mln; + image2d<int> ima(3, 3); + debug::iota(ima); + mln_assertion(level::compute< accu::max >(ima) == 9); + mln_assertion(level::compute< accu::max_<int> >(ima) == 9); + + accu::compute< accu::nil >(ima); // No-op. + + // FIXME : what's the difference between + // accu::compute< accu::max >(ima); + + mln_assertion( accu::compute< accu::val<accu::max> >(ima) == 9); + +// std::cout << accu::compute< accu::max >(ima) +// << std::endl; +} Index: trunk/milena/tests/accu/histo.cc =================================================================== --- trunk/milena/tests/accu/histo.cc (revision 0) +++ trunk/milena/tests/accu/histo.cc (revision 1580) @@ -0,0 +1,70 @@ +// 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. + +/*! \file tests/accu/histo.cc + * + * \brief Tests on mln::accu::histo. + */ + +#include <mln/value/int_u8.hh> + +#include <mln/accu/histo.hh> + + +int main() +{ + using namespace mln; + using namespace mln::value; + + accu::histo< set<int_u8> > a; + + a.take(1); + a.take(1); + a.take(1); + + + a.take(2); + a.take(2); + a.take(2); + + a.take(234); + a.take(234); + a.take(234); + a.take(234); + a.take(234); + a.take(234); + + mln_assertion(a[1] == 3); + mln_assertion(a[2] == 3); + mln_assertion(a[234] == 6); + + a.untake(234); + mln_assertion(a[234] == 5); + + // Abort + // a.untake(235); +} Index: trunk/milena/tests/accu/min_max.cc =================================================================== --- trunk/milena/tests/accu/min_max.cc (revision 0) +++ trunk/milena/tests/accu/min_max.cc (revision 1580) @@ -0,0 +1,69 @@ +// 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. + +/*! \file tests/accu/min_max.cc + * + * \brief Tests on mln::accu::min_max. + */ + +// FIXME : This test doesn't compile without this include. +#include <mln/value/builtin/integers.hh> + +#include <mln/accu/min_max.hh> + +int main() +{ + using namespace mln; + + { + mln_accu_with_(accu::min_max, int) accu; + + accu.take(7); + + mln_assertion(accu.to_result().first == 7); + mln_assertion(accu.to_result().second == 7); + } + + { + mln_accu_with_(accu::min_max, int) accu; + + accu.take(10); + accu.take(9); + accu.take(8); + accu.take(7); + accu.take(6); + accu.take(5); + accu.take(4); + accu.take(3); + accu.take(2); + accu.take(1); + accu.take(0); + + mln_assertion(accu.to_result().first == 0); + mln_assertion(accu.to_result().second == 10); + } +} Index: trunk/milena/tests/accu/count.cc =================================================================== --- trunk/milena/tests/accu/count.cc (revision 0) +++ trunk/milena/tests/accu/count.cc (revision 1580) @@ -0,0 +1,54 @@ +// 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. + +/*! \file tests/accu/count.cc + * + * \brief Tests on mln::accu::count. + */ + +#include <mln/value/int_u8.hh> + +#include <mln/accu/count.hh> + + +int main() +{ + using namespace mln; + + { + accu::count_<value::int_u8> accu; + mln_assertion(accu.to_result() == 0); + } + + { + accu::count_<value::int_u8> accu; + for (int i = 0; i < 200; i++) + accu.take(i); + mln_assertion(accu.to_result() == 200); + } + +} Index: trunk/milena/tests/accu/min_h.cc =================================================================== --- trunk/milena/tests/accu/min_h.cc (revision 0) +++ trunk/milena/tests/accu/min_h.cc (revision 1580) @@ -0,0 +1,62 @@ +// 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. + +/*! \file tests/accu/min_h.cc + * + * \brief Tests on mln::accu::min_h. + */ + +#include <mln/value/int_u8.hh> +#include <mln/accu/min_h.hh> + + +int main() +{ + using namespace mln; + using namespace mln::value; + + accu::min_h< set<int_u8> > a; + + a.take(42); + a.take(42); + a.take(42); + + a.take(200); + a.take(200); + a.take(200); + a.take(200); + a.take(200); + a.take(200); + + a.take(234); + a.take(234); + a.take(234); + a.take(234); + a.take(234); + a.take(234); + mln_assertion(a.to_result() == 42); +} Index: trunk/milena/tests/accu/bbox.cc =================================================================== --- trunk/milena/tests/accu/bbox.cc (revision 0) +++ trunk/milena/tests/accu/bbox.cc (revision 1580) @@ -0,0 +1,50 @@ +// 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. + +/*! \file tests/accu/nil.cc + * + * \brief Tests on mln::accu::nil. + */ + + +#include <mln/core/point2d.hh> +#include <mln/core/box2d.hh> + +#include <mln/accu/bbox.hh> + +int main() +{ + using namespace mln; + accu::bbox<point2d> accu; + + accu.take_as_init(make::point2d(0,0)); + accu.take(make::point2d(0,5)); + accu.take(make::point2d(5,0)); + accu.take(make::point2d(5,5)); + + mln_assertion(accu.to_result() == make::box2d(0,0,5,5)); +}