summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Buland <mike@xagasoft.com>2014-09-17 09:58:13 -0600
committerMike Buland <mike@xagasoft.com>2014-09-17 09:58:13 -0600
commitd830593dda9525f12695c8ba2b4f62aa56658687 (patch)
tree0fee9ba5b755dc7b5290bc40b35ec248b044756f
parent3ada65d36621787f8dd103e9ae19083ef3c1df5b (diff)
downloadclic-d830593dda9525f12695c8ba2b4f62aa56658687.tar.gz
clic-d830593dda9525f12695c8ba2b4f62aa56658687.tar.bz2
clic-d830593dda9525f12695c8ba2b4f62aa56658687.tar.xz
clic-d830593dda9525f12695c8ba2b4f62aa56658687.zip
Added a unit test that breaks divide.
-rw-r--r--src/unitnumber.cpp42
1 files changed, 40 insertions, 2 deletions
diff --git a/src/unitnumber.cpp b/src/unitnumber.cpp
index 92cf1b7..6e1a7c8 100644
--- a/src/unitnumber.cpp
+++ b/src/unitnumber.cpp
@@ -121,6 +121,43 @@ void UnitNumber::number1()
121 "18446744073709551615", 121 "18446744073709551615",
122 "2034904753109530147"); 122 "2034904753109530147");
123} 123}
124#undef mathTest
125
126#define mathTest( anum, op, bnum, scale, answ ) \
127 unitTest( (Number(anum, scale) op Number(bnum, scale)).toString() == answ )
128/*
129void UnitNumber::number2()
130{
131 mathTest( "1", /, "17", 10, "0.0588235294" );
132 mathTest( "1", /, "177", 10, "0.0056497175" );
133}
134*/
135
136/*
137// clic
138 1/17
1390.0588235294
1401/177
1410.0005649717
142
143
144// bc
1451/17
146.0588235294
1471/177
148.0056497175
149
150
1511/17
152bc: .0588235294
153clic: 0.0588235294
154
1551/177
156bc: .0056497175
157clic: 0.0005649717
158*/
159//}
160#undef mathTest
124 161
125#define compcheck( anum, op, bnum ) \ 162#define compcheck( anum, op, bnum ) \
126 a = #anum; b = #bnum; \ 163 a = #anum; b = #bnum; \
@@ -255,8 +292,6 @@ void UnitNumber::radix1()
255 292
256void UnitNumber::fraction1() 293void UnitNumber::fraction1()
257{ 294{
258 Number a( 8 ), b( 8 );
259
260 mathTestS( 8, "123.456", +, "0.987", "124.443" ); 295 mathTestS( 8, "123.456", +, "0.987", "124.443" );
261 mathTestS( 8, "123.456", -, "0.987", "122.469" ); 296 mathTestS( 8, "123.456", -, "0.987", "122.469" );
262 mathTestS( 8, "123.456", *, "0.987", "121.851072" ); 297 mathTestS( 8, "123.456", *, "0.987", "121.851072" );
@@ -264,5 +299,8 @@ void UnitNumber::fraction1()
264 299
265 mathTestS( 8, "12", /, "4", "3" ); 300 mathTestS( 8, "12", /, "4", "3" );
266 mathTestS( 100, "9", /, "1.9", "4.7368421052631578947368421052631578947368421052631578947368421052631578947368421052631578947368421052" ); 301 mathTestS( 100, "9", /, "1.9", "4.7368421052631578947368421052631578947368421052631578947368421052631578947368421052631578947368421052" );
302
303 mathTestS( 10, "1", /, "17", "0.0588235294" );
304 mathTestS( 10, "1", /, "177", "0.0056497175" );
267} 305}
268 306