From d830593dda9525f12695c8ba2b4f62aa56658687 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 17 Sep 2014 09:58:13 -0600 Subject: Added a unit test that breaks divide. --- src/unitnumber.cpp | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file 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() "18446744073709551615", "2034904753109530147"); } +#undef mathTest + +#define mathTest( anum, op, bnum, scale, answ ) \ + unitTest( (Number(anum, scale) op Number(bnum, scale)).toString() == answ ) +/* +void UnitNumber::number2() +{ + mathTest( "1", /, "17", 10, "0.0588235294" ); + mathTest( "1", /, "177", 10, "0.0056497175" ); +} +*/ + +/* +// clic + 1/17 +0.0588235294 +1/177 +0.0005649717 + + +// bc +1/17 +.0588235294 +1/177 +.0056497175 + + +1/17 +bc: .0588235294 +clic: 0.0588235294 + +1/177 +bc: .0056497175 +clic: 0.0005649717 +*/ +//} +#undef mathTest #define compcheck( anum, op, bnum ) \ a = #anum; b = #bnum; \ @@ -255,8 +292,6 @@ void UnitNumber::radix1() void UnitNumber::fraction1() { - Number a( 8 ), b( 8 ); - mathTestS( 8, "123.456", +, "0.987", "124.443" ); mathTestS( 8, "123.456", -, "0.987", "122.469" ); mathTestS( 8, "123.456", *, "0.987", "121.851072" ); @@ -264,5 +299,8 @@ void UnitNumber::fraction1() mathTestS( 8, "12", /, "4", "3" ); mathTestS( 100, "9", /, "1.9", "4.7368421052631578947368421052631578947368421052631578947368421052631578947368421052631578947368421052" ); + + mathTestS( 10, "1", /, "17", "0.0588235294" ); + mathTestS( 10, "1", /, "177", "0.0056497175" ); } -- cgit v1.2.3