zero_vec_test.cpp 1.2 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. namespace
  8. {
  9. template <class T,class U>
  10. struct same_type;
  11. template <class T>
  12. struct
  13. same_type<T,T>
  14. {
  15. };
  16. template <class T,class U>
  17. void
  18. check_deduction( T const &, U const & )
  19. {
  20. same_type<T,typename boost::qvm::deduce_vec<U>::type>();
  21. }
  22. template <int Dim>
  23. void
  24. test()
  25. {
  26. using namespace boost::qvm;
  27. test_qvm::vector<V1,Dim> v1=zero_vec<float,Dim>();
  28. for( int i=0; i!=Dim; ++i )
  29. BOOST_TEST(!v1.a[i]);
  30. test_qvm::vector<V2,Dim> v2(42,1);
  31. set_zero(v2);
  32. for( int i=0; i!=Dim; ++i )
  33. BOOST_TEST(!v2.a[i]);
  34. check_deduction(vec<float,Dim>(),zero_vec<float,Dim>());
  35. check_deduction(vec<int,Dim>(),zero_vec<int,Dim>());
  36. }
  37. }
  38. int
  39. main()
  40. {
  41. test<2>();
  42. test<3>();
  43. test<4>();
  44. test<5>();
  45. return boost::report_errors();
  46. }