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>
 
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.
//
......@@ -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>
......
# 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
......
// 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);
}
}
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