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

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

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

Go to the source code of this file.

Typedefs

using normalized_pair = vnix::rat::normalized_pair< 5, 3 >
 

Functions

 TEST_CASE ("Input fraction has positive denominator.","[normalized-pair]")
 
 TEST_CASE ("Input fraction is reduced.","[normalized-pair]")
 
 TEST_CASE ("Throw on division by zero.","[normalized-pair]")
 
 TEST_CASE ("Limits are as expected.","[normalized-pair]")
 

Detailed Description

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

License: BSD three-clause; see LICENSE.

Definition in file normalized-pair-test.cpp.

Typedef Documentation

Definition at line 9 of file normalized-pair-test.cpp.

Function Documentation

TEST_CASE ( "Input fraction has positive denominator."  ,
""  [normalized-pair] 
)

Definition at line 12 of file normalized-pair-test.cpp.

12  {
13  normalized_pair const p(3, -2);
14  REQUIRE(p.n() == -3);
15  REQUIRE(p.d() == +2);
16 }
Numerator and denominator of a rational number as separate numbers, not encoded into the same word...

Here is the call graph for this function:

TEST_CASE ( "Input fraction is reduced."  ,
""  [normalized-pair] 
)

Definition at line 19 of file normalized-pair-test.cpp.

19  {
20  normalized_pair const p(-4, 6);
21  REQUIRE(p.n() == -2);
22  REQUIRE(p.d() == +3);
23 }
Numerator and denominator of a rational number as separate numbers, not encoded into the same word...

Here is the call graph for this function:

TEST_CASE ( "Throw on division by zero."  ,
""  [normalized-pair] 
)

Definition at line 26 of file normalized-pair-test.cpp.

26  {
27  REQUIRE_THROWS(normalized_pair(1, 0));
28 }
vnix::rat::normalized_pair< 5, 3 > normalized_pair

Here is the call graph for this function:

TEST_CASE ( "Limits are as expected."  ,
""  [normalized-pair] 
)

Definition at line 31 of file normalized-pair-test.cpp.

31  {
32  REQUIRE_NOTHROW(normalized_pair(-16, 1));
33  REQUIRE_THROWS(normalized_pair(-17, 1));
34 
35  REQUIRE_NOTHROW(normalized_pair(+15, 1));
36  REQUIRE_THROWS(normalized_pair(+16, 1));
37 
38  REQUIRE_NOTHROW(normalized_pair(+1, 8));
39  REQUIRE_THROWS(normalized_pair(+1, 9));
40 }
vnix::rat::normalized_pair< 5, 3 > normalized_pair

Here is the call graph for this function: