units
Use physical dimensions at compile-time or run-time.
Typedefs | Functions
dyndim-base-test.cpp File Reference

Test-cases for vnix::units::dyndim_base. More...

#include "../vnix/units/statdim-base.hpp"
#include "catch.hpp"
Include dependency graph for dyndim-base-test.cpp:

Go to the source code of this file.

Typedefs

using dim = vnix::units::dim
 
template<uint64_t D>
using statdim_base = vnix::units::statdim_base< D >
 
using dyndim_base = vnix::units::dyndim_base
 

Functions

 TEST_CASE ("Check dimension on dyndim_base from dim.","[dyndim-base]")
 
 TEST_CASE ("Sum & diff require same dimension for dyndim.","[dyndim-base]")
 
 TEST_CASE ("Prod & quot change dimension for dyndim.","[dyndim-base]")
 
 TEST_CASE ("Pow and sqrt change dimension for dyndim.","[dyndim-base]")
 

Detailed Description

Test-cases for vnix::units::dyndim_base.

License: BSD three-clause; see LICENSE.

Definition in file dyndim-base-test.cpp.

Typedef Documentation

Definition at line 9 of file dyndim-base-test.cpp.

Definition at line 11 of file dyndim-base-test.cpp.

template<uint64_t D>
using statdim_base = vnix::units::statdim_base<D>

Definition at line 10 of file dyndim-base-test.cpp.

Function Documentation

TEST_CASE ( "Check dimension on dyndim_base from dim."  ,
""  [dyndim-base] 
)

Definition at line 14 of file dyndim-base-test.cpp.

14  {
15  dim constexpr d(-1, 1, 0, 0, 0);
16  dim e(1, 0, 0, 0, 0);
17  REQUIRE(dyndim_base(d).d() == d);
18  REQUIRE(dyndim_base(e).d() == e);
19 }
vnix::units::dyndim_base dyndim_base

Here is the call graph for this function:

TEST_CASE ( "Sum & diff require same dimension for dyndim."  ,
""  [dyndim-base] 
)

Definition at line 22 of file dyndim-base-test.cpp.

22  {
23  dim constexpr d1(-1, 1, 1, 0, 0);
24  dim constexpr d2(+1, 0, 0, 0, 0);
25 
26  dyndim_base ddb(d1);
27  statdim_base<d1.encode()> sdb1;
28  statdim_base<d2.encode()> sdb2;
29 
30  REQUIRE_NOTHROW(ddb.sum(ddb));
31  REQUIRE_NOTHROW(ddb.sum(sdb1));
32  REQUIRE_NOTHROW(ddb.diff(ddb));
33  REQUIRE_NOTHROW(ddb.diff(sdb1));
34 
35  REQUIRE(ddb.sum(ddb).d() == d1);
36  REQUIRE(ddb.sum(sdb1).d() == d1);
37  REQUIRE(ddb.diff(ddb).d() == d1);
38  REQUIRE(ddb.diff(sdb1).d() == d1);
39 
40  REQUIRE_THROWS(ddb.sum(sdb2));
41  REQUIRE_THROWS(ddb.diff(sdb2));
42 }
Base-type for a dimensioned value whose dimension is specified, perhaps dynamically at run-time...
Definition: dyndim-base.hpp:24
Base-type for a dimensioned value whose dimension is specified statically at compile-time by way of a...

Here is the call graph for this function:

TEST_CASE ( "Prod & quot change dimension for dyndim."  ,
""  [dyndim-base] 
)

Definition at line 45 of file dyndim-base-test.cpp.

45  {
46  dim constexpr d1(-1, +1, +1, 0, 0);
47  dim constexpr d2(+1, +0, +0, 0, 0);
48  dim constexpr d3(+0, +1, +1, 0, 0);
49  dim constexpr d4(-2, +1, +1, 0, 0);
50  dim constexpr d5(+1, -1, -1, 0, 0);
51 
52  dyndim_base ddb1(d1), ddb2(d2);
53  statdim_base<d2.encode()> sdb2;
54 
55  REQUIRE(ddb1.prod(ddb2).d() == d3);
56  REQUIRE(ddb1.quot(ddb2).d() == d4);
57  REQUIRE(ddb1.prod(sdb2).d() == d3);
58  REQUIRE(ddb1.quot(sdb2).d() == d4);
59  REQUIRE(ddb1.recip().d() == d5);
60 }
Base-type for a dimensioned value whose dimension is specified, perhaps dynamically at run-time...
Definition: dyndim-base.hpp:24
Base-type for a dimensioned value whose dimension is specified statically at compile-time by way of a...

Here is the call graph for this function:

TEST_CASE ( "Pow and sqrt change dimension for dyndim."  ,
""  [dyndim-base] 
)

Definition at line 63 of file dyndim-base-test.cpp.

63  {
64  using rat = dim::rat;
65 
66  dim constexpr d1(-1, +1, +1, 0, 0);
67  dim constexpr d2(-2, +2, +2, 0, 0);
68  dim constexpr d3(rat(-1, 2), rat(1, 2), rat(1, 2), 0, 0);
69 
70  dyndim_base ddb(d1);
71 
72  REQUIRE(ddb.pow<2>().d() == d2);
73  REQUIRE(ddb.pow(2).d() == d2);
74  REQUIRE(ddb.sqrt().d() == d3);
75 }
rational< 4, 2 > rat
Type of rational for dimensioned values.
Definition: dim.hpp:26
Base-type for a dimensioned value whose dimension is specified, perhaps dynamically at run-time...
Definition: dyndim-base.hpp:24

Here is the call graph for this function: