minus_vv_test.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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/vec_operations.hpp>
  5. #include <boost/qvm/vec.hpp>
  6. #include "test_qvm_vector.hpp"
  7. #include "gold.hpp"
  8. namespace
  9. {
  10. template <class T,class U> struct same_type_tester;
  11. template <class T> struct same_type_tester<T,T> { };
  12. template <class T,class U> void test_same_type( T, U ) { same_type_tester<T,U>(); }
  13. template <int Dim>
  14. void
  15. test()
  16. {
  17. using namespace boost::qvm::sfinae;
  18. test_qvm::vector<V1,Dim> const x(42,2);
  19. {
  20. test_qvm::vector<V1,Dim> const y(42,1);
  21. test_same_type(x,x-y);
  22. test_qvm::vector<V1,Dim> r=x-y;
  23. test_qvm::subtract_v(r.b,x.b,y.b);
  24. BOOST_QVM_TEST_EQ(r.a,r.b);
  25. }
  26. {
  27. test_qvm::vector<V1,Dim> const y(42,1);
  28. test_qvm::vector<V2,Dim> r=vref(x)-y;
  29. test_qvm::subtract_v(r.b,x.b,y.b);
  30. BOOST_QVM_TEST_EQ(r.a,r.b);
  31. }
  32. {
  33. test_qvm::vector<V1,Dim> const y(42,1);
  34. test_qvm::vector<V2,Dim> r=x-vref(y);
  35. test_qvm::subtract_v(r.b,x.b,y.b);
  36. BOOST_QVM_TEST_EQ(r.a,r.b);
  37. }
  38. }
  39. }
  40. int
  41. main()
  42. {
  43. test<2>();
  44. test<3>();
  45. test<4>();
  46. test<5>();
  47. return boost::report_errors();
  48. }