Commit d4f02aba authored by Roland Levillain's avatar Roland Levillain
Browse files

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.
parent 85c24ded
2013-02-06 Roland Levillain <roland@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@lrde.epita.fr> 2013-02-06 Roland Levillain <roland@lrde.epita.fr>
   
Fix mutual dependencies between floating-point gray-level values. Fix mutual dependencies between floating-point gray-level values.
// 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. // This file is part of Olena.
// //
...@@ -238,19 +239,19 @@ namespace mln ...@@ -238,19 +239,19 @@ namespace mln
// Valid Conversions are : // Valid Conversions are :
// gray_f -> gray_<n> // gray_f -> gray_<n>
// gray_f -> graylevel<n> // gray_f -> graylevel<n>
// gray_f -> graylevel_f // gray_f -> graylevel_f
// gray_<n> -> gray_f // gray_<n> -> gray_f
// gray_<n> -> graylevel<n> // gray_<n> -> graylevel<n>
// gray_<n> -> graylevel_f // gray_<n> -> graylevel_f
// graylevel_f -> gray_f // graylevel_f -> gray_f
// graylevel_f -> graylevel<n> // graylevel_f -> graylevel<n>
// graylevel_<n> -> gray_<n> // graylevel<n> -> gray_<n>
// graylevel_<n> -> graylevel_f<n> // graylevel<n> -> graylevel_f
template <unsigned n> template <unsigned n>
......
# Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development # Copyright (C) 2007, 2008, 2009, 2012, 2013 EPITA Research and Development
# Laboratory (LRDE). # Laboratory (LRDE).
# #
# This file is part of Olena. # This file is part of Olena.
...@@ -25,6 +25,7 @@ SUBDIRS = \ ...@@ -25,6 +25,7 @@ SUBDIRS = \
check_PROGRAMS = \ check_PROGRAMS = \
bool \ bool \
equiv \ equiv \
graylevel \
int_s \ int_s \
int_s16 \ int_s16 \
int_u8 \ int_u8 \
...@@ -38,7 +39,6 @@ check_PROGRAMS = \ ...@@ -38,7 +39,6 @@ check_PROGRAMS = \
# float01 # float01
# float01_bis # float01_bis
# float01_f # float01_f
# graylevel
# graylevel_f # graylevel_f
bool_SOURCES = bool.cc bool_SOURCES = bool.cc
...@@ -46,7 +46,7 @@ equiv_SOURCES = equiv.cc ...@@ -46,7 +46,7 @@ equiv_SOURCES = equiv.cc
#float01_SOURCES = float01.cc #float01_SOURCES = float01.cc
#float01_bis_SOURCES = float01_bis.cc #float01_bis_SOURCES = float01_bis.cc
#float01_f_SOURCES = float01_f.cc #float01_f_SOURCES = float01_f.cc
#graylevel_SOURCES = graylevel.cc graylevel_SOURCES = graylevel.cc
#graylevel_f_SOURCES = graylevel_f.cc #graylevel_f_SOURCES = graylevel_f.cc
int_s_SOURCES = int_s.cc int_s_SOURCES = int_s.cc
int_s16_SOURCES = int_s16.cc int_s16_SOURCES = int_s16.cc
......
// 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. // This file is part of Olena.
// //
...@@ -32,29 +33,20 @@ ...@@ -32,29 +33,20 @@
#include <mln/value/float01_f.hh> #include <mln/value/float01_f.hh>
#include <mln/value/float01_.hh> #include <mln/value/float01_.hh>
#include <mln/literal/black.hh> #include <mln/literal/black.hh>
#include <mln/literal/white.hh> #include <mln/literal/white.hh>
template<typename From, typename To, typename T>
// FIXME: Give a more explicit error message. void
// template <typename T> test_conversion (const T& val)
// void foo() {
// { (void)(To)(From) val;
// typedef mln::value::gl8 g; To test = (From)(val);
// // mln_trait_op_times(int, mln::value::Integer<g>) tmp; test = (From)(val);
// 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); \
} }
int main() int main()
{ {
using namespace mln::value; using namespace mln::value;
...@@ -64,8 +56,6 @@ int main() ...@@ -64,8 +56,6 @@ int main()
using mln::literal::black; using mln::literal::black;
// FIXME: Make all the test pass.
gl8 a(white); gl8 a(white);
gl8 b(white); gl8 b(white);
...@@ -77,6 +67,7 @@ int main() ...@@ -77,6 +67,7 @@ int main()
gl8 b(10); gl8 b(10);
gl8 c = a + b; gl8 c = a + b;
(void) c;
} }
{ {
...@@ -139,34 +130,33 @@ int main() ...@@ -139,34 +130,33 @@ int main()
// Conversions. // Conversions.
typedef mln::value::internal::gray_<8> i_gray_8; typedef mln::value::internal::gray_<8> i_gray_8;
test_conversion(gl8, i_gray_8, 255);
test_conversion(gl8, gray_f, 0.4); // gray_<n> -> graylevel<n>
test_conversion(gl8, glf, 0.4); test_conversion<i_gray_8, gl8>(255);
test_conversion(glf, i_gray_8, 255); // gray_f -> graylevel<n>
test_conversion(glf, gray_f, 0.4); test_conversion<gray_f, gl8>(0.4);
test_conversion(glf, gl8, 142); // graylevel_f -> graylevel<n>
test_conversion<glf, gl8>(0.4);
test_conversion(gray_f, i_gray_8, 4); // gray_<n> -> graylevel_f
test_conversion(glf, gray_f, 0.4); 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);
// { // gray_<n> -> gray_f
// // FIXME: comparison with literals doesn't work test_conversion<i_gray_8, gray_f>(4);
// c = a;
// mln_assertion(c == white);
// c = (a * 2) / 2;
// mln_assertion(c == white);
// c = c / 6; // gray_f -> gray_<n>
// } test_conversion<gray_f, i_gray_8>(0.4);
// { // graylevel_f -> gray_f
// gl8 c = white; test_conversion<glf, gray_f>(0.4);
// mln_assertion(c == white);
// mln_assertion(c.value() == float(255));
// }
// graylevel<n> -> gray_<n>
test_conversion<gl8, i_gray_8>(142);
}
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment