• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List

macros.hh

00001 // Copyright (C) 2007, 2009 EPITA Research and Development Laboratory
00002 // (LRDE)
00003 //
00004 // This file is part of Olena.
00005 //
00006 // Olena is free software: you can redistribute it and/or modify it under
00007 // the terms of the GNU General Public License as published by the Free
00008 // Software Foundation, version 2 of the License.
00009 //
00010 // Olena is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with Olena.  If not, see <http://www.gnu.org/licenses/>.
00017 //
00018 // As a special exception, you may use this file as part of a free
00019 // software project without restriction.  Specifically, if other files
00020 // instantiate templates or use macros or inline functions from this
00021 // file, or you compile this file and link it with other files to produce
00022 // an executable, this file does not by itself cause the resulting
00023 // executable to be covered by the GNU General Public License.  This
00024 // exception does not however invalidate any other reasons why the
00025 // executable file might be covered by the GNU General Public License.
00026 
00027 
00031 
00032 #define sym_compare_assert(V1, OP, V2)          \
00033                                                 \
00034     mln_assertion(V1 OP V2);                    \
00035     mln_assertion(-V1 OP -V2);                  \
00036     mln_assertion(V2 OP V1);                    \
00037     mln_assertion(-V2 OP -V1);
00038 
00039 #define asym_compare_assert(V1, OP, V2)         \
00040                                                 \
00041     mln_assertion(V1 OP V2);                    \
00042     mln_assertion(!(-V1 OP -V2));               \
00043     mln_assertion(-V2 OP -V1);                  \
00044     mln_assertion(!(V2 OP V1));
00045 
00046 // For unsigned types, V1 > V2 if op is minus
00047 #define test_interop(T1, T2, OP, V1, V2)                \
00048                                                         \
00049 {                                                       \
00050     T1 i = V1;                                          \
00051     T2 j = V2;                                          \
00052                                                         \
00053     i = i OP j;                                         \
00054     sym_compare_assert(i, ==, float(V1 OP V2));         \
00055     sym_compare_assert(j, ==, float(V2));               \
00056                                                         \
00057     i = V1;                                             \
00058     j = V2;                                             \
00059                                                         \
00060     j = i OP j;                                         \
00061     sym_compare_assert(j, ==, float(V1 OP V2));         \
00062     sym_compare_assert(i, ==, float(V1));               \
00063                                                         \
00064     i = V1;                                             \
00065     i OP##= i;                                          \
00066     sym_compare_assert(i, ==, float(V1 OP V1));         \
00067                                                         \
00068     i = V1;                                             \
00069     j = V2;                                             \
00070     i OP##= j;                                          \
00071     sym_compare_assert(i, ==, float(V1 OP V2));         \
00072                                                         \
00073     j OP##= j;                                          \
00074     sym_compare_assert(j, ==, float(V2 OP V2));         \
00075                                                         \
00076     i = V1;                                             \
00077     j = V2;                                             \
00078     j OP##= i;                                          \
00079     sym_compare_assert(j, ==, float(V2 OP V1));         \
00080                                                         \
00081     i = V1;                                             \
00082     i OP##= i;                                          \
00083     sym_compare_assert(i, ==, float(((V1 OP V1))));     \
00084 }
00085 
00086 #define test_operator(T, OP, V1, V2)            \
00087                                                 \
00088 {                                               \
00089     T i = V1;                                   \
00090     T j = V2;                                   \
00091                                                 \
00092     i = i OP j;                                 \
00093     sym_compare_assert(i, ==, float(V1 OP V2)); \
00094     sym_compare_assert(j, ==, float(V2));       \
00095                                                 \
00096     i = V1;                                     \
00097     i OP##= i;                                  \
00098     sym_compare_assert(i, ==, float(V1 OP V1)); \
00099                                                 \
00100     i = V1;                                     \
00101     j = V2;                                     \
00102     i OP##= j;                                  \
00103 }

Generated on Tue Oct 4 2011 15:24:03 for Milena (Olena) by  doxygen 1.7.1