early.C 1012 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // -*- mode: c++; coding: utf-8 -*-
  2. /// @file early.C
  3. /// @brief Tests for early()
  4. // (c) Daniel Llorens - 2019
  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 "ra/operators.H"
  10. #include "ra/io.H"
  11. #include "ra/test.H"
  12. using std::cout, std::endl;
  13. int main()
  14. {
  15. TestRecorder tr(std::cout);
  16. tr.section("any, every rank 0");
  17. {
  18. ra::Big<int, 0> a = 99;
  19. tr.test(any(a==99));
  20. tr.test(every(a==99));
  21. }
  22. tr.section("any, every static rank");
  23. {
  24. ra::Big<int, 2> a({2, 3}, ra::_0*2 + ra::_1*10);
  25. tr.test(!any(odd(a)));
  26. tr.test(every(!odd(a)));
  27. }
  28. tr.section("any, every dyn rank");
  29. {
  30. ra::Big<int> a = ra::iota(9)*2;
  31. tr.test(!any(odd(a)));
  32. tr.test(every(!odd(a)));
  33. }
  34. return tr.summary();
  35. }