Commit 15a7a1a7 authored by Guillaume Duhamel's avatar Guillaume Duhamel
Browse files

Update tests for level and border and fix typo.


	* tests/border/duplicate_full.cc,
	* tests/border/fill.cc,
	* tests/border/fill_full.cc,
	* tests/border/mirror_full.cc: Update 1d version.

	* tests/display/color_pretty.cc,
	* tests/level/abs_full.cc,
	* tests/level/sort_points_full.cc,
	* tests/logical/and_not_full.cc,
	* tests/logical/not_full.cc: Update and fix typo.

	* mln/trait/value/kind.hh: Fix typo.

git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@1601 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 6bfc8fc3
2007-12-07 Guillaume Duhamel <guillaume.duhamel@lrde.epita.fr>
Update tests for level and border and fix typo.
* tests/border/duplicate_full.cc,
* tests/border/fill.cc,
* tests/border/fill_full.cc,
* tests/border/mirror_full.cc: Update 1d version.
* tests/display/color_pretty.cc,
* tests/level/abs_full.cc,
* tests/level/sort_points_full.cc,
* tests/logical/and_not_full.cc,
* tests/logical/not_full.cc: Update and fix typo.
* mln/trait/value/kind.hh: Fix typo.
2007-12-07 Simon Nivault <simon.nivault@lrde.epita.fr>
The set of a lazy_set can be cleared.
......
......@@ -56,13 +56,14 @@ namespace mln
struct logic : label { std::string name() const { return "kind::logic"; } };
struct binary : logic { std::string name() const { return "kind::binary"; } };
/*
// FIXME: Why not?
// label logic
// \ / \
// \ nary_logic \
// \ / \ \
// \ / \
// \ nary_logic \
// \ / \ \
// binary ternary fuzzy
*/
struct data : any { std::string name() const { return "kind::data"; } };
};
......
......@@ -30,142 +30,192 @@
* \brief Tests on mln::border::duplicate.
*/
#include <mln/core/image1d.hh>
#include <mln/core/image2d.hh>
#include <mln/debug/iota.hh>
#include <mln/border/duplicate.hh>
#include <mln/value/int_u8.hh>
#include <mln/value/int_s8.hh>
using namespace mln;
int
main (void)
namespace mln
{
template <typename T>
void chck1d(int cols, int border, T ref[])
{
(std::cerr << "Test border::mirror on int with border = 3 ... ").flush ();
typedef int T;
int border = 3;
int row = 4;
int col = 5;
int r = row + 2 * border;
int c = col + 2 * border;
image2d<T> ima(row, col, border);
debug::iota (ima);
border::duplicate (ima);
T vs[110] =
{
1, 1, 1, 1, 2, 3, 4, 5, 5, 5, 5,
1, 1, 1, 1, 2, 3, 4, 5, 5, 5, 5,
1, 1, 1, 1, 2, 3, 4, 5, 5, 5, 5,
1, 1, 1, 1, 2, 3, 4, 5, 5, 5, 5,
6, 6, 6, 6, 7, 8, 9, 10, 10, 10, 10,
11, 11, 11, 11, 12, 13, 14, 15, 15, 15, 15,
16, 16, 16, 16, 17, 18, 19, 20, 20, 20, 20,
16, 16, 16, 16, 17, 18, 19, 20, 20, 20, 20,
16, 16, 16, 16, 17, 18, 19, 20, 20, 20, 20,
16, 16, 16, 16, 17, 18, 19, 20, 20, 20, 20
};
int c = cols + 2 * border;
for (int i = 0; i < c * r; ++i)
mln_assertion(ima[i] == vs[i]);
std::cerr << "OK" << std::endl;
image1d<T> ima(cols, border);
debug::iota(ima);
border::duplicate(ima);
for (int i = 0; i < c; ++i)
mln_assertion(ima[i] == ref[i]);
}
template <typename T>
void chck2d(int rows, int cols, int border, T ref[])
{
(std::cerr << "Test border::mirror on int_u8 with border = 2 ... ").flush ();
typedef value::int_u8 T;
int border = 2;
int row = 4;
int col = 5;
int r = row + 2 * border;
int c = col + 2 * border;
image2d<T> ima(row, col, border);
debug::iota (ima);
border::duplicate (ima);
T vs[72] =
{
1, 1, 1, 2, 3, 4, 5, 5, 5,
1, 1, 1, 2, 3, 4, 5, 5, 5,
1, 1, 1, 2, 3, 4, 5, 5, 5,
6, 6, 6, 7, 8, 9, 10, 10, 10,
11, 11, 11, 12, 13, 14, 15, 15, 15,
16, 16, 16, 17, 18, 19, 20, 20, 20,
16, 16, 16, 17, 18, 19, 20, 20, 20,
16, 16, 16, 17, 18, 19, 20, 20, 20
};
int r = rows + 2 * border;
int c = cols + 2 * border;
image2d<T> ima(rows, cols, border);
debug::iota(ima);
border::duplicate(ima);
for (int i = 0; i < c * r; ++i)
mln_assertion(ima[i] == vs[i]);
std::cerr << "OK" << std::endl;
mln_assertion(ima[i] == ref[i]);
}
{
(std::cerr << "Test border::mirror on int_s8 with border = 1 ... ").flush ();
typedef value::int_s8 T;
int border = 1;
int row = 4;
int col = 5;
int r = row + 2 * border;
int c = col + 2 * border;
image2d<T> ima(row, col, border);
debug::iota (ima);
border::duplicate (ima);
T vs[49] =
{
1, 1, 2, 3, 4, 5, 5,
1, 1, 2, 3, 4, 5, 5,
6, 6, 7, 8, 9, 10, 10,
11, 11, 12, 13, 14, 15, 15,
16, 16, 17, 18, 19, 20, 20,
16, 16, 17, 18, 19, 20, 20
};
}
for (int i = 0; i < c * r; ++i)
mln_assertion(ima[i] == vs[i]);
std::cerr << "OK" << std::endl;
}
int
main(void)
{
using namespace mln;
std::cerr << "Tests border::duplicate:" << std::endl;
{
(std::cerr << "Test border::mirror on int with border = 0 ... ").flush ();
std::cerr << " in 1d :" << std::endl;
typedef int T;
int border = 0;
int row = 4;
int col = 5;
{
(std::cerr << " on int_u8 with border = 3 ... ").flush ();
int r = row + 2 * border;
int c = col + 2 * border;
typedef value::int_u8 T;
int border = 3;
int cols = 2;
T ref[8] = {1, 1, 1, 1, 2, 2, 2, 2};
image2d<T> ima(row, col, border);
debug::iota (ima);
border::duplicate (ima);
chck1d(cols, border, ref);
std::cerr << "OK" << std::endl;
}
T vs[20] =
{
1, 2, 3, 4, 5,
6, 7, 8, 9, 10,
11, 12, 13, 14, 15,
16, 17, 18, 19, 20
};
{
(std::cerr << " on int with border = 2 ... ").flush ();
for (int i = 0; i < c * r; ++i)
mln_assertion(ima[i] == vs[i]);
std::cerr << "OK" << std::endl;
}
typedef int T;
int border = 2;
int cols = 3;
T ref[7] = {1, 1, 1, 2, 3, 3, 3};
chck1d(cols, border, ref);
std::cerr << "OK" << std::endl;
}
{
(std::cerr << " on int_s8 with border = 1 ... ").flush ();
typedef value::int_s8 T;
int border = 1;
int cols = 2;
T ref[4] = {1, 1, 2, 2};
chck1d(cols, border, ref);
std::cerr << "OK" << std::endl;
}
{
(std::cerr << " on int with border = 0 ... ").flush ();
typedef int T;
int border = 0;
int cols = 4;
T ref[4] = {1, 2, 3, 4};
chck1d(cols, border, ref);
std::cerr << "OK" << std::endl;
}
} // end of 1d
{
std::cerr << " in 2d :" << std::endl;
{
(std::cerr << " on int with border = 3 ... ").flush ();
typedef int T;
int border = 3;
int rows = 4;
int cols = 5;
T ref[110] =
{
1, 1, 1, 1, 2, 3, 4, 5, 5, 5, 5,
1, 1, 1, 1, 2, 3, 4, 5, 5, 5, 5,
1, 1, 1, 1, 2, 3, 4, 5, 5, 5, 5,
1, 1, 1, 1, 2, 3, 4, 5, 5, 5, 5,
6, 6, 6, 6, 7, 8, 9, 10, 10, 10, 10,
11, 11, 11, 11, 12, 13, 14, 15, 15, 15, 15,
16, 16, 16, 16, 17, 18, 19, 20, 20, 20, 20,
16, 16, 16, 16, 17, 18, 19, 20, 20, 20, 20,
16, 16, 16, 16, 17, 18, 19, 20, 20, 20, 20,
16, 16, 16, 16, 17, 18, 19, 20, 20, 20, 20
};
chck2d(rows, cols, border, ref);
std::cerr << "OK" << std::endl;
}
{
(std::cerr << " on int_u8 with border = 3 ... ").flush ();
typedef value::int_u8 T;
int border = 2;
int rows = 4;
int cols = 5;
T ref[72] =
{
1, 1, 1, 2, 3, 4, 5, 5, 5,
1, 1, 1, 2, 3, 4, 5, 5, 5,
1, 1, 1, 2, 3, 4, 5, 5, 5,
6, 6, 6, 7, 8, 9, 10, 10, 10,
11, 11, 11, 12, 13, 14, 15, 15, 15,
16, 16, 16, 17, 18, 19, 20, 20, 20,
16, 16, 16, 17, 18, 19, 20, 20, 20,
16, 16, 16, 17, 18, 19, 20, 20, 20
};
chck2d(rows, cols, border, ref);
std::cerr << "OK" << std::endl;
}
{
(std::cerr << " on int_s8 with border = 1 ... ").flush ();
typedef value::int_s8 T;
int border = 1;
int rows = 4;
int cols = 5;
T ref[49] =
{
1, 1, 2, 3, 4, 5, 5,
1, 1, 2, 3, 4, 5, 5,
6, 6, 7, 8, 9, 10, 10,
11, 11, 12, 13, 14, 15, 15,
16, 16, 17, 18, 19, 20, 20,
16, 16, 17, 18, 19, 20, 20
};
chck2d(rows, cols, border, ref);
std::cerr << "OK" << std::endl;
}
{
(std::cerr << " on int with border = 0 ... ").flush ();
typedef int T;
int border = 0;
int rows = 4;
int cols = 5;
T ref[20] =
{
1, 2, 3, 4, 5,
6, 7, 8, 9, 10,
11, 12, 13, 14, 15,
16, 17, 18, 19, 20
};
chck2d(rows, cols, border, ref);
std::cerr << "OK" << std::endl;
}
} // end of 2d
}
......@@ -25,7 +25,7 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
/*! \file tests/border_fill/test_border_fill_image2d_1.cc
/*! \file tests/border/fill.cc
*
* \brief Tests on mln::border::fill.
*/
......
......@@ -25,7 +25,7 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
/*! \file tests/border_fill/test_border_fill_image2d_1.cc
/*! \file tests/border/fill_full.cc
*
* \brief Tests on mln::border::fill.
*/
......@@ -133,14 +133,16 @@ main (void)
{
int limits = 10;
std::cerr << "Tests border::fill:" << std::endl;
{
std::cerr << "Tests border::fill on int:" << std::endl;
std::cerr << " on int:" << std::endl;
typedef int T;
T value = (T) -1;
T v = 42;
(std::cerr << "in 1d ... ").flush ();
(std::cerr << " in 1d ... ").flush ();
for (int i = 1; i < limits; ++i)
for (int j = 1; j < limits; ++j)
......@@ -149,7 +151,7 @@ main (void)
std::cerr << "OK" << std::endl;
(std::cerr << "in 2d ... ").flush ();
(std::cerr << " in 2d ... ").flush ();
for (int i = 1; i < limits; ++i)
for (int j = 1; j < limits; ++j)
......@@ -160,13 +162,13 @@ main (void)
}
{
std::cerr << "Tests border::fill on unsigned:" << std::endl;
std::cerr << " on unsigned:" << std::endl;
typedef unsigned T;
T value = (T) -1;
T v = 42;
(std::cerr << "in 1d ... ").flush ();
(std::cerr << " in 1d ... ").flush ();
for (int i = 1; i < limits; ++i)
for (int j = 1; j < limits; ++j)
......@@ -175,7 +177,7 @@ main (void)
std::cerr << "OK" << std::endl;
(std::cerr << "in 2d ... ").flush ();
(std::cerr << " in 2d ... ").flush ();
for (int i = 1; i < limits; ++i)
for (int j = 1; j < limits; ++j)
......@@ -186,13 +188,13 @@ main (void)
}
{
std::cerr << "Tests border::fill on int_u8 ... " << std::endl;
std::cerr << " on int_u8:" << std::endl;
typedef value::int_u8 T;
T value = 255;
T v = 42;
(std::cerr << "in 1d ... ").flush ();
(std::cerr << " in 1d ... ").flush ();
for (int i = 1; i < limits; ++i)
for (int j = 1; j < limits; ++j)
......@@ -201,7 +203,7 @@ main (void)
std::cerr << "OK" << std::endl;
(std::cerr << "in 2d ... ").flush ();
(std::cerr << " in 2d ... ").flush ();
for (int i = 1; i < limits; ++i)
for (int j = 1; j < limits; ++j)
......@@ -212,13 +214,13 @@ main (void)
}
{
std::cerr << "Tests border::fill on int_u16 ... " << std::endl;
std::cerr << " on int_u16:" << std::endl;
typedef value::int_u16 T;
T value = 65535;
T v = 42;
(std::cerr << "in 1d ... ").flush ();
(std::cerr << " in 1d ... ").flush ();
for (int i = 1; i < limits; ++i)
for (int j = 1; j < limits; ++j)
......@@ -227,7 +229,7 @@ main (void)
std::cerr << "OK" << std::endl;
(std::cerr << "in 2d ... ").flush ();
(std::cerr << " in 2d ... ").flush ();
for (int i = 1; i < limits; ++i)
for (int j = 1; j < limits; ++j)
......@@ -238,13 +240,13 @@ main (void)
}
{
std::cerr << "Tests border::fill on int_s8 ... " << std::endl;
std::cerr << " on int_s8:" << std::endl;
typedef value::int_s8 T;
T value = 127;
T v = 42;
(std::cerr << "in 1d ... ").flush ();
(std::cerr << " in 1d ... ").flush ();
for (int i = 1; i < limits; ++i)
for (int j = 1; j < limits; ++j)
......@@ -253,7 +255,7 @@ main (void)
std::cerr << "OK" << std::endl;
(std::cerr << "in 2d ... ").flush ();
(std::cerr << " in 2d ... ").flush ();
for (int i = 1; i < limits; ++i)
for (int j = 1; j < limits; ++j)
......@@ -264,13 +266,13 @@ main (void)
}
{
std::cerr << "Tests border::fill on int_s16 ... " << std::endl;
std::cerr << " on int_s16:" << std::endl;
typedef value::int_s16 T;
T value = 32767;
T v = 42;
(std::cerr << "in 1d ... ").flush ();
(std::cerr << " in 1d ... ").flush ();
for (int i = 1; i < limits; ++i)
for (int j = 1; j < limits; ++j)
......@@ -279,7 +281,7 @@ main (void)
std::cerr << "OK" << std::endl;
(std::cerr << "in 2d ... ").flush ();
(std::cerr << " in 2d ... ").flush ();
for (int i = 1; i < limits; ++i)
for (int j = 1; j < limits; ++j)
......@@ -290,13 +292,13 @@ main (void)
}
{
std::cerr << "Tests border::fill on rgb8 ... " << std::endl;
std::cerr << " on rgb8:" << std::endl;
typedef value::rgb8 T;
T value = T(255, 255, 255);
T v = T(42, 0, 0);
(std::cerr << "in 1d ... ").flush ();
(std::cerr << " in 1d ... ").flush ();
for (int i = 1; i < limits; ++i)
for (int j = 1; j < limits; ++j)
......@@ -305,7 +307,7 @@ main (void)
std::cerr << "OK" << std::endl;
(std::cerr << "in 2d ... ").flush ();
(std::cerr << " in 2d ... ").flush ();
for (int i = 1; i < limits; ++i)
for (int j = 1; j < limits; ++j)
......@@ -316,13 +318,13 @@ main (void)
}
{
std::cerr << "Tests border::fill on rgb16:" << std::endl;
std::cerr << " on rgb16:" << std::endl;
typedef value::rgb16 T;
T value = T(65535, 65535, 65535);
T v = T(42, 0, 0);
(std::cerr << "in 1d ... ").flush ();
(std::cerr << " in 1d ... ").flush ();
for (int i = 1; i < limits; ++i)
for (int j = 1; j < limits; ++j)
......@@ -331,7 +333,7 @@ main (void)
std::cerr << "OK" << std::endl;
(std::cerr << "in 2d ... ").flush ();
(std::cerr << " in 2d ... ").flush ();
for (int i = 1; i < limits; ++i)
for (int j = 1; j < limits; ++j)
......@@ -343,13 +345,13 @@ main (void)
{
std::cerr << "Tests border::fill on float01_8:" << std::endl;
std::cerr << " on float01_8:" << std::endl;
typedef value::float01_8 T;
T value = T(0.9999);
T v = T(0.111);
(std::cerr << "in 1d ... ").flush ();
(std::cerr << " in 1d ... ").flush ();
for (int i = 1; i < limits; ++i)
for (int j = 1; j < limits; ++j)
......@@ -358,7 +360,7 @@ main (void)
std::cerr << "OK" << std::endl;
(std::cerr << "in 2d ... ").flush ();
(std::cerr << " in 2d ... ").flush ();
for (int i = 1; i < limits; ++i)
for (int j = 1; j < limits; ++j)
......@@ -369,13 +371,13 @@ main (void)
}
{
std::cerr << "Tests border::fill on float01_16:" << std::endl;
std::cerr << " on float01_16:" << std::endl;
typedef value::float01_16 T;
T value = T(0.9999);
T v = T(0.111);
(std::cerr << "in 1d ... ").flush ();
(std::cerr << " in 1d ... ").flush ();
for (int i = 1; i < limits; ++i)
for (int j = 1; j < limits; ++j)
......@@ -384,7 +386,7 @@ main (void)
std::cerr << "OK" << std::endl;