URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-12-07 Guillaume Duhamel <guillaume.duhamel(a)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.
---
mln/trait/value/kind.hh | 3
tests/border/duplicate_full.cc | 168 ++++++++++++++++++++++++-------------
tests/border/fill.cc | 2
tests/border/fill_full.cc | 24 ++---
tests/border/mirror_full.cc | 178 +++++++++++++++++++++++++---------------
tests/display/color_pretty.cc | 2
tests/level/abs_full.cc | 2
tests/level/sort_points_full.cc | 2
tests/logical/and_not_full.cc | 2
tests/logical/not_full.cc | 4
10 files changed, 245 insertions(+), 142 deletions(-)
Index: trunk/milena/tests/level/abs_full.cc
===================================================================
--- trunk/milena/tests/level/abs_full.cc (revision 1600)
+++ trunk/milena/tests/level/abs_full.cc (revision 1601)
@@ -25,7 +25,7 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/level/abs.cc
+/*! \file tests/level/abs_full.cc
*
* \brief Tests on mln::level::abs.
*/
Index: trunk/milena/tests/level/sort_points_full.cc
===================================================================
--- trunk/milena/tests/level/sort_points_full.cc (revision 1600)
+++ trunk/milena/tests/level/sort_points_full.cc (revision 1601)
@@ -25,7 +25,7 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/level/sort_points.cc
+/*! \file tests/level/sort_points_full.cc
*
* \brief Tests on mln::level::sort_points.
*/
Index: trunk/milena/tests/display/color_pretty.cc
===================================================================
--- trunk/milena/tests/display/color_pretty.cc (revision 1600)
+++ trunk/milena/tests/display/color_pretty.cc (revision 1601)
@@ -25,7 +25,7 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/color_pretty.cc
+/*! \file tests/display/color_pretty.cc
*
* \brief Tests on mln::display::color::pretty.
*/
Index: trunk/milena/tests/border/duplicate_full.cc
===================================================================
--- trunk/milena/tests/border/duplicate_full.cc (revision 1600)
+++ trunk/milena/tests/border/duplicate_full.cc (revision 1601)
@@ -30,34 +30,115 @@
* \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>
+namespace mln
+{
+
+ template <typename T>
+ void chck1d(int cols, int border, T ref[])
+ {
+ int c = cols + 2 * border;
+
+ 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[])
+ {
+ 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] == ref[i]);
+ }
+
+}
-using namespace mln;
int
main (void)
{
+ using namespace mln;
+
+ std::cerr << "Tests border::duplicate:" << std::endl;
+
{
- (std::cerr << "Test border::mirror on int with border = 3 ...
").flush ();
+ std::cerr << " in 1d :" << std::endl;
- typedef int T;
+ {
+ (std::cerr << " on int_u8 with border = 3 ... ").flush ();
+
+ typedef value::int_u8 T;
int border = 3;
- int row = 4;
- int col = 5;
+ int cols = 2;
+ T ref[8] = {1, 1, 1, 1, 2, 2, 2, 2};
- int r = row + 2 * border;
- int c = col + 2 * border;
+ chck1d(cols, border, ref);
+ std::cerr << "OK" << std::endl;
+ }
- image2d<T> ima(row, col, border);
- debug::iota (ima);
- border::duplicate (ima);
+ {
+ (std::cerr << " on int with border = 2 ... ").flush ();
+
+ 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;
+ }
- T vs[110] =
+ {
+ (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,
@@ -71,27 +152,17 @@
16, 16, 16, 16, 17, 18, 19, 20, 20, 20, 20
};
- for (int i = 0; i < c * r; ++i)
- mln_assertion(ima[i] == vs[i]);
+ chck2d(rows, cols, border, ref);
std::cerr << "OK" << std::endl;
}
{
- (std::cerr << "Test border::mirror on int_u8 with border = 2 ...
").flush ();
-
+ (std::cerr << " on int_u8 with border = 3 ... ").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] =
+ 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,
@@ -103,27 +174,17 @@
16, 16, 16, 17, 18, 19, 20, 20, 20
};
- for (int i = 0; i < c * r; ++i)
- mln_assertion(ima[i] == vs[i]);
+ chck2d(rows, cols, border, ref);
std::cerr << "OK" << std::endl;
}
{
- (std::cerr << "Test border::mirror on int_s8 with border = 1 ...
").flush ();
-
+ (std::cerr << " 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] =
+ int rows = 4;
+ int cols = 5;
+ T ref[49] =
{
1, 1, 2, 3, 4, 5, 5,
1, 1, 2, 3, 4, 5, 5,
@@ -133,28 +194,17 @@
16, 16, 17, 18, 19, 20, 20
};
- for (int i = 0; i < c * r; ++i)
- mln_assertion(ima[i] == vs[i]);
+ chck2d(rows, cols, border, ref);
std::cerr << "OK" << std::endl;
}
-
{
- (std::cerr << "Test border::mirror on int with border = 0 ...
").flush ();
-
+ (std::cerr << " on int with border = 0 ... ").flush ();
typedef int T;
int border = 0;
- 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[20] =
+ int rows = 4;
+ int cols = 5;
+ T ref[20] =
{
1, 2, 3, 4, 5,
6, 7, 8, 9, 10,
@@ -162,10 +212,10 @@
16, 17, 18, 19, 20
};
- for (int i = 0; i < c * r; ++i)
- mln_assertion(ima[i] == vs[i]);
+ chck2d(rows, cols, border, ref);
std::cerr << "OK" << std::endl;
}
+ } // end of 2d
}
Index: trunk/milena/tests/border/mirror_full.cc
===================================================================
--- trunk/milena/tests/border/mirror_full.cc (revision 1600)
+++ trunk/milena/tests/border/mirror_full.cc (revision 1601)
@@ -37,28 +37,110 @@
#include <mln/value/int_u8.hh>
#include <mln/value/int_s8.hh>
-using namespace mln;
+
+namespace mln
+{
+
+ template <typename T>
+ void chck1d (int cols, int border, T ref[])
+ {
+ int c = cols + 2 * border;
+
+ image1d<T> ima(cols, border);
+ debug::iota(ima);
+ border::mirror(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[])
+ {
+ int r = rows + 2 * border;
+ int c = cols + 2 * border;
+
+ image2d<T> ima(rows, cols, border);
+ debug::iota(ima);
+ border::mirror(ima);
+
+ for (int i = 0; i < c * r; ++i)
+ mln_assertion(ima[i] == ref[i]);
+ }
+
+}
+
int
main (void)
{
+ using namespace mln;
+
+
+ std::cerr << "Tests border::mirror:" << std::endl;
+
+ {
+ std::cerr << " in 1d :" << std::endl;
{
- (std::cerr << "Test border::mirror on int with border = 3 ...
").flush ();
+ (std::cerr << " on int_u8 with border = 3 ... ").flush ();
- typedef int T;
+ typedef value::int_u8 T;
int border = 3;
- int row = 4;
- int col = 5;
+ int cols = 2;
+ T ref[8] = {2, 2, 1, 1, 2, 2, 1, 1};
+
+ chck1d(cols, border, ref);
+ std::cerr << "OK" << std::endl;
+ }
- int r = row + 2 * border;
- int c = col + 2 * border;
+ {
+ (std::cerr << " on int with border = 2 ... ").flush ();
- image2d<T> ima(row, col, border);
- debug::iota (ima);
- border::mirror (ima);
+ typedef int T;
+ int border = 2;
+ int cols = 3;
+ T ref[7] = {2, 1, 1, 2, 3, 3, 2};
+
+ 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
- T vs[110] =
+ {
+ 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, 11, 12, 13, 14, 15, 5, 5, 5,
1, 1, 1, 6, 7, 8, 9, 10, 5, 5, 5,
@@ -72,28 +154,17 @@
16, 16, 16, 6, 7, 8, 9, 10, 20, 20, 20
};
- for (int i = 0; i < c * r; ++i)
- mln_assertion(ima[i] == vs[i]);
-
+ chck2d(rows, cols, border, ref);
std::cerr << "OK" << std::endl;
}
{
- (std::cerr << "Test border::mirror on int_s8 with border = 2 ...
").flush ();
-
- typedef value::int_s8 T;
+ (std::cerr << " on int_u8 with border = 3 ... ").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::mirror (ima);
-
- T vs[72] =
+ int rows = 4;
+ int cols = 5;
+ T ref[72] =
{
1, 1, 6, 7, 8, 9, 10, 5, 5,
1, 1, 1, 2, 3, 4, 5, 5, 5,
@@ -105,28 +176,17 @@
16, 16, 11, 12, 13, 14, 15, 20, 20
};
- for (int i = 0; i < c * r; ++i)
- mln_assertion(ima[i] == vs[i]);
-
+ chck2d(rows, cols, border, ref);
std::cerr << "OK" << std::endl;
}
{
- (std::cerr << "Test border::mirror on int_u8 with border = 1 ...
").flush ();
-
- typedef value::int_u8 T;
+ (std::cerr << " 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::mirror (ima);
-
- T vs[49] =
+ int rows = 4;
+ int cols = 5;
+ T ref[49] =
{
1, 1, 2, 3, 4, 5, 5,
1, 1, 2, 3, 4, 5, 5,
@@ -136,27 +196,17 @@
16, 16, 17, 18, 19, 20, 20
};
- for (int i = 0; i < c * r; ++i)
- mln_assertion(ima[i] == vs[i]);
-
+ chck2d(rows, cols, border, ref);
std::cerr << "OK" << std::endl;
}
{
- (std::cerr << "Test border::mirror on int with border = 0 ...
").flush ();
-
+ (std::cerr << " on int with border = 0 ... ").flush ();
+ typedef int T;
int border = 0;
- int row = 4;
- int col = 5;
-
- int r = row + 2 * border;
- int c = col + 2 * border;
-
- image2d<int> ima(row, col, border);
- debug::iota (ima);
- border::mirror (ima);
-
- int vs[20] =
+ int rows = 4;
+ int cols = 5;
+ T ref[20] =
{
1, 2, 3, 4, 5,
6, 7, 8, 9, 10,
@@ -164,10 +214,10 @@
16, 17, 18, 19, 20
};
- for (int i = 0; i < c * r; ++i)
- mln_assertion(ima[i] == vs[i]);
-
+ chck2d(rows, cols, border, ref);
std::cerr << "OK" << std::endl;
}
+ } // end of 2d
+
}
Index: trunk/milena/tests/border/fill_full.cc
===================================================================
--- trunk/milena/tests/border/fill_full.cc (revision 1600)
+++ trunk/milena/tests/border/fill_full.cc (revision 1601)
@@ -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,8 +133,10 @@
{
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;
@@ -160,7 +162,7 @@
}
{
- std::cerr << "Tests border::fill on unsigned:" << std::endl;
+ std::cerr << " on unsigned:" << std::endl;
typedef unsigned T;
T value = (T) -1;
@@ -186,7 +188,7 @@
}
{
- 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;
@@ -212,7 +214,7 @@
}
{
- 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;
@@ -238,7 +240,7 @@
}
{
- 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;
@@ -264,7 +266,7 @@
}
{
- 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;
@@ -290,7 +292,7 @@
}
{
- 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);
@@ -316,7 +318,7 @@
}
{
- 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);
@@ -343,7 +345,7 @@
{
- 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);
@@ -369,7 +371,7 @@
}
{
- 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);
Index: trunk/milena/tests/border/fill.cc
===================================================================
--- trunk/milena/tests/border/fill.cc (revision 1600)
+++ trunk/milena/tests/border/fill.cc (revision 1601)
@@ -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.
*/
Index: trunk/milena/tests/logical/not_full.cc
===================================================================
--- trunk/milena/tests/logical/not_full.cc (revision 1600)
+++ trunk/milena/tests/logical/not_full.cc (revision 1601)
@@ -25,9 +25,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/logical/and_full.cc
+/*! \file tests/logical/not_full.cc
*
- * \brief Tests on mln::logical::and.
+ * \brief Tests on mln::logical::not.
*/
#include <mln/core/image1d.hh>
Index: trunk/milena/tests/logical/and_not_full.cc
===================================================================
--- trunk/milena/tests/logical/and_not_full.cc (revision 1600)
+++ trunk/milena/tests/logical/and_not_full.cc (revision 1601)
@@ -27,7 +27,7 @@
/*! \file tests/logical/and_not_full.cc
*
- * \brief Tests on mln::logical::and.
+ * \brief Tests on mln::logical::and_not.
*/
#include <mln/core/image1d.hh>
Index: trunk/milena/mln/trait/value/kind.hh
===================================================================
--- trunk/milena/mln/trait/value/kind.hh (revision 1600)
+++ trunk/milena/mln/trait/value/kind.hh (revision 1601)
@@ -56,13 +56,14 @@
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 \
// \ / \ \
// binary ternary fuzzy
-
+ */
struct data : any { std::string name() const { return "kind::data"; } };
};