| 1 | // Copyright 2008-2022 Emil Dotchevski and Reverge Studios, Inc. |
| 2 | |
| 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying |
| 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 5 | |
| 6 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER |
| 7 | # include BOOST_QVM_TEST_SINGLE_HEADER |
| 8 | #else |
| 9 | # include <boost/qvm/to_string.hpp> |
| 10 | # include <boost/qvm/quat_operations.hpp> |
| 11 | # include <boost/qvm/vec_operations.hpp> |
| 12 | # include <boost/qvm/mat_operations.hpp> |
| 13 | #endif |
| 14 | |
| 15 | #include "test_qvm_matrix.hpp" |
| 16 | #include "test_qvm_quaternion.hpp" |
| 17 | #include "test_qvm_vector.hpp" |
| 18 | |
| 19 | namespace |
| 20 | { |
| 21 | template <int Rows,int Cols> |
| 22 | void |
| 23 | test_matrix( std::string const & gold ) |
| 24 | { |
| 25 | using namespace boost::qvm::sfinae; |
| 26 | test_qvm::matrix<M1,Rows,Cols,int> const x(42,1); |
| 27 | std::string s=to_string(x); |
| 28 | BOOST_TEST(s==gold); |
| 29 | } |
| 30 | |
| 31 | template <int Dim> |
| 32 | void |
| 33 | test_vector( std::string const & gold ) |
| 34 | { |
| 35 | using namespace boost::qvm::sfinae; |
| 36 | test_qvm::vector<V1,Dim,int> const x(42,1); |
| 37 | std::string s=to_string(x); |
| 38 | BOOST_TEST(s==gold); |
| 39 | } |
| 40 | |
| 41 | void |
| 42 | test_quaternion( std::string const & gold ) |
| 43 | { |
| 44 | using namespace boost::qvm::sfinae; |
| 45 | test_qvm::quaternion<Q1,int> const x(42,1); |
| 46 | std::string s=to_string(a: x); |
| 47 | BOOST_TEST(s==gold); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | int |
| 52 | main() |
| 53 | { |
| 54 | test_matrix<1,2>(gold: "((42,43))" ); |
| 55 | test_matrix<2,1>(gold: "((42)(43))" ); |
| 56 | test_matrix<2,2>(gold: "((42,43)(44,45))" ); |
| 57 | test_matrix<1,3>(gold: "((42,43,44))" ); |
| 58 | test_matrix<3,1>(gold: "((42)(43)(44))" ); |
| 59 | test_matrix<3,3>(gold: "((42,43,44)(45,46,47)(48,49,50))" ); |
| 60 | test_matrix<1,4>(gold: "((42,43,44,45))" ); |
| 61 | test_matrix<4,1>(gold: "((42)(43)(44)(45))" ); |
| 62 | test_matrix<4,4>(gold: "((42,43,44,45)(46,47,48,49)(50,51,52,53)(54,55,56,57))" ); |
| 63 | test_matrix<1,5>(gold: "((42,43,44,45,46))" ); |
| 64 | test_matrix<5,1>(gold: "((42)(43)(44)(45)(46))" ); |
| 65 | test_matrix<5,5>(gold: "((42,43,44,45,46)(47,48,49,50,51)(52,53,54,55,56)(57,58,59,60,61)(62,63,64,65,66))" ); |
| 66 | test_vector<2>(gold: "(42,43)" ); |
| 67 | test_vector<3>(gold: "(42,43,44)" ); |
| 68 | test_vector<4>(gold: "(42,43,44,45)" ); |
| 69 | test_vector<5>(gold: "(42,43,44,45,46)" ); |
| 70 | test_quaternion(gold: "(42,43,44,45)" ); |
| 71 | return boost::report_errors(); |
| 72 | } |
| 73 | |