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

Test-cases for vnix::gcd. More...

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

Go to the source code of this file.

Functions

 TEST_CASE ("GCD of any x and itself is x.","[gcd]")
 
 TEST_CASE ("GCD of 0 and any x is x.","[gcd]")
 
 TEST_CASE ("GCD of 1 and any x is 1.","[gcd]")
 
 TEST_CASE ("GCD of any relative primes is 1.","[gcd]")
 
 TEST_CASE ("GCD of multiple is factor.","[gcd]")
 
 TEST_CASE ("Otherwise, GCD works.","[gcd]")
 

Detailed Description

Test-cases for vnix::gcd.

License: BSD three-clause; see LICENSE.

Definition in file gcd-test.cpp.

Function Documentation

TEST_CASE ( "GCD of any x and itself is x."  ,
""  [gcd] 
)

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

12  {
13  REQUIRE(gcd(0, 0) == 0);
14  REQUIRE(gcd(1, 1) == 1);
15  REQUIRE(gcd(2, 2) == 2);
16  REQUIRE(gcd(3, 3) == 3);
17  REQUIRE(gcd(4, 4) == 4);
18  REQUIRE(gcd(5, 5) == 5);
19  REQUIRE(gcd(6, 6) == 6);
20  REQUIRE(gcd(7, 7) == 7);
21  REQUIRE(gcd(8, 8) == 8);
22  REQUIRE(gcd(9, 9) == 9);
23 }
constexpr gcd_promoted< A, B > gcd(A a, B b)
Greatest common divisor of two numbers; only absolute values are used.
Definition: gcd.hpp:40

Here is the call graph for this function:

TEST_CASE ( "GCD of 0 and any x is x."  ,
""  [gcd] 
)

Definition at line 26 of file gcd-test.cpp.

26  {
27  REQUIRE(gcd(0, 1) == 1);
28  REQUIRE(gcd(0, 2) == 2);
29  REQUIRE(gcd(0, 3) == 3);
30  REQUIRE(gcd(0, 4) == 4);
31  REQUIRE(gcd(0, 5) == 5);
32  REQUIRE(gcd(0, 6) == 6);
33  REQUIRE(gcd(0, 7) == 7);
34  REQUIRE(gcd(0, 8) == 8);
35  REQUIRE(gcd(0, 9) == 9);
36 
37  REQUIRE(gcd(1, 0) == 1);
38  REQUIRE(gcd(2, 0) == 2);
39  REQUIRE(gcd(3, 0) == 3);
40  REQUIRE(gcd(4, 0) == 4);
41  REQUIRE(gcd(5, 0) == 5);
42  REQUIRE(gcd(6, 0) == 6);
43  REQUIRE(gcd(7, 0) == 7);
44  REQUIRE(gcd(8, 0) == 8);
45  REQUIRE(gcd(9, 0) == 9);
46 }
constexpr gcd_promoted< A, B > gcd(A a, B b)
Greatest common divisor of two numbers; only absolute values are used.
Definition: gcd.hpp:40

Here is the call graph for this function:

TEST_CASE ( "GCD of 1 and any x is 1."  ,
""  [gcd] 
)

Definition at line 49 of file gcd-test.cpp.

49  {
50  REQUIRE(gcd(1, 2) == 1);
51  REQUIRE(gcd(1, 3) == 1);
52  REQUIRE(gcd(1, 4) == 1);
53  REQUIRE(gcd(1, 5) == 1);
54  REQUIRE(gcd(1, 6) == 1);
55  REQUIRE(gcd(1, 7) == 1);
56  REQUIRE(gcd(1, 8) == 1);
57  REQUIRE(gcd(1, 9) == 1);
58 
59  REQUIRE(gcd(2, 1) == 1);
60  REQUIRE(gcd(3, 1) == 1);
61  REQUIRE(gcd(4, 1) == 1);
62  REQUIRE(gcd(5, 1) == 1);
63  REQUIRE(gcd(6, 1) == 1);
64  REQUIRE(gcd(7, 1) == 1);
65  REQUIRE(gcd(8, 1) == 1);
66  REQUIRE(gcd(9, 1) == 1);
67 }
constexpr gcd_promoted< A, B > gcd(A a, B b)
Greatest common divisor of two numbers; only absolute values are used.
Definition: gcd.hpp:40

Here is the call graph for this function:

TEST_CASE ( "GCD of any relative primes is 1."  ,
""  [gcd] 
)

Definition at line 70 of file gcd-test.cpp.

70  {
71  REQUIRE(gcd(2, 3) == 1);
72  REQUIRE(gcd(2, 5) == 1);
73  REQUIRE(gcd(2, 7) == 1);
74  REQUIRE(gcd(3, 2) == 1);
75  REQUIRE(gcd(3, 4) == 1);
76  REQUIRE(gcd(3, 5) == 1);
77  REQUIRE(gcd(3, 7) == 1);
78  REQUIRE(gcd(3, 8) == 1);
79  REQUIRE(gcd(4, 3) == 1);
80  REQUIRE(gcd(4, 5) == 1);
81  REQUIRE(gcd(4, 7) == 1);
82  REQUIRE(gcd(4, 9) == 1);
83  REQUIRE(gcd(5, 2) == 1);
84  REQUIRE(gcd(5, 3) == 1);
85  REQUIRE(gcd(5, 4) == 1);
86  REQUIRE(gcd(5, 7) == 1);
87  REQUIRE(gcd(5, 8) == 1);
88  REQUIRE(gcd(5, 9) == 1);
89  REQUIRE(gcd(6, 5) == 1);
90  REQUIRE(gcd(6, 7) == 1);
91  REQUIRE(gcd(7, 2) == 1);
92  REQUIRE(gcd(7, 3) == 1);
93  REQUIRE(gcd(7, 4) == 1);
94  REQUIRE(gcd(7, 5) == 1);
95  REQUIRE(gcd(7, 6) == 1);
96  REQUIRE(gcd(7, 8) == 1);
97  REQUIRE(gcd(7, 9) == 1);
98  REQUIRE(gcd(8, 3) == 1);
99  REQUIRE(gcd(8, 5) == 1);
100  REQUIRE(gcd(8, 7) == 1);
101  REQUIRE(gcd(8, 9) == 1);
102  REQUIRE(gcd(9, 2) == 1);
103  REQUIRE(gcd(9, 4) == 1);
104  REQUIRE(gcd(9, 5) == 1);
105  REQUIRE(gcd(9, 7) == 1);
106  REQUIRE(gcd(9, 8) == 1);
107 }
constexpr gcd_promoted< A, B > gcd(A a, B b)
Greatest common divisor of two numbers; only absolute values are used.
Definition: gcd.hpp:40

Here is the call graph for this function:

TEST_CASE ( "GCD of multiple is factor."  ,
""  [gcd] 
)

Definition at line 110 of file gcd-test.cpp.

110  {
111  REQUIRE(gcd(2, 4) == 2);
112  REQUIRE(gcd(2, 6) == 2);
113  REQUIRE(gcd(2, 8) == 2);
114  REQUIRE(gcd(3, 6) == 3);
115  REQUIRE(gcd(3, 9) == 3);
116  REQUIRE(gcd(4, 8) == 4);
117 
118  REQUIRE(gcd(4, 2) == 2);
119  REQUIRE(gcd(6, 2) == 2);
120  REQUIRE(gcd(8, 2) == 2);
121  REQUIRE(gcd(6, 3) == 3);
122  REQUIRE(gcd(9, 3) == 3);
123  REQUIRE(gcd(8, 4) == 4);
124 }
constexpr gcd_promoted< A, B > gcd(A a, B b)
Greatest common divisor of two numbers; only absolute values are used.
Definition: gcd.hpp:40

Here is the call graph for this function:

TEST_CASE ( Otherwise,
GCD works."  ,
""  [gcd] 
)

Definition at line 127 of file gcd-test.cpp.

127  {
128  REQUIRE(gcd(4, 6) == 2);
129  REQUIRE(gcd(6, 4) == 2);
130  REQUIRE(gcd(6, 9) == 3);
131  REQUIRE(gcd(9, 6) == 3);
132 }
constexpr gcd_promoted< A, B > gcd(A a, B b)
Greatest common divisor of two numbers; only absolute values are used.
Definition: gcd.hpp:40

Here is the call graph for this function: