1313#endif
1414
1515#include < cassert>
16+ #include < iostream>
1617#include " CoinRational.hpp"
1718
1819void
@@ -21,15 +22,17 @@ CoinRationalUnitTest()
2122
2223 // Test default constructor
2324 {
24- CoinRational r; // 0/1
25- assert (r.getNumerator () == 0 );
26- assert (r.getDenominator () == 1 );
25+ CoinRational a; // 0/1
26+ std::cout << " Testing " << a.getNumerator () << " / " << a.getDenominator () << std::endl;
27+ assert (a.getNumerator () == 0 );
28+ assert (a.getDenominator () == 1 );
2729 }
2830
2931 // Requires int64_t
3032 // Test constructor with assignment
3133 {
3234 CoinRational a (4294967295 , 4294967296 );
35+ std::cout << " Testing " << a.getNumerator () << " / " << a.getDenominator () << std::endl;
3336 assert (a.getNumerator () == 4294967295 );
3437 assert (a.getDenominator () == 4294967296 );
3538 }
@@ -38,6 +41,7 @@ CoinRationalUnitTest()
3841 // Test constructor with assignment
3942 {
4043 CoinRational a (9223372036854775807 , 4294967299 );
44+ std::cout << " Testing " << a.getNumerator () << " / " << a.getDenominator () << std::endl;
4145 assert (a.getNumerator () == 9223372036854775807 );
4246 assert (a.getDenominator () == 4294967299 );
4347 }
@@ -46,101 +50,117 @@ CoinRationalUnitTest()
4650 // Test constructor with nearestRational calls
4751 {
4852 CoinRational a (2147483699.5 , 0.00001 , 4294967299 );
49- assert (a.getNumerator () == 4294967299 );
53+ std::cout << " Testing " << a.getNumerator () << " / " << a.getDenominator () << std::endl;
54+ assert (a.getNumerator () == 4294967399 );
5055 assert (a.getDenominator () == 2 );
5156 }
5257
5358 // Test constructor with nearestRational calls
5459 {
5560 CoinRational a (-3.0 , 0.0001 , 100 );
61+ std::cout << " Testing " << a.getNumerator () << " / " << a.getDenominator () << std::endl;
5662 assert (a.getNumerator () == -3 );
5763 assert (a.getDenominator () == 1 );
5864 }
5965
6066 {
6167 CoinRational a (3.0 , 0.0001 , 100 );
68+ std::cout << " Testing " << a.getNumerator () << " / " << a.getDenominator () << std::endl;
6269 assert (a.getNumerator () == 3 );
6370 assert (a.getDenominator () == 1 );
6471 }
6572
6673 {
6774 // return 0/1 if best is more than maxdelta tolerance
6875 CoinRational a (0.367879441 , 0.0001 , 100 ); // 1/e
76+ std::cout << " Testing " << a.getNumerator () << " / " << a.getDenominator () << std::endl;
6977 assert (a.getNumerator () == 32 );
7078 assert (a.getDenominator () == 87 );
7179 }
7280
7381 {
7482 CoinRational a (10.367879441 , 0.0001 , 100 ); // 10 + 1/e
83+ std::cout << " Testing " << a.getNumerator () << " / " << a.getDenominator () << std::endl;
7584 assert (a.getNumerator () == 902 );
7685 assert (a.getDenominator () == 87 );
7786 }
7887
7988 {
8089 // return 0/1 if best is more than maxdelta tolerance
8190 CoinRational a (0.367879441 , 0.000001 , 100 ); // 1/e
91+ std::cout << " Testing " << a.getNumerator () << " / " << a.getDenominator () << std::endl;
8292 assert (a.getNumerator () == 0 );
8393 assert (a.getDenominator () == 1 );
8494 }
8595
8696 {
8797 CoinRational a (3.0 / 7.0 , 0.0001 , 100 );
98+ std::cout << " Testing " << a.getNumerator () << " / " << a.getDenominator () << std::endl;
8899 assert (a.getNumerator () == 3 );
89100 assert (a.getDenominator () == 7 );
90101 }
91102
92103 {
93104 CoinRational a (7.0 / 3.0 , 0.0001 , 100 );
105+ std::cout << " Testing " << a.getNumerator () << " / " << a.getDenominator () << std::endl;
94106 assert (a.getNumerator () == 7 );
95107 assert (a.getDenominator () == 3 );
96108 }
97109
98110 {
99111 double sqrt13 = sqrt (13 );
100112 CoinRational a (sqrt13, 0.01 , 20 );
113+ std::cout << " Testing " << a.getNumerator () << " / " << a.getDenominator () << std::endl;
101114 assert (a.getNumerator () == 18 );
102115 assert (a.getDenominator () == 5 );
103116 }
104117
105118 {
106119 double sqrt13 = sqrt (13 );
107120 CoinRational a (sqrt13, 0.002 , 30 );
121+ std::cout << " Testing " << a.getNumerator () << " / " << a.getDenominator () << std::endl;
108122 assert (a.getNumerator () == 101 );
109123 assert (a.getDenominator () == 28 );
110124 }
111125
112126 {
113127 CoinRational a (0.25 , 0.1 , 3 );
128+ std::cout << " Testing " << a.getNumerator () << " / " << a.getDenominator () << std::endl;
114129 assert (a.getNumerator () == 1 );
115130 assert (a.getDenominator () == 3 );
116131 }
117132
118133 {
119134 CoinRational a (0.605551 , 0.003 , 30 );
135+ std::cout << " Testing " << a.getNumerator () << " / " << a.getDenominator () << std::endl;
120136 assert (a.getNumerator () == 17 );
121137 assert (a.getDenominator () == 28 );
122138 }
123139
124140 {
125141 CoinRational a (0.605551 , 0.001 , 30 );
142+ std::cout << " Testing " << a.getNumerator () << " / " << a.getDenominator () << std::endl;
126143 assert (a.getNumerator () == 20 );
127144 assert (a.getDenominator () == 33 ); // oops, should be at most 30.
128145 }
129146
130147 {
131148 CoinRational a (0.58496250072 , 0.00001 , 253 );
149+ std::cout << " Testing " << a.getNumerator () << " / " << a.getDenominator () << std::endl;
132150 assert (a.getNumerator () == 179 );
133151 assert (a.getDenominator () == 306 ); // oops, should be at most 253. Expected 148/253, but this is apparently on purpose.
134152 }
135153
136154 {
137155 CoinRational a (19.0 /11.0 , 0.02 , 10 );
156+ std::cout << " Testing " << a.getNumerator () << " / " << a.getDenominator () << std::endl;
138157 assert (a.getNumerator () == 12 );
139158 assert (a.getDenominator () == 7 );
140159 }
141160
142161 {
143162 CoinRational a (-19.0 / 11.0 , 0.02 , 10 );
163+ std::cout << " Testing " << a.getNumerator () << " / " << a.getDenominator () << std::endl;
144164 assert (a.getNumerator () == -12 );
145165 assert (a.getDenominator () == 7 );
146166 }
0 commit comments