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

Test-cases for vnix::rat::encoding. More...

#include "../vnix/rat/encoding.hpp"
#include "catch.hpp"
Include dependency graph for encoding-test.cpp:

Go to the source code of this file.

Typedefs

using np8_t = vnix::rat::normalized_pair< 5, 3 >
 
using np9_t = vnix::rat::normalized_pair< 5, 4 >
 
using en8_t = vnix::rat::encoding< 5, 3 >
 
using en9_t = vnix::rat::encoding< 5, 4 >
 

Functions

 TEST_CASE ("Constants are computed correctly.","[encoding]")
 
 TEST_CASE ("Limiting values are encoded and decoded.","[encoding]")
 

Detailed Description

Test-cases for vnix::rat::encoding.

License: BSD three-clause; see LICENSE.

Definition in file encoding-test.cpp.

Typedef Documentation

using en8_t = vnix::rat::encoding<5, 3>

Definition at line 11 of file encoding-test.cpp.

using en9_t = vnix::rat::encoding<5, 4>

Definition at line 12 of file encoding-test.cpp.

Definition at line 9 of file encoding-test.cpp.

Definition at line 10 of file encoding-test.cpp.

Function Documentation

TEST_CASE ( "Constants are computed correctly."  ,
""  [encoding] 
)

Definition at line 15 of file encoding-test.cpp.

15  {
16  using en = vnix::rat::encoding<5, 3>;
17  REQUIRE(en::BITS == 8);
18  REQUIRE(en::DNM_MASK == 0x07);
19  REQUIRE(en::NMR_MASK == 0xF8);
20 }
Encoding of numerator and denominator into unsigned word.
Definition: encoding.hpp:19
TEST_CASE ( "Limiting values are encoded and decoded."  ,
""  [encoding] 
)

Definition at line 23 of file encoding-test.cpp.

23  {
24  en8_t const e1(np8_t(-16, 1));
25  en8_t const e2(np8_t(+15, 1));
26  en8_t const e3(np8_t(+1, 8));
27  en9_t const e4(np9_t(-16, 1));
28  en9_t const e5(np9_t(+15, 1));
29  en9_t const e6(np9_t(+1, 16));
30 
31  REQUIRE(e1.n() == -16);
32  REQUIRE(e1.d() == 1);
33 
34  REQUIRE(e2.n() == +15);
35  REQUIRE(e2.d() == 1);
36 
37  REQUIRE(e3.n() == +1);
38  REQUIRE(e3.d() == 8);
39 
40  REQUIRE(e4.n() == -16);
41  REQUIRE(e4.d() == 1);
42 
43  REQUIRE(e5.n() == +15);
44  REQUIRE(e5.d() == 1);
45 
46  REQUIRE(e6.n() == +1);
47  REQUIRE(e6.d() == 16);
48 }
vnix::rat::normalized_pair< 5, 4 > np9_t
vnix::rat::normalized_pair< 5, 3 > np8_t
Encoding of numerator and denominator into unsigned word.
Definition: encoding.hpp:19

Here is the call graph for this function: