ra-11.cc 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // -*- mode: c++; coding: utf-8 -*-
  2. // ra-ra/test - Reduce a bug in gcc 8.3.
  3. // (c) Daniel Llorens - 2013-2015
  4. // This library is free software; you can redistribute it and/or modify it under
  5. // the terms of the GNU Lesser General Public License as published by the Free
  6. // Software Foundation; either version 3 of the License, or (at your option) any
  7. // later version.
  8. #include <numeric>
  9. #include <iostream>
  10. #include <iterator>
  11. #include "ra/test.hh"
  12. #include "mpdebug.hh"
  13. using std::cout, std::endl, std::flush, ra::TestRecorder;
  14. int main()
  15. {
  16. TestRecorder tr(std::cout);
  17. {
  18. double b[6] = { 1, 2, 3, 4, 5, 6 };
  19. ra::View<double> ra { {6}, b };
  20. tr.test_eq(b, ra);
  21. ra::Unique<double> A({2, 3}, 0);
  22. tr.test_eq(ra::Small<ra::dim_t, 2> {2, 3}, shape(iter<-2>(A)));
  23. tr.test_eq(ra::Small<ra::dim_t, 1> {2}, shape(iter<-1>(A)));
  24. double pool[6] = { 1, 2, 3, 4, 5, 6 };
  25. ra::Unique<double> u({3, 2}, pool, 6);
  26. tr.test(std::equal(pool, pool+6, u.begin()));
  27. ra::Unique<double> q(ra::scalar(44));
  28. tr.test_eq(1, q.size());
  29. double rpool[6] = { 1, 2, 3, 4, 5, 6 };
  30. ra::View<double, 2> r { {{3, 1}, {2, 3}}, rpool };
  31. double rcheck[6] = { 1, 4, 2, 5, 3, 6 };
  32. tr.test(std::equal(rcheck, rcheck+6, r.at(ra::Big<int>({0}, {})).begin()));
  33. }
  34. return tr.summary();
  35. }