* mln/value/graylevel.hh: Aesthetic changes in comments.
* tests/value/graylevel.cc (test_conversion): Turn this macro into
a function template.
(main): Ensure all valid comparisons listed in
mln/value/graylevel.hh work.
Remove dead code.
Address warnings.
* tests/value/Makefile.am (check_PROGRAMS): Re-enable graylevel.
(graylevel_SOURCES): Re-enable.
---
milena/ChangeLog | 14 +++++++
milena/mln/value/graylevel.hh | 23 ++++++------
milena/tests/value/Makefile.am | 6 ++--
milena/tests/value/graylevel.cc | 74 +++++++++++++++++----------------------
4 files changed, 61 insertions(+), 56 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 2a289ad..111f0d7 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,19 @@
2013-02-06 Roland Levillain <roland(a)lrde.epita.fr>
+ Revive tests/value/graylevel.cc.
+
+ * mln/value/graylevel.hh: Aesthetic changes in comments.
+ * tests/value/graylevel.cc (test_conversion): Turn this macro into
+ a function template.
+ (main): Ensure all valid comparisons listed in
+ mln/value/graylevel.hh work.
+ Remove dead code.
+ Address warnings.
+ * tests/value/Makefile.am (check_PROGRAMS): Re-enable graylevel.
+ (graylevel_SOURCES): Re-enable.
+
+2013-02-06 Roland Levillain <roland(a)lrde.epita.fr>
+
Fix mutual dependencies between floating-point gray-level values.
* mln/value/graylevel_f.hh,
diff --git a/milena/mln/value/graylevel.hh b/milena/mln/value/graylevel.hh
index fc68391..7181678 100644
--- a/milena/mln/value/graylevel.hh
+++ b/milena/mln/value/graylevel.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2006, 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2006, 2007, 2008, 2009, 2013 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -238,19 +239,19 @@ namespace mln
// Valid Conversions are :
-// gray_f -> gray_<n>
-// gray_f -> graylevel<n>
-// gray_f -> graylevel_f
+ // gray_f -> gray_<n>
+ // gray_f -> graylevel<n>
+ // gray_f -> graylevel_f
-// gray_<n> -> gray_f
-// gray_<n> -> graylevel<n>
-// gray_<n> -> graylevel_f
+ // gray_<n> -> gray_f
+ // gray_<n> -> graylevel<n>
+ // gray_<n> -> graylevel_f
-// graylevel_f -> gray_f
-// graylevel_f -> graylevel<n>
+ // graylevel_f -> gray_f
+ // graylevel_f -> graylevel<n>
-// graylevel_<n> -> gray_<n>
-// graylevel_<n> -> graylevel_f<n>
+ // graylevel<n> -> gray_<n>
+ // graylevel<n> -> graylevel_f
template <unsigned n>
diff --git a/milena/tests/value/Makefile.am b/milena/tests/value/Makefile.am
index a8e43a4..f5d4505 100644
--- a/milena/tests/value/Makefile.am
+++ b/milena/tests/value/Makefile.am
@@ -1,4 +1,4 @@
-# Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
+# Copyright (C) 2007, 2008, 2009, 2012, 2013 EPITA Research and Development
# Laboratory (LRDE).
#
# This file is part of Olena.
@@ -25,6 +25,7 @@ SUBDIRS = \
check_PROGRAMS = \
bool \
equiv \
+ graylevel \
int_s \
int_s16 \
int_u8 \
@@ -38,7 +39,6 @@ check_PROGRAMS = \
# float01
# float01_bis
# float01_f
-# graylevel
# graylevel_f
bool_SOURCES = bool.cc
@@ -46,7 +46,7 @@ equiv_SOURCES = equiv.cc
#float01_SOURCES = float01.cc
#float01_bis_SOURCES = float01_bis.cc
#float01_f_SOURCES = float01_f.cc
-#graylevel_SOURCES = graylevel.cc
+graylevel_SOURCES = graylevel.cc
#graylevel_f_SOURCES = graylevel_f.cc
int_s_SOURCES = int_s.cc
int_s16_SOURCES = int_s16.cc
diff --git a/milena/tests/value/graylevel.cc b/milena/tests/value/graylevel.cc
index 21faab4..13c2d4c 100644
--- a/milena/tests/value/graylevel.cc
+++ b/milena/tests/value/graylevel.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2013 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -32,29 +33,20 @@
#include <mln/value/float01_f.hh>
#include <mln/value/float01_.hh>
-
#include <mln/literal/black.hh>
#include <mln/literal/white.hh>
-
-// FIXME: Give a more explicit error message.
-// template <typename T>
-// void foo()
-// {
-// typedef mln::value::gl8 g;
-// // mln_trait_op_times(int, mln::value::Integer<g>) tmp;
-// mln_trait_op_times(int, mln::value::Integer<g>) tmp;
-// }
-
-
-#define test_conversion(T1, T2, VAL) \
-{ \
- (T1)(T2)(VAL); \
- T1 test = (T2)(VAL); \
- test = (T2)(VAL); \
+template<typename From, typename To, typename T>
+void
+test_conversion (const T& val)
+{
+ (void)(To)(From) val;
+ To test = (From)(val);
+ test = (From)(val);
}
+
int main()
{
using namespace mln::value;
@@ -64,8 +56,6 @@ int main()
using mln::literal::black;
- // FIXME: Make all the test pass.
-
gl8 a(white);
gl8 b(white);
@@ -77,6 +67,7 @@ int main()
gl8 b(10);
gl8 c = a + b;
+ (void) c;
}
{
@@ -139,34 +130,33 @@ int main()
// Conversions.
typedef mln::value::internal::gray_<8> i_gray_8;
- test_conversion(gl8, i_gray_8, 255);
- test_conversion(gl8, gray_f, 0.4);
- test_conversion(gl8, glf, 0.4);
+ // gray_<n> -> graylevel<n>
+ test_conversion<i_gray_8, gl8>(255);
- test_conversion(glf, i_gray_8, 255);
- test_conversion(glf, gray_f, 0.4);
- test_conversion(glf, gl8, 142);
+ // gray_f -> graylevel<n>
+ test_conversion<gray_f, gl8>(0.4);
+ // graylevel_f -> graylevel<n>
+ test_conversion<glf, gl8>(0.4);
- test_conversion(gray_f, i_gray_8, 4);
- test_conversion(glf, gray_f, 0.4);
- }
+ // gray_<n> -> graylevel_f
+ test_conversion<i_gray_8, glf>(255);
+ // gray_f -> graylevel_f
+ test_conversion<gray_f, glf>(0.4);
+ // graylevel<n> -> graylevel_f
+ test_conversion<gl8, glf>(142);
-// {
-// // FIXME: comparison with literals doesn't work
-// c = a;
-// mln_assertion(c == white);
+ // gray_<n> -> gray_f
+ test_conversion<i_gray_8, gray_f>(4);
-// c = (a * 2) / 2;
-// mln_assertion(c == white);
-// c = c / 6;
-// }
+ // gray_f -> gray_<n>
+ test_conversion<gray_f, i_gray_8>(0.4);
-// {
-// gl8 c = white;
-// mln_assertion(c == white);
-// mln_assertion(c.value() == float(255));
-// }
+ // graylevel_f -> gray_f
+ test_conversion<glf, gray_f>(0.4);
+ // graylevel<n> -> gray_<n>
+ test_conversion<gl8, i_gray_8>(142);
+ }
}
--
1.7.2.5