#include <catch.hpp>
#include <boost/log/trivial.hpp>
#include "class_vec_3d.hpp"
Go to the source code of this file.
| #define BOOST_LOG_DYN_LINK 1 |
| TEST_CASE |
( |
"UNIT TEST: vector class {Vec_3D<T>}" |
, |
|
|
"" |
[core] |
|
) |
| |
Definition at line 8 of file test_vec_3d.cpp.
References CHECK, CHECK_FALSE, REQUIRE, and sqrt().
10 BOOST_LOG_TRIVIAL(info) << "vector
class {
Vec_3D<T>}
"; 12 Vec_3D<double> vec_d(sqrt(2.), -sqrt(2.), sqrt(5.)); 13 Vec_3D<float> vec_f(sqrt(2.f), -sqrt(2.f), sqrt(5.f)); 14 Vec_3D<int> vec_i(3,0,-4); 15 CHECK( vec_d.norm() == Approx(3.) ); 16 CHECK( vec_f.norm() == Approx(3.) ); 17 CHECK( vec_i.norm() == Approx(5) ); 19 REQUIRE( vec_f[0] == Approx(sqrt(2.f)) ); 20 REQUIRE( vec_f[2] == Approx(sqrt(5.)) ); 23 REQUIRE( vec_d[0] == -1.345E1 ); 24 REQUIRE( vec_d[2] == -13.45 ); 27 vec_i+=Vec_3D<int>(2, 3, -4); 28 REQUIRE ( (vec_i[0] + vec_i[1] + vec_i[2]) == Approx(1) ); 29 // Vec_3D<double> vec_d2 = vec_i + Vec_3D<double>(1., 1.5, -3.5)*2.; 30 // REQUIRE( vec_d2[0] == Approx(4.) ); 31 // REQUIRE( vec_d2[1] == Approx(6.) ); 32 // REQUIRE( vec_d2[2] == Approx(-11.) ); 37 // for (double val : vec_d2) sumd += val; 38 for (int val : vec_i) sumi += val; 40 // CHECK( sumd == Approx(-1.) ); 43 CHECK( Vec_3D<int>(4, -3, 8) == Vec_3D<int>(4, -3, 8) ); 44 CHECK_FALSE( Vec_3D<int>(4, -3, 8) != Vec_3D<int>(4, -3, 8) ); 45 CHECK( Vec_3D<int>(4, -3, 8) <= Vec_3D<int>(6, 0, 8) ); 46 CHECK_FALSE( Vec_3D<int>(4, -3, 8) < Vec_3D<int>(2, 0, 10) ); 47 CHECK_FALSE( Vec_3D<int>(4, -3, 8) > Vec_3D<int>(4, 0, 8) ); 48 }: class handling basic 3D-vector functions, definitions