* tests/labeling/Makefile.am: Add more extra-dist files.
* tests/labeling/foreground.cc: Rewrite.
* tests/labeling/foreground.ref.pgm: New.
---
milena/ChangeLog | 10 ++++++++
milena/tests/labeling/Makefile.am | 8 +++++-
milena/tests/labeling/foreground.cc | 34 ++++++++++++-----------------
milena/tests/labeling/foreground.ref.pgm | Bin 0 -> 81654 bytes
4 files changed, 30 insertions(+), 22 deletions(-)
create mode 100644 milena/tests/labeling/foreground.ref.pgm
diff --git a/milena/ChangeLog b/milena/ChangeLog
index b5dc109..a1e5a66 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,15 @@
2013-03-18 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Write a valid test for labeling::foreground.
+
+ * tests/labeling/Makefile.am: Add more extra-dist files.
+
+ * tests/labeling/foreground.cc: Rewrite.
+
+ * tests/labeling/foreground.ref.pgm: New.
+
+2013-03-18 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Fix compilation issues.
* mln/fun/v2v/round_sat.hh,
diff --git a/milena/tests/labeling/Makefile.am b/milena/tests/labeling/Makefile.am
index 33e81e4..1cabf25 100644
--- a/milena/tests/labeling/Makefile.am
+++ b/milena/tests/labeling/Makefile.am
@@ -1,5 +1,5 @@
-# Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
-# Laboratory (LRDE).
+# Copyright (C) 2007, 2008, 2009, 2010, 2013 EPITA Research and
+# Development Laboratory (LRDE).
#
# This file is part of Olena.
#
@@ -17,6 +17,10 @@
include $(top_srcdir)/milena/tests/tests.mk
+EXTRA_DIST = \
+ foreground.ref.pgm
+
+
check_PROGRAMS = \
background \
blobs \
diff --git a/milena/tests/labeling/foreground.cc b/milena/tests/labeling/foreground.cc
index 8be0aeb..286c166 100644
--- a/milena/tests/labeling/foreground.cc
+++ b/milena/tests/labeling/foreground.cc
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2010, 2013 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -27,12 +27,15 @@
#include <mln/core/image/image2d.hh>
#include <mln/core/var.hh>
#include <mln/io/pbm/load.hh>
+#include <mln/io/pgm/load.hh>
#include <mln/core/alias/neighb2d.hh>
#include <mln/data/compare.hh>
#include <mln/labeling/foreground.hh>
+#include <mln/value/int_u8.hh>
#include "tests/data.hh"
+#include <mln/io/pgm/save.hh>
int main()
{
@@ -41,27 +44,18 @@ int main()
typedef image2d<bool> I;
neighb2d nbh = c4();
- I pic = io::pbm::load(MLN_IMG_DIR "/picasso.pbm");
- image2d<unsigned> out, ref;
+ // Load ref
+ image2d<value::int_u8> ref;
+ io::pgm::load(ref, MLN_TESTS_DIR "/labeling/foreground.ref.pgm");
- unsigned n;
- out = labeling::foreground(pic, nbh, n); // Calls the fastest 'video'
- // version.
- mln_assertion(n == 33);
- {
- // Note that labeling::foreground actually is labeling::value
- // which calls canvas::labeling_video and its generic dispatch
- // leads to canvas::impl::generic::labeling.
+ I input = io::pbm::load(MLN_IMG_DIR "/picasso.pbm");
+ image2d<value::int_u8> out;
- labeling::impl::value_functor<I,unsigned> f(pic, true);
+ value::int_u8 n;
+ out = labeling::foreground(input, nbh, n);
- unsigned n_;
- ref = canvas::labeling::impl::generic::labeling(pic, nbh, n_,
- pic.domain(),
- f);
- mln_invariant(n_ == n);
- mln_invariant(ref == out);
- }
+ mln_assertion(n == 33);
+ mln_assertion(ref == out);
}
diff --git a/milena/tests/labeling/foreground.ref.pgm
b/milena/tests/labeling/foreground.ref.pgm
new file mode 100644
index 0000000..e2dc613
Binary files /dev/null and b/milena/tests/labeling/foreground.ref.pgm differ
--
1.7.2.5