minus_qq_test.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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/quat_operations.hpp>
  5. #include <boost/qvm/quat.hpp>
  6. #include "test_qvm_quaternion.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. void
  14. test()
  15. {
  16. using namespace boost::qvm::sfinae;
  17. test_qvm::quaternion<Q1> const x(42,2);
  18. {
  19. test_qvm::quaternion<Q1> const y(42,1);
  20. test_same_type(x,x-y);
  21. test_qvm::quaternion<Q1> r=x-y;
  22. test_qvm::subtract_v(r.b,x.b,y.b);
  23. BOOST_QVM_TEST_EQ(r.a,r.b);
  24. }
  25. {
  26. test_qvm::quaternion<Q1> const y(42,1);
  27. test_qvm::quaternion<Q2> r=qref(x)-y;
  28. test_qvm::subtract_v(r.b,x.b,y.b);
  29. BOOST_QVM_TEST_EQ(r.a,r.b);
  30. }
  31. {
  32. test_qvm::quaternion<Q1> const y(42,1);
  33. test_qvm::quaternion<Q2> r=x-qref(y);
  34. test_qvm::subtract_v(r.b,x.b,y.b);
  35. BOOST_QVM_TEST_EQ(r.a,r.b);
  36. }
  37. }
  38. }
  39. int
  40. main()
  41. {
  42. test();
  43. return boost::report_errors();
  44. }