]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/qvm/test/to_string_test.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / qvm / test / to_string_test.cpp
1 //Copyright (c) 2008-2016 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 #include <boost/qvm/to_string.hpp>
7 #include <boost/qvm/quat_operations.hpp>
8 #include <boost/qvm/vec_operations.hpp>
9 #include <boost/qvm/mat_operations.hpp>
10 #include "test_qvm_matrix.hpp"
11 #include "test_qvm_quaternion.hpp"
12 #include "test_qvm_vector.hpp"
13
14 namespace
15 {
16 template <int Rows,int Cols>
17 void
18 test_matrix( std::string const & gold )
19 {
20 using namespace boost::qvm::sfinae;
21 test_qvm::matrix<M1,Rows,Cols,int> const x(42,1);
22 std::string s=to_string(x);
23 BOOST_TEST(s==gold);
24 }
25
26 template <int Dim>
27 void
28 test_vector( std::string const & gold )
29 {
30 using namespace boost::qvm::sfinae;
31 test_qvm::vector<V1,Dim,int> const x(42,1);
32 std::string s=to_string(x);
33 BOOST_TEST(s==gold);
34 }
35
36 void
37 test_quaternion( std::string const & gold )
38 {
39 using namespace boost::qvm::sfinae;
40 test_qvm::quaternion<Q1,int> const x(42,1);
41 std::string s=to_string(x);
42 BOOST_TEST(s==gold);
43 }
44 }
45
46 int
47 main()
48 {
49 test_matrix<1,2>("((42,43))");
50 test_matrix<2,1>("((42)(43))");
51 test_matrix<2,2>("((42,43)(44,45))");
52 test_matrix<1,3>("((42,43,44))");
53 test_matrix<3,1>("((42)(43)(44))");
54 test_matrix<3,3>("((42,43,44)(45,46,47)(48,49,50))");
55 test_matrix<1,4>("((42,43,44,45))");
56 test_matrix<4,1>("((42)(43)(44)(45))");
57 test_matrix<4,4>("((42,43,44,45)(46,47,48,49)(50,51,52,53)(54,55,56,57))");
58 test_matrix<1,5>("((42,43,44,45,46))");
59 test_matrix<5,1>("((42)(43)(44)(45)(46))");
60 test_matrix<5,5>("((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))");
61 test_vector<2>("(42,43)");
62 test_vector<3>("(42,43,44)");
63 test_vector<4>("(42,43,44,45)");
64 test_vector<5>("(42,43,44,45,46)");
65 test_quaternion("(42,43,44,45)");
66 return boost::report_errors();
67 }