early.cc 1007 B

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