scalar_cast_m_test.cpp 877 B

12345678910111213141516171819202122232425262728293031323334
  1. //Copyright (c) 2008-2016 Emil Dotchevski and Reverge Studios, Inc.
  2. //Distributed under the Boost Software License, Version 1.0. (See accompanying
  3. //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  4. #include <boost/qvm/mat_operations.hpp>
  5. #include "test_qvm_matrix.hpp"
  6. #include "gold.hpp"
  7. namespace
  8. {
  9. template <int Rows,int Cols>
  10. void
  11. test()
  12. {
  13. using namespace boost::qvm::sfinae;
  14. test_qvm::matrix<M1,Rows,Cols,double> x(42,1);
  15. test_qvm::matrix<M1,Rows,Cols,float> y;
  16. assign(y,scalar_cast<float>(x));
  17. for( int i=0; i!=Rows; ++i )
  18. for( int j=0; j!=Cols; ++j )
  19. y.b[i][j]=static_cast<float>(x.a[i][j]);
  20. BOOST_QVM_TEST_EQ(y.a,y.b);
  21. }
  22. }
  23. int
  24. main()
  25. {
  26. test<1,2>();
  27. test<2,1>();
  28. test<2,2>();
  29. return boost::report_errors();
  30. }