URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-12-04 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Complete rgb_full test.
* tests/value/rgb_full.cc: tests interoperability with more types.
---
rgb_full.cc | 52 ++++++++++++++++++++++++++++++++++++----------------
1 file changed, 36 insertions(+), 16 deletions(-)
Index: trunk/milena/tests/value/rgb_full.cc
===================================================================
--- trunk/milena/tests/value/rgb_full.cc (revision 1587)
+++ trunk/milena/tests/value/rgb_full.cc (revision 1588)
@@ -40,58 +40,58 @@
\
mln_assertion(V1 OP V2);
-#define compute_rgb(V1, OP, V2) \
+#define compute_rgb(T, V1, OP, V2) \
\
- rgb8( \
+ T( \
V1.red() OP V2.red() , \
V1.green() OP V2.green() , \
V1.blue() OP V2.blue() \
)
-#define compute_rgb_sc(V1, OP, V2) \
+#define compute_rgb_sc(T, V1, OP, V2) \
\
- rgb8( \
+ T( \
V1.red() OP V2 , \
V1.green() OP V2 , \
V1.blue() OP V2 \
)
-
+// Interop between 2 rgbs.
#define test_interop(T1, T2, OP, V1, V2) \
{ \
T1 i = V1; \
T2 j = V2; \
\
i = i OP j; \
- sym_compare_assert(i, ==, compute_rgb(V1, OP, V2)); \
+ sym_compare_assert(i, ==, compute_rgb(T1, V1, OP, V2)); \
sym_compare_assert(j, ==, V2); \
\
i = V1; \
j = V2; \
\
j = i OP j; \
- sym_compare_assert(j, ==, compute_rgb(V1, OP, V2)); \
+ sym_compare_assert(j, ==, compute_rgb(T1,V1, OP, V2)); \
sym_compare_assert(i, ==, V1); \
\
i = V1; \
i OP##= i; \
- sym_compare_assert(i, ==, compute_rgb(V1, OP, V1)); \
+ sym_compare_assert(i, ==, compute_rgb(T1,V1, OP, V1)); \
\
i = V1; \
j = V2; \
i OP##= j; \
- sym_compare_assert(i, ==, compute_rgb(V1, OP, V2)); \
+ sym_compare_assert(i, ==, compute_rgb(T1,V1, OP, V2)); \
\
j OP##= j; \
- sym_compare_assert(j, ==, compute_rgb(V2, OP, V2)); \
+ sym_compare_assert(j, ==, compute_rgb(T1,V2, OP, V2)); \
\
i = V1; \
j = V2; \
j OP##= i; \
- sym_compare_assert(j, ==, compute_rgb(V2, OP, V1)); \
+ sym_compare_assert(j, ==, compute_rgb(T1,V2, OP, V1)); \
\
i = V1; \
i OP##= i; \
- sym_compare_assert(i, ==, compute_rgb(V1, OP, V1)); \
+ sym_compare_assert(i, ==, compute_rgb(T1,V1, OP, V1)); \
}
@@ -102,17 +102,17 @@
T2 j = V2; \
\
i = i OP j; \
- sym_compare_assert(i, ==, compute_rgb_sc(V1, OP, V2)); \
+ sym_compare_assert(i, ==, compute_rgb_sc(T1,V1, OP, V2)); \
sym_compare_assert(j, ==, V2); \
\
i = V1; \
i OP##= i; \
- sym_compare_assert(i, ==, compute_rgb(V1, OP, V1)); \
+ sym_compare_assert(i, ==, compute_rgb(T1,V1, OP, V1)); \
\
i = V1; \
j = V2; \
i OP##= j; \
- sym_compare_assert(i, ==, compute_rgb_sc(V1, OP, V2)); \
+ sym_compare_assert(i, ==, compute_rgb_sc(T1, V1, OP, V2)); \
}
int main()
@@ -121,17 +121,37 @@
using value::rgb;
using value::rgb8;
using value::int_u8;
+ using value::int_u;
using literal::blue;
using literal::white;
{
test_interop(rgb8, rgb8, +, rgb8(4,5,6), rgb8(1,2,3));
- test_interop(rgb8, rgb8, -, rgb8(4,5,6), rgb8(1,2,3))
+ test_interop(rgb8, rgb8, -, rgb8(4,5,6), rgb8(1,2,3));
+
+ test_interop(rgb<10>, rgb<10>, +, rgb<10>(4,5,6),
rgb<10>(1,2,3));
+ test_interop(rgb<10>, rgb<10>, -, rgb<10>(4,5,6),
rgb<10>(1,2,3));
+
+ test_interop(rgb<16>, rgb<16>, +, rgb<16>(4,5,6),
rgb<16>(1,2,3));
+ test_interop(rgb<16>, rgb<16>, -, rgb<16>(4,5,6),
rgb<16>(1,2,3));
+
test_interop_sc(rgb8, int, *, rgb8(4,5,6), 4);
test_interop_sc(rgb8, int, /, rgb8(40,50,60), 10);
+ test_interop_sc(rgb8, unsigned, *, rgb8(4,5,6), 4);
+ test_interop_sc(rgb8, unsigned, /, rgb8(40,50,60), 10);
+
+ test_interop_sc(rgb8, float, *, rgb8(4,5,6), 4);
+ test_interop_sc(rgb8, float, /, rgb8(40,50,60), 10);
+
+ test_interop_sc(rgb8, char, *, rgb8(4,5,6), 4);
+ test_interop_sc(rgb8, char, /, rgb8(40,50,60), 10);
+
test_interop_sc(rgb8, int_u8, *, rgb8(4,5,6), 4);
test_interop_sc(rgb8, int_u8, /, rgb8(40,50,60), 10);
+
+ test_interop_sc(rgb8, int_u<7>, *, rgb8(4,5,6), 4);
+ test_interop_sc(rgb8, int_u<7>, /, rgb8(40,50,60), 10);
}
}