* tests/literal/Makefile.am: Update targets.
* tests/literal/colors.cc,
* tests/literal/identity.cc,
* tests/literal/max.cc,
* tests/literal/min.cc,
* tests/literal/origin.cc: New.
* tests/literal/medium_gray.cc: Make a real test.
---
milena/ChangeLog | 14 +++++
milena/tests/literal/Makefile.am | 12 ++++-
.../tests/literal/colors.cc | 62 +++++++++++---------
.../tests/literal/identity.cc | 31 +++++-----
.../color_type.hh => milena/tests/literal/max.cc | 27 ++++-----
milena/tests/literal/medium_gray.cc | 25 +++-----
.../color_type.hh => milena/tests/literal/min.cc | 27 ++++-----
.../{core/site_set/box.cc => literal/origin.cc} | 18 +++---
8 files changed, 118 insertions(+), 98 deletions(-)
copy scribo/tests/filter/object_links_left_aligned.cc =>
milena/tests/literal/colors.cc (55%)
copy scribo/scribo/core/def/color_type.hh => milena/tests/literal/identity.cc (79%)
copy scribo/scribo/core/def/color_type.hh => milena/tests/literal/max.cc (79%)
copy scribo/scribo/core/def/color_type.hh => milena/tests/literal/min.cc (79%)
copy milena/tests/{core/site_set/box.cc => literal/origin.cc} (81%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index bbbc6ea..fdf84db 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,19 @@
2011-11-23 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Improve tests for literal classes.
+
+ * tests/literal/Makefile.am: Update targets.
+
+ * tests/literal/colors.cc,
+ * tests/literal/identity.cc,
+ * tests/literal/max.cc,
+ * tests/literal/min.cc,
+ * tests/literal/origin.cc: New.
+
+ * tests/literal/medium_gray.cc: Make a real test.
+
+2011-11-23 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Fix compilation with multiple files.
* mln/canvas/browsing/backdiagonal2d.hh,
diff --git a/milena/tests/literal/Makefile.am b/milena/tests/literal/Makefile.am
index ef86851..81e3a16 100644
--- a/milena/tests/literal/Makefile.am
+++ b/milena/tests/literal/Makefile.am
@@ -1,4 +1,4 @@
-# Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+# Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development
# Laboratory (LRDE).
#
# This file is part of Olena.
@@ -19,14 +19,24 @@ include $(top_srcdir)/milena/tests/tests.mk
check_PROGRAMS = \
black \
+ colors \
+ identity \
+ max \
medium_gray \
+ min \
one \
+ origin \
white \
zero
black_SOURCES = black.cc
+colors_SOURCES = colors.cc
+identity_SOURCES = identity.cc
+max_SOURCES = max.cc
medium_gray_SOURCES = medium_gray.cc
+min_SOURCES = min.cc
one_SOURCES = one.cc
+origin_SOURCES = origin.cc
white_SOURCES = white.cc
zero_SOURCES = zero.cc
diff --git a/scribo/tests/filter/object_links_left_aligned.cc
b/milena/tests/literal/colors.cc
similarity index 55%
copy from scribo/tests/filter/object_links_left_aligned.cc
copy to milena/tests/literal/colors.cc
index ce630f5..2635dc8 100644
--- a/scribo/tests/filter/object_links_left_aligned.cc
+++ b/milena/tests/literal/colors.cc
@@ -25,45 +25,53 @@
/// \file
-#include <iostream>
+#include <mln/value/rgb8.hh>
+#include <mln/literal/colors.hh>
-#include <mln/core/image/image2d.hh>
-#include <mln/core/alias/neighb2d.hh>
-#include <mln/io/pbm/load.hh>
-#include <scribo/core/def/lbl_type.hh>
-#include <scribo/primitive/extract/components.hh>
-#include <scribo/primitive/link/with_single_left_link.hh>
-#include <scribo/filter/object_links_left_aligned.hh>
-
-#include "tests/data.hh"
int main()
{
- using namespace scribo;
using namespace mln;
- std::string img = SCRIBO_IMG_DIR "/phillip.pbm";
+ value::rgb8 v = literal::red;
+ mln_assertion(v == value::rgb8(255, 0, 0));
+
+ v = literal::green;
+ mln_assertion(v == value::rgb8(0, 255, 0));
+
+ v = literal::blue;
+ mln_assertion(v == value::rgb8(0, 0, 255));
+
+ v = literal::brown;
+ mln_assertion(v == value::rgb8(191, 127, 64));
+
+ v = literal::lime;
+ mln_assertion(v == value::rgb8(191, 255, 0));
+
+ v = literal::orange;
+ mln_assertion(v == value::rgb8(255, 127, 0));
- const unsigned ref[] = { 0, 2, 6, 8, 3, 4, 6, 9, 2, 4 };
- const unsigned filtered_ref[] = { 0, 2, 2, 8, 4, 4, 6, 9, 2, 4 };
+ v = literal::pink;
+ mln_assertion(v == value::rgb8(255, 191, 191));
- image2d<bool> input;
- io::pbm::load(input, img.c_str());
+ v = literal::purple;
+ mln_assertion(v == value::rgb8(191, 0, 64));
- typedef scribo::def::lbl_type V;
- typedef image2d<V> L;
+ v = literal::teal;
+ mln_assertion(v == value::rgb8(0, 127, 127));
- V nbboxes;
- component_set<L>
- text = primitive::extract::components(input, c8(), nbboxes);
+ v = literal::violet;
+ mln_assertion(v == value::rgb8(127, 0, 127));
- object_links<L> links = primitive::link::with_single_left_link(text, 30);
+ v = literal::cyan;
+ mln_assertion(v == value::rgb8(0, 255, 255));
- for_all_links(l, links)
- mln_assertion(links(l) == ref[l]);
+ v = literal::magenta;
+ mln_assertion(v == value::rgb8(255, 0, 255));
- links = scribo::filter::object_links_left_aligned(links, 80.f);
+ v = literal::yellow;
+ mln_assertion(v == value::rgb8(255, 255, 0));
- for_all_links(l, links)
- mln_assertion(links(l) == filtered_ref[l]);
+ v = literal::olive;
+ mln_assertion(v == value::rgb8(127, 127, 0));
}
diff --git a/scribo/scribo/core/def/color_type.hh b/milena/tests/literal/identity.cc
similarity index 79%
copy from scribo/scribo/core/def/color_type.hh
copy to milena/tests/literal/identity.cc
index 7acd334..e8cbc3d 100644
--- a/scribo/scribo/core/def/color_type.hh
+++ b/milena/tests/literal/identity.cc
@@ -23,26 +23,25 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_CORE_COLOR_TYPE_HH
-# define SCRIBO_CORE_COLOR_TYPE_HH
-
/// \file
-///
-/// Global type definition for labels.
-
-# include <mln/value/rgb8.hh>
+#include <mln/core/contract.hh>
+#include <mln/literal/identity.hh>
+#include <mln/algebra/mat.hh>
+#include <mln/make/mat.hh>
-namespace scribo
-{
- namespace def
- {
- typedef mln::value::rgb8 color_type;
-
- } // end of namespace scribo::def
+int main()
+{
+ using namespace mln;
-} // end of namespace scribo
+ int val[4] = {
+ 1, 0 ,
+ 0, 1
+ };
-#endif // ! SCRIBO_CORE_DEF_HH
+ algebra::mat<2,2, int> m = literal::identity;
+ algebra::mat<2,2, int> ref = make::mat<2,2>(val);
+ mln_assertion(m == ref);
+}
diff --git a/scribo/scribo/core/def/color_type.hh b/milena/tests/literal/max.cc
similarity index 79%
copy from scribo/scribo/core/def/color_type.hh
copy to milena/tests/literal/max.cc
index 7acd334..5bbf170 100644
--- a/scribo/scribo/core/def/color_type.hh
+++ b/milena/tests/literal/max.cc
@@ -23,26 +23,23 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_CORE_COLOR_TYPE_HH
-# define SCRIBO_CORE_COLOR_TYPE_HH
-
/// \file
-///
-/// Global type definition for labels.
-
-# include <mln/value/rgb8.hh>
+#include <mln/literal/max.hh>
+#include <mln/value/int_u8.hh>
-namespace scribo
-{
- namespace def
- {
- typedef mln::value::rgb8 color_type;
+int main()
+{
+ using namespace mln;
- } // end of namespace scribo::def
+ unsigned char c = literal::max;
+ mln_assertion(c == mln_max(unsigned char));
-} // end of namespace scribo
+ double d = literal::max;
+ mln_assertion(d == mln_max(double));
-#endif // ! SCRIBO_CORE_DEF_HH
+ value::int_u8 v = literal::max;
+ mln_assertion(v == mln_max(value::int_u8));
+}
diff --git a/milena/tests/literal/medium_gray.cc b/milena/tests/literal/medium_gray.cc
index 75995fb..278c46c 100644
--- a/milena/tests/literal/medium_gray.cc
+++ b/milena/tests/literal/medium_gray.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -23,6 +24,8 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
+/// \file
+
#include <mln/literal/grays.hh>
#include <mln/value/graylevel.hh>
#include <mln/value/gl8.hh>
@@ -33,20 +36,12 @@ int main()
{
using namespace mln;
- using literal::medium_gray;
- using value::gl8;
- using value::gl16;
-
- gl8 a;
- gl16 b;
-
- a = medium_gray;
-
- std::cout << int(a.value()) << std::endl;
+ value::gl8 a = literal::medium_gray;
+ mln_assertion(a == value::gl8(128));
- b = a;
- std::cout << int(b.value()) << std::endl;
+ value::gl16 b = a;
+ mln_assertion(b == value::gl16(32768));
- b = medium_gray;
- std::cout << int(b.value()) << std::endl;
+ b = literal::medium_gray;
+ mln_assertion(b == value::gl16(32768));
}
diff --git a/scribo/scribo/core/def/color_type.hh b/milena/tests/literal/min.cc
similarity index 79%
copy from scribo/scribo/core/def/color_type.hh
copy to milena/tests/literal/min.cc
index 7acd334..254f5f9 100644
--- a/scribo/scribo/core/def/color_type.hh
+++ b/milena/tests/literal/min.cc
@@ -23,26 +23,23 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_CORE_COLOR_TYPE_HH
-# define SCRIBO_CORE_COLOR_TYPE_HH
-
/// \file
-///
-/// Global type definition for labels.
-
-# include <mln/value/rgb8.hh>
+#include <mln/literal/min.hh>
+#include <mln/value/int_u8.hh>
-namespace scribo
-{
- namespace def
- {
- typedef mln::value::rgb8 color_type;
+int main()
+{
+ using namespace mln;
- } // end of namespace scribo::def
+ unsigned char c = literal::min;
+ mln_assertion(c == mln_min(unsigned char));
-} // end of namespace scribo
+ double d = literal::min;
+ mln_assertion(d == mln_min(double));
-#endif // ! SCRIBO_CORE_DEF_HH
+ value::int_u8 v = literal::min;
+ mln_assertion(v == mln_min(value::int_u8));
+}
diff --git a/milena/tests/core/site_set/box.cc b/milena/tests/literal/origin.cc
similarity index 81%
copy from milena/tests/core/site_set/box.cc
copy to milena/tests/literal/origin.cc
index ad5c119..312948d 100644
--- a/milena/tests/core/site_set/box.cc
+++ b/milena/tests/literal/origin.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -23,20 +23,20 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#include <mln/core/site_set/box.hh>
-#include <mln/core/alias/box2d.hh>
+/// \file
+
#include <mln/core/alias/point2d.hh>
+#include <mln/core/alias/point3d.hh>
+#include <mln/literal/origin.hh>
int main()
{
using namespace mln;
- box2d
- b1(point2d(0,0), point2d(3, 4)),
- b2(point2d(-1,-1), point2d(4, 5));
-
- b1.merge(b2);
+ point2d p2 = literal::origin;
+ mln_assertion(p2 == point2d(0, 0));
- mln_assertion(b1 == b2);
+ point3d p3 = literal::origin;
+ mln_assertion(p3 == point3d(0, 0, 0));
}
--
1.7.2.5