math_test.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright (C) 2016 Intel Corporation. All rights reserved.
  3. *
  4. * This file is free software: you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the
  6. * Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This file is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. * See the GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along
  15. * with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #pragma once
  18. #include <iostream>
  19. #include <AP_gtest.h>
  20. #include <AP_Math/AP_Math.h>
  21. /*
  22. * Overload operator << for AP_Math types to allow nice printing for failed
  23. * tests.
  24. */
  25. template <typename T>
  26. ::std::ostream& operator<<(::std::ostream& os, const Matrix3<T>& m)
  27. {
  28. return os << "{{" << m.a.x << ", " << m.a.y << ", " << m.a.z << "}, " <<
  29. "{" << m.b.x << ", " << m.b.y << ", " << m.b.z << "}, " <<
  30. "{" << m.c.x << ", " << m.c.y << ", " << m.c.z << "}}";
  31. }
  32. template <typename T>
  33. ::std::ostream& operator<<(::std::ostream& os, const Vector3<T>& v)
  34. {
  35. return os << "{" << v.x << ", " << v.y << ", " << v.z << "}";
  36. }