macros.cc 803 B

123456789101112131415161718192021222324252627282930313233
  1. // -*- mode: c++; coding: utf-8 -*-
  2. /// @file macros.cc
  3. /// @brief test type list library based on tuples.
  4. // (c) Daniel Llorens - 2010
  5. // This library is free software; you can redistribute it and/or modify it under
  6. // the terms of the GNU Lesser General Public License as published by the Free
  7. // Software Foundation; either version 3 of the License, or (at your option) any
  8. // later version.
  9. #include <iostream>
  10. #include "ra/macros.hh"
  11. using std::cout, std::endl;
  12. int main()
  13. {
  14. int errors = 0;
  15. int a = 0;
  16. #define ADDTHIS(x) a += x;
  17. FOR_EACH(ADDTHIS, 1, 2, 3);
  18. errors += (6!=a);
  19. a = 0;
  20. FOR_EACH(ADDTHIS, 7, 0);
  21. errors += (7!=a);
  22. a = 0;
  23. FOR_EACH(ADDTHIS, 3);
  24. errors += (3!=a);
  25. #undef ADDTHIS
  26. std::cout << errors << " errors" << endl;
  27. return errors;
  28. }